1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
3export function discordMessages({ botToken, channelId }) {
4 return fetchJSON(
5 `https://discord.com/api/channels/${channelId}/messages`,
6 {
7 headers: {
2
3export let hnSearchByDate = (params) => fetchJSON(
4 `http://hn.algolia.com/api/v1/search_by_date?${new URLSearchParams(params)}`
5)
15 const llm = new ChatOpenAI({
16 modelName: "gpt-3.5-turbo",
17 openAIApiKey: process.env.openai,
18 temperature: 0,
19 });
1import { runValAPI } from "https://esm.town/v/stevekrouse/runValAPI";
2
3export const runValAPIEx = runValAPI("@patrickjm.gpt3", {
4 prompt: "write me a limerick about sandboxing javascript",
5});
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let valtownAPIExamples = [
4 "https://api.val.town/v1/alias/stevekrouse",
5 "https://api.val.town/v1/users/a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18",
6 "https://api.val.town/v1/alias/stevekrouse/fetchJSON",
7 "https://api.val.town/v1/vals/18b54b4e-779a-4c56-8ee6-4c75af7e55f0",
8].map(fetchJSON);
3
4export let getMessages = (channelId) => fetchJSON(
5 `https://discord.com/api/channels/${channelId}/messages`, {
6 headers: {
7 "Authorization": `Bot ${discordBotToken}`,
1import { runValAPI } from "https://esm.town/v/stevekrouse/runValAPI";
2import { safeCounter as safeCounter2 } from "https://esm.town/v/stevekrouse/safeCounter";
3import { sleep } from "https://esm.town/v/stevekrouse/sleep";
22 // value of it, now that I know it can't be updated until I release this lock.
23 //
24 // Note 2: I use `@stevekrouse.runValAPI` here instead of `api` (used below)
25 // because `api` only works on funcitons and @stevekrouse.threadsafeStateEx
26 // is a JSON val.
27 let { state } = await runValAPI(
28 "@stevekrouse.threadsafeStateEx",
29 );
30 // 5. Update the state
31 //
32 // Note 3: I update the state via an API call here to ensure that the state
33 // is fully updated *before* I release the lock. If I were to update the state
34 // directly in this val, `@stevekrouse.updateThreadsafeStateEx = `, those
1export function myApi(name) {
2 return "hi " + name;
3}