9 "Bullet",
10 "Computer",
11 "Rapid",
12 "Top Rated",
13 "Blitz",
6// Create a summary from a given text using GPT 4
7export const OpenAISummary = async (text: string, config: {
8 apiKey?: string;
9 jwt?: string;
10 modelName?: string;
11} = {}) => {
12 const { apiKey, jwt, modelName = "gpt-4" } = config;
13 if (!apiKey && !jwt) {
14 const { success, reset } = await upstashRateLimiter(
15 "anon",
22 }
23 }
24 else if (!apiKey) {
25 try {
26 await verifyJWT(jwt);
31 }
32 const agent = await AIAgent(
33 apiKey || process.env.OPENAI_API_KEY_GPT4,
34 );
35 const response = await agent.summarize(text, modelName);
10 const { LangChainTracer } = await import("npm:langchain/callbacks");
11 const client = new Client({
12 apiUrl: "https://api.smith.langchain.com",
13 apiKey: process.env.LANGSMITH,
14 });
15 const tracer = new LangChainTracer({ client });
16 const callbacks = options?.verbose !== false ? [tracer] : [];
17 // Set up API key for each providers
18 const args = extend({ callbacks }, options);
19 if (spec?.provider === "openai")
20 args.openAIApiKey = process.env.OPENAI;
21 else if (spec?.provider === "huggingface")
22 args.apiKey = process.env.HUGGINGFACE;
23 // Populate model builders
24 const setup = cond([
2
3export async function spellCheck(req: express.Request, res: express.Response) {
4 let response = await fetch("https://www.dnd5eapi.co/api/spells");
5 let data = await response.json();
6 let countOfSpells = data["count"];
8 let randomSpell = data["results"][randomSpellNumber];
9 let response2 = await fetch(
10 `https://www.dnd5eapi.co/api/spells/${randomSpell["index"]}`,
11 );
12 let data2 = await response2.json();
1export let tell = (msg) => return `I heard you say ${msg}`;
2//Can call w/URL with: https://api.val.town/eval/@dvergin.tell('Howdy')
1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
13 // Test
14 const { results } = fetchJSON(
15 "https://api.openaq.org/v2/locations?" +
16 new URLSearchParams({
17 // This is a comment
3
4/* Search Hacker News via Agolia
5Look for the valid params: https://hn.algolia.com/api */
6export let hnSearch = async ({
7 search_by_date,
17 let cleaned_params = await searchParams(params);
18 let data = await fetchJSON(
19 `http://hn.algolia.com/api/v1/${type}?${cleaned_params}`
20 );
21 if (!data.hits && data.message) {
3export function discordChannel({ botToken, serverId }) {
4 return fetchJSON(
5 `https://discord.com/api/guilds/${serverId}/channels`,
6 {
7 headers: {