valTownChatGPTmain.tsx1 match
3import { renderToString } from "npm:react-dom/server";
45// This uses by personal API key, you'll need to provide your own if
6// you fork this. We'll be adding support to the std/openai lib soon!
7const openai = new OpenAI();
fetchTodaysNytCxPuzzlemain.tsx2 matches
37mini?: boolean;
38}): Promise<PuzzlesData> => {
39// https://api.foracross.com/api/puzzle_list?page=0&pageSize=50&filter%5BnameOrTitleFilter%5D=ny%20times%20june%2019%202024&filter%5BsizeFilter%5D%5BMini%5D=true&filter%5BsizeFilter%5D%5BStandard%5D=true
40const url = new URL("https://api.foracross.com/api/puzzle_list");
41const search = new URLSearchParams();
42search.set("page", `${page}`);
1const HUGGING_FACE_API_URL = "https://api-inference.huggingface.co/models";
2const HUGGING_FACE_API_KEY = Deno.env.get("HUGGING_FACE_API_KEY");
34const defaultModels = {
6061async featureExtraction(input, options) {
62return this.callHuggingFaceAPI(input, options);
63}
6465async textClassification(input, options) {
66return this.callHuggingFaceAPI(input, options);
67}
6869async tokenClassification(input, options) {
70return this.callHuggingFaceAPI(input, options);
71}
7273async questionAnswering(input, options) {
74return this.callHuggingFaceAPI(input, options);
75}
7677async summarization(input, options) {
78return this.callHuggingFaceAPI(input, options);
79}
8081async translation(input, options) {
82return this.callHuggingFaceAPI(input, options);
83}
8485async textGeneration(input, options) {
86return this.callHuggingFaceAPI(input, options);
87}
8889async sentenceSimilarity(input, options) {
90return this.callHuggingFaceAPI(input, options);
91}
9293async callHuggingFaceAPI(payload, options) {
94try {
95const response = await fetch(`${HUGGING_FACE_API_URL}/${this.model}`, {
96method: "POST",
97headers: {
98"Authorization": `Bearer ${HUGGING_FACE_API_KEY}`,
99"Content-Type": "application/json"
100},
104if (!response.ok) {
105const error = await response.json();
106console.error("Hugging Face API Error:", error);
107return { error: `API request failed: ${error.error}` };
108}
109111return data;
112} catch (error) {
113console.error("Error calling Hugging Face API:", error);
114return { error: "Error calling Hugging Face API" };
115}
116}
verifyTokenmain.tsx1 match
1async function fetchUser(token: string): Promise<{ id: string }> {
2const resp = await fetch("https://api.val.town/v1/me", {
3headers: {
4Authorization: `Bearer ${token}`,
vtApiTypesmain.tsx12 matches
1/**
2* This file was auto-generated by openapi-typescript.
3* Do not make direct changes to the file.
4*/
427* Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.
428*
429* Vals generated via this API will *not* appear in the authenticated user's workspace.
430*/
431get: {
463* Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.
464*
465* Vals generated via this API will *not* appear in the authenticated user's workspace.
466*/
467post: {
494"/v1/run/{username}.{val_name}": {
495/**
496* Run a val as an API
497* @deprecated
498* @description This endpoint runs the specified user's val and returns the output.
526};
527/**
528* Run a val as an API
529* @deprecated
530*/
563"/": {
564/**
565* Run a val as an API (as an Express handler)
566* @description Runs `@{username}.{val_name}` as an Express handler.
567*
568* `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
569*
570* Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.
571*
572* ### Unauthenticated
573* Unauthenticated use will only be able to call public vals as Express handlers.
574*
575* The val will be executed with `{username}`'s permissions ("API Mode"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.
576*
577* ### Authenticated
601};
602/**
603* Run a val as an API (as an Express handler)
604* @description Runs `@{username}.{val_name}` as an Express handler.
605*
606* `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).
607*
608* ### Unauthenticated
609* Unauthenticated use will only be able to call public vals as Express handlers.
610*
611* The val will be executed with `{username}`'s permissions ("API Mode"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.
612*
613* ### Authenticated
1import { blob } from "https://esm.town/v/std/blob";
2import process from "node:process";
3import { TodoistApi } from "npm:@doist/todoist-api-typescript";
4import Instructor from "npm:@instructor-ai/instructor";
5import Jimp from "npm:jimp";
15// the task is skipped
1617const TODOIST_API_KEY = process.env.TODOIST_API_KEY;
18const HABITIFY_API_KEY = process.env.HABITIFY_API_KEY;
19const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
20const DEF_TIMEZONE = "America/Los_Angeles"; // Get your timezone from here: https://stackoverflow.com/a/54500197
2147};
4849const todoistapi = new TodoistApi(TODOIST_API_KEY);
5051const oai = new OpenAI({
52apiKey: OPENAI_API_KEY ?? undefined,
53});
54107async function getCommentsForTask(taskId) {
108try {
109const comments = await todoistapi.getComments({ taskId });
110return comments;
111} catch (error) {
137const response = await fetch(url, {
138headers: {
139Authorization: `Bearer ${TODOIST_API_KEY}`,
140},
141});
310311async function addLog(habit_id, unit_type, value, target_date) {
312const url = `https://api.habitify.me/logs/${habit_id}`;
313const headers = {
314Authorization: HABITIFY_API_KEY,
315"Content-Type": "application/json",
316};
338}
339async function addTextNote(habit_id, created, content) {
340const url = `https://api.habitify.me/notes/${habit_id}`;
341const headers = {
342Authorization: HABITIFY_API_KEY,
343"Content-Type": "application/json",
344};
366367async function addImageNote(habit_id, created_at, imageBuffer) {
368const url = `https://api.habitify.me/notes/addImageNote/${habit_id}?created_at=${encodeURIComponent(created_at)}`;
369const headers = {
370Authorization: HABITIFY_API_KEY,
371"Content-Type": "image/jpeg",
372};
395if (!habits_list || force_update_database)
396{
397const HABITIFY_API_KEY = process.env.HABITIFY_API_KEY;
398const url = "https://api.habitify.me/habits";
399const headers = {
400Authorization: HABITIFY_API_KEY,
401"Content-Type": "application/json",
402};
456export default async function(interval: Interval) {
457const habits_list = await get_habitify_database();
458var tasks = await todoistapi.getTasks({
459projectId: add_to_habitify_todoist_project_id,
460});
520}
521}
522await todoistapi.deleteTask(task.id);
523}
524}
hfApiGatewayREADME.md12 matches
1## 🤖 A gateway to Hugging Face's Inference API
23You can perform various NLP tasks using different [models](https://huggingface.co/models). The gateway supports multiple tasks, including feature extraction, text classification, token classification, question answering, summarization, translation, text generation, and sentence similarity.
21```bash
22# Example Default Model Request
23curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"source_sentence": "Hello World", "sentences": ["Goodbye World", "How are you?", "Nice to meet you."]}}' "https://iamseeley-hfapigateway.web.val.run/?task=feature-extraction"
24```
2528**Feature Extraction**
29```bash
30curl -X POST -H "Content-Type: application/json" -d '{"inputs": ["Hello World", "Goodbye World"]}' "https://iamseeley-hfapigateway.web.val.run/?task=feature-extraction&model=BAAI/bge-base-en-v1.5"
31```
32**Feature Extraction**
33```bash
34curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"source_sentence": "Hello World", "sentences": ["Goodbye World", "How are you?", "Nice to meet you."]}}' "https://iamseeley-hfapigateway.web.val.run/?task=feature-extraction&model=sentence-transformers/all-MiniLM-L6-v2"
35```
36**Text Classification**
37```bash
38curl -X POST -H "Content-Type: application/json" -d '{"inputs": "I love programming!"}' "https://iamseeley-hfapigateway.web.val.run/?task=text-classification&model=j-hartmann/emotion-english-distilroberta-base"
39```
40**Token Classification**
41```bash
42curl -X POST -H "Content-Type: application/json" -d '{"inputs": "My name is John and I live in New York."}' "https://iamseeley-hfApiGateway.web.val.run/?task=token-classification&model=dbmdz/bert-large-cased-finetuned-conll03-english"
43```
44**Question Answering**
45```bash
46curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"question": "What is the capital of France?", "context": "The capital of France is Paris, a major European city and a global center for art, fashion, gastronomy, and culture."}}' "https://iamseeley-hfapigateway.web.val.run/?task=question-answering&model=deepset/roberta-base-squad2"
47```
48**Summarization**
49```bash
50curl -X POST -H "Content-Type: application/json" -d '{"inputs": "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."}' "https://iamseeley-hfapigateway.web.val.run/?task=summarization&model=sshleifer/distilbart-cnn-12-6"
51```
52**Translation**
53```bash
54curl -X POST -H "Content-Type: application/json" -d '{"inputs": "Hello, how are you?"}' "https://iamseeley-hfapigateway.web.val.run/?task=translation&model=google-t5/t5-small"
55```
56**Text Generation**
57```bash
58curl -X POST -H "Content-Type: application/json" -d '{"inputs": "Once upon a time"}' "https://iamseeley-hfapigateway.web.val.run/?task=text-generation&model=gpt2"
59```
60**Sentence Similarity**
61```bash
62curl -X POST -H "Content-Type: application/json" -d '{"inputs": {"source_sentence": "Hello World", "sentences": ["Goodbye World"]}}' "https://iamseeley-hfapigateway.web.val.run/?task=sentence-similarity&model=sentence-transformers/all-MiniLM-L6-v2"
63```
6493[exampleQuestionAnswering](https://esm.town/v/iamseeley/exampleQuestionAnswering)
9495Migrated from folder: hf_gateway/hfApiGateway
dailyDadJokemain.tsx1 match
34export async function dailyDadJoke() {
5let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6console.log(setup, punchline);
7return email({
dailyDadJokeREADME.md2 matches
113. 🤣🤣🤣🤣
1213## API
1415This val uses the [icanhazdadjoke API](https://icanhazdadjoke.com/api). You can find [more docs here](https://github.com/15Dkatz/official_joke_api), such as how to [filter by type](https://github.com/15Dkatz/official_joke_api?tab=readme-ov-file#grab-jokes-by-type).
fuchsiaSnipemain.tsx1 match
1export default async function(req: Request): Promise<Response> {
2const response = await fetch("http://worldtimeapi.org/api/timezone/America/New_York")
3const timeData = await response.json()
4