1export function myApi(name) {
2 return "hi " + name;
3}
1export function myApi(name) {
2 return "hi " + name;
3}
4 try {
5 const wiki = await fetch(
6 `https://en.wikipedia.org/w/api.php?action=query&format=json&titles=${article}&prop=extracts&explaintext`,
7 ).then((res) => res.json());
8 if (!wiki.query) {
1import { twitterAPIDown } from "https://esm.town/v/stevekrouse/twitterAPIDown";
2
3export async function twitterAPIDownAlert() {
4 if (twitterAPIDown.down)
5 console.email(
6 twitterAPIDown.reason,
7 "Twitter API may be down!"
8 );
9}
3export async function runAllTests({
4 names,
5 api,
6}: {
7 names: string[];
8 api: string;
9}) {
10 let validAPI =
11 api.startsWith("http://localhost") ||
12 api.startsWith("https://api.val.town");
13 if (!validAPI) return "bad api";
14 let results = [];
15 for (let name of names) {
16 console.log(
17 `${api}/eval/@stevekrouse.${name}("${encodeURIComponent(api)}")`
18 );
19 results.push(
20 (
21 await fetchJSON(
22 `${api}/eval/@stevekrouse.${name}("${encodeURIComponent(api)}")`
23 )
24 ).data + ` (${name})`
7 const model = new OpenAI({
8 temperature: 0.9,
9 openAIApiKey: process.env.openai,
10 maxTokens: 100,
11 });
3// GitHub events
4export let githubEvents = fetchJSON(
5 "https://api.github.com/users/stevekrouse/events"
6);
1import { spotifyAPI } from "https://esm.town/v/stevekrouse/spotifyAPI";
2
3export let spotifyDiscoverWeeklyPlaylist = async (token) =>{
4 let search = await spotifyAPI({
5 endpoint: 'search',
6 q: 'Discover Weekly',
1export function myApi(req, res) {
2 res.set("Content-Type", "application/json");
3 res.send([{ value: "wangtianbao", url: "https://www.967111.net" }]);
18 );
19 const chatModel = new ChatOpenAI({
20 openAIApiKey: process.env.OPENAI_API_KEY,
21 });
22 /* Create the vectorstore */
29 [{ id: 2 }, { id: 1 }, { id: 3 }],
30 new OpenAIEmbeddings({
31 openAIApiKey: process.env.OPENAI_API_KEY,
32 }),
33 );