Search
Code3,267
import { type OpenAI } from "npm:openai";import { dedent } from "npm:ts-dedent";`.trim();const developerPrompt: OpenAI.ChatCompletionDeveloperMessageParam = { "role": "developer", "content": promptContent,
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { 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" },
import { z } from "npm:zod@4.0.5";import { generateText, tool } from "npm:ai@5.0.0-beta.16";import { openai } from "npm:@ai-sdk/openai@2.0.0-beta.7";const result = await generateText({ model: openai("gpt-4o"), tools: { weather: tool({
Note: When changing a SQLite table's schema, change the table's name (e.g., add \_2 or \_3) to create a fresh table.### OpenAI```tsimport { 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 create a fresh table.### OpenAI```tsimport { 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" },
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { 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" },
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { 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" },
│ │ ├── files-tools.ts # Files store tool handlers│ │ ├── code-tools.ts # Code execution tool handlers│ │ └── openai-tools.ts # OpenAI API tool handlers│ └── valtown/│ └── client.ts # Val Town API client (for admin features)- **admin-project-info**: Get project information and structure overview using Val Town API (admin only)#### OpenAI API Tools- **openai-chat-completion**: Create chat completions using OpenAI's API via Val Town's built-in OpenAI integration (supports GPT-4, GPT-3.5, and other models)## OpenAI IntegrationThe server includes OpenAI chat completion functionality using Val Town's built-in OpenAI integration. This provides seamless access to OpenAI's models without requiring additional API key configuration.### Example Usage "method": "tools/call", "params": { "name": "openai-chat-completion", "arguments": { "messages": [ "method": "tools/call", "params": { "name": "openai-chat-completion", "arguments": { "messages": [- `tools["files-exists"](args)` - Check if file exists in your personal file store- `tools["files-metadata"](args)` - Get file metadata from your personal file store- `tools["openai-chat-completion"](args)` - Create OpenAI chat completions### Two Execution Modes**Note**: `AWS_SECRET_ACCESS_KEY` is NOT set as an environment variable. Instead, it's passed via the Authorization header for security.**OpenAI Integration**: OpenAI functionality uses Val Town's built-in OpenAI integration, which automatically handles API key management. No additional environment variables are required for OpenAI tools.### DynamoDB Table Schema
] as const;// OpenAI Toolsexport const OPENAI_TOOLS = [ { name: "openai-chat-completion", description: "Create a chat completion using OpenAI's API via Val Town's OpenAI integration", inputSchema: { type: "object", model: { type: "string", description: "The OpenAI model to use", default: "gpt-4o-mini", enum: [ ...FILES_TOOLS, ...CODE_TOOLS, ...OPENAI_TOOLS,] as const; ...FILES_TOOLS, ...CODE_TOOLS, ...OPENAI_TOOLS, ...ADMIN_TOOLS,] as const;
import { OpenAI } from "https://esm.town/v/std/openai";import { zodResponseFormat } from "npm:openai/helpers/zod";import { z } from "npm:zod";const VERIFY_TOKEN = "butler";const openai = new OpenAI();const app = new Hono();export async function parseReminder(text: string) { const completion = await openai.chat.completions.create({ messages: [ {
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
lost1991
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
No docs found