Search
Code3,282
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" },
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" },
/** * OpenAI API tool handlers using Val Town's OpenAI integration */import { OpenAI } from "https://esm.town/v/std/openai";import { AuthContext } from "../../storage/kv-store.ts";// OpenAI API typesinterface ChatMessage { role: "system" | "user" | "assistant";}export class OpenAIToolHandlers { private openai: OpenAI; constructor() { this.openai = new OpenAI(); } async handleChatCompletion(args: ChatCompletionRequest, authContext: AuthContext) { try { const completion = await this.openai.chat.completions.create({ messages: args.messages, model: args.model || "gpt-4o-mini", }; } catch (error) { throw new Error(`OpenAI API error: ${error.message}`); } }
import { GlobalRateLimiter, ensureGlobalRateLimitTableExists } from "https://esm.town/v/cricks_unmixed4u/openai-client/GlobalRateLimiter.tsx?v=37";import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";import { BaseMessage, HumanMessage } from "npm:@langchain/core/messages";import { BaseCheckpointSaver } from "npm:@langchain/langgraph-checkpoint";import { createReactAgent } from "npm:@langchain/langgraph/prebuilt";import { ChatOpenAI } from "npm:@langchain/openai";import { z } from "npm:zod";// Create the agent with toolsfunction createAgent() { const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }); const getWeather = tool((input) => {
import { OpenAI } from "https://esm.town/v/std/openai";type ACPStatus = "SUCCESS" | "FAILURE" | "NEEDS_HUMAN_INPUT";async function rootCauseAnalysisAgent(acp: ACP): Promise<ACP> { const openai = new OpenAI(); const enrichedData = acp.payload.content; let userMessage = ` try { const response = await openai.chat.completions.create({ model: "gpt-4o", response_format: { "type": "json_object" },async function articleDrafterAgent(acp: ACP): Promise<ACP> { const openai = new OpenAI(); const { topic, keywords, angle, research, feedback } = acp.payload.content; let userMessage = `Write a blog post about "${topic}". Keywords: ${ } try { const response = await openai.chat.completions.create({ model: "gpt-4o", messages: [
import { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ {
Configure the following variables in your environment: - `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)- `OPENAI_API_KEY` (An OpenAI API Key)- `EXA_API_KEY` (Optional, though needed if you use the web search tool)
import { anthropic } from "npm:@ai-sdk/anthropic";import { openai } from "npm:@ai-sdk/openai";import { generateText, streamText } from "npm:ai";import { getSystemPrompt } from "./prompt.tsx"; const maxSteps = 10; const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1"); const options = {
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