untitled-61main.tsx1 match
8• Display each summary in a card layout: headline, short summary, timestamp, and source link.
9• Functionality
10• Fetch Somali news articles from APIs (local news websites or RSS feeds).
11• Use Gemini AI to summarize the article into 3–5 bullet points.
12• Provide an option to switch between Somali and English summaries.
untitled-7046main.tsx1 match
8• Display each summary in a card layout: headline, short summary, timestamp, and source link.
9• Functionality
10• Fetch Somali news articles from APIs (local news websites or RSS feeds).
11• Use Gemini AI to summarize the article into 3–5 bullet points.
12• Provide an option to switch between Somali and English summaries.
value-sortknowledge.md14 matches
14- Generate code in TypeScript or TSX
15- Add appropriate TypeScript types and interfaces for all data structures
16- Prefer official SDKs or libraries than writing API calls directly
17- Ask the user to supply API or library documentation if you are at all unsure about it
18- **Never bake in secrets into the code** - always use environment variables
19- Include comments explaining complex logic (avoid commenting obvious operations)
24### 1. HTTP Trigger
2526- Create web APIs and endpoints
27- Handle HTTP requests and responses
28- Example structure:
135## GreenPTClient
136137The `GreenPTClient` is a function that allows interaction with the GreenPT API for chat completions. It accepts a model parameter and provides an `invoke` method to send messages and retrieve responses asynchronously. To ensure API security, it requires an API key stored in environment variables.
138139### Example Usage
146async function getChatResponse() {
147const messages = [
148{ role: "user", content: "What is the capital of France?" },
149];
150153console.log("AI Response:", response);
154} catch (error) {
155console.error("Error invoking GreenPT API:", error);
156}
157}
161```
162163In this example, we create an instance of `GreenPTClient`, send a message asking about the capital of France, and log the AI's response. Error handling is included to catch any issues with the API call.
164165228However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
229If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
230or by making an API request for it.
231232## Val Town Platform Specifics
236- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
237- **Storage:** DO NOT use the Deno KV module for storage
238- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
239- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
240- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
241- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
242- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
243- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
244- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
245- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
279### Backend (Hono) Best Practices
280281- Hono is the recommended API framework
282- Main entry point should be `backend/index.ts`
283- **Static asset serving:** Use the utility functions to read and serve project files:
303});
304```
305- Create RESTful API routes for CRUD operations
306- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
307```ts
340- For files in the project, use `readFile` helpers
3413425. **API Design:**
343- `fetch` handler is the entry point for HTTP vals
344- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
value-sortopenai-client.mdc2 matches
15Use GlobalRateLimitedChatOpenAI(model, requestsPerSecond) to enforce a global rate limit on chat completions, suitable for shared or public-facing endpoints.
16Val Town/Platform Notes
17Uses Val Town’s standard SQLite API for persistent storage.
18Designed for server-side use (no browser-specific code).
19No secrets are hardcoded; OpenAI API keys are managed by the OpenAI SDK/environment.
value-sort.cursorrules10 matches
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
2425- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
175or by making an API request for it.
176177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248});
249```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252```ts
285- For files in the project, use `readFile` helpers
2862875. **API Design:**
288- `fetch` handler is the entry point for HTTP vals
289- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
untitled-3540main.tsx1 match
12};
1314return fetch("https://extraction-api.nanonets.com/extract", {
15method: "POST",
16headers: headers,
tennis_scoreboard_espn_3main.tsx3 matches
5// ===============================
67// [REPO-SWAP #1]: replace this stub with: import { logger } from "@api/shared/logger"
8// and then: const log = logger.child({ label: "tool:topic:tennis-liveboard" })
9const log = {
179}
180181// ---------- ESPN API ----------
182async function fetchBucket(tour: "atp" | "wta", day: string) {
183const url =
184`https://site.api.espn.com/apis/site/v2/sports/tennis/${tour}/scoreboard?dates=${day}&_=${Date.now()}`;
185const res = await fetch(url, { headers: { "Cache-Control": "no-cache" } });
186if (!res.ok) return null;
hello-realtimeutils.ts8 matches
1const MODEL = "gpt-realtime";
2const INSTRUCTIONS = `
3Greet the user in English, and thank them for trying the new OpenAI Realtime API.
4Give them a brief summary based on the list below, and then ask if they have any questions.
5Answer questions using the information below. For questions outside this scope,
7---
8Short summary:
9- The Realtime API is now generally available, and has improved instruction following, voice naturalness, and audio quality.
10There are two new voices and it's easier to develop for. There's also a new telephony integration for phone scenarios.
11Full list of improvements:
16- higher audio quality
17- improved handling of alphanumerics (eg, properly understanding credit card and phone numbers)
18- support for the OpenAI Prompts API
19- support for MCP-based tools
20- auto-truncation to reduce context size
21- native telephony support, making it simple to connect voice calls to existing Realtime API applications
22- when using WebRTC, you can connect without needing an ephemeral token
23- when using WebRTC, you can now control sessions (including tool calls) from the server
27const VOICE = "marin";
2829const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
30if (!OPENAI_API_KEY) {
31throw new Error("🔴 OpenAI API key not configured");
32}
3334export function makeHeaders(contentType?: string) {
35const obj: Record<string, string> = {
36Authorization: `Bearer ${OPENAI_API_KEY}`,
37};
38if (contentType) obj["Content-Type"] = contentType;
hello-realtimesip.ts1 match
2728// Accept the call.
29const url = `https://api.openai.com/v1/realtime/calls/${callId}/accept`;
30const headers = makeHeaders("application/json");
31const body = JSON.stringify(makeSession());
hello-realtimertc.ts1 match
7rtc.post("/", async (c) => {
8// Create the call.
9const url = "https://api.openai.com/v1/realtime/calls";
10const headers = makeHeaders();
11const fd = new FormData();