Search

189 results found for openai (404ms)

Code
187

import { Agent, run, webSearchTool } from "npm:@openai/agents@0.3.0";
const instructions = `You research the web looking for news stories
│ │ │ ├── blocks.ts # Block operations
│ │ │ └── search.ts # Search operations
│ │ ├── aiService.ts # OpenAI for fuzzy matching
│ │ └── blobService.ts # Val Town blob storage
│ └── utils/ # Utility functions
### Strategy 4: AI Fuzzy Matching with Date Disambiguation
If strategies 1-3 don't find a match, the system uses OpenAI (via Val Town's
`@std/openai`) to match the todo text against project names and client names.
**Initial AI Match**:
- Sends the todo text and list of projects (with client names) to OpenAI
(`gpt-4o-mini`)
- AI returns one of:
(Strategies 4-5)
**OpenAI Integration**:
- Uses Val Town's built-in OpenAI integration (`@std/openai`)
- Model: `gpt-4o-mini` (fast, cost-effective)
- AI calls per todo (when needed):
try {
const page = await browser.newPage();
await page.goto("https://en.wikipedia.org/wiki/OpenAI");
const intro = await page.evaluate(
`document.querySelector('p:nth-of-type(2)').innerText`,
"llama-3.1-8b-instant",
],
endpoint: "https://api.groq.com/openai/v1/chat/completions",
},
openrouter: {
}
async function callOpenAICompatibleAPI(
endpoint: string,
apiKey: string,
}
response = await callOpenAICompatibleAPI(
providerConfig.endpoint,
effectiveApiKey,
Note: When changing a SQLite table's schema, change the table's name (e.g., add \_2 or \_3) to c
### OpenAI
```ts
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Say hello in a creative way" }],
model: "gpt-4o-mini",
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: "Say hello in a creative way" },
// Val: nanoBananaImageOpenAI
// Adaptado pra ser OpenAI-compatible pro Open WebUI remoto, mantendo o handler original como fa
// 1. LISTAS DE OPÇÕES VÁLIDAS
if (pathname === "/v1/images/generations") {
// Handler pra OpenAI-compatible (pro Open WebUI)
if (req.method !== "POST") {
return Response.json({ error: "Use POST" }, { status: 405 });
const {
prompt,
size = "1024x1024", // Default OpenAI style
n = 1, // Número de imagens, mas por agora suportamos só 1
response_format = "b64_json",
} = body;
// Mapear size OpenAI pra aspectRatio e imageSize
let aspectRatio = "1:1";
let imageSize = "2K";
if (imageData && imageData.data && imageData.mimeType) {
// Retorna no formato OpenAI: array de data com b64_json ou url
const images = [];
for (let i = 0; i < n; i++) { // Suporte básico a n>1, mas gera a mesma imagem
// 3. DESCRIÇÃO DA FERRAMENTA
export const description = {
name: "nanoBananaImageOpenAI",
description:
"Gera imagens via Google Nano Banana, agora com endpoint OpenAI-compatible em /v1/images/genera
inputSchema: {
type: "object",
type: "string",
description:
"Tamanho no formato OpenAI como '1024x1024', mapeado pra aspectRatio e imageSize.",
},
n: { type: "integer", description: "Número de imagens (default 1)." },
- **Frontend**: React 18 + Twind (TailwindCSS)
- **Database**: Val Town SQLite
- **AI**: OpenAI for recipe extraction
**Goal:** Build a lightweight recipe management app on Val Town that lets users save recipes fro
backend serving a React frontend. SQLite for persistence. OpenAI for recipe extraction from scra
tack:** Val Town, TypeScript, Hono, React 18.2.0, SQLite, OpenAI GPT-4o-mini, TailwindCSS (via T
---
// backend/routes/ingest.ts
import { Hono } from "https://esm.sh/hono@4.4.2";
import { OpenAI } from "https://esm.town/v/std/openai";
import { createRecipe } from "../database/queries.ts";
import type { IngestRequest } from "../../shared/types.ts";
const ingest = new Hono();
const openai = new OpenAI();
// POST /api/ingest - Extract recipe from URL
// Use AI to extract structured recipe data
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
max_tokens: 2000,
1. Click [**Remix**](/?intent=remix)
1. Store your `OPENAI_API_KEY` as an environment variable
[here](https://www.val.town/x/templates/leads/environment-variables)
1. Customize [`PROMPT.txt`](./PROMPT.txt) (Don't remove any fields from the
- The webhook receives each POST request and stores the incoming data as
`input_data`
- All `input_data` is passed to the OpenAI agent in [`agent.ts`](./agent.ts)
**AI Agent**
openai-agents
kidjs
openai-agents
Template to use the OpenAI Agents SDK
Public
openai-agents
EatPraySin
openai-agents
Template to use the OpenAI Agents SDK
Public

Users

No users found

Docs

No docs found
13
Next