Search

3,377 results found for openai (7996ms)

Code
3,282

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" },
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" },
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" },
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" },
/**
* 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 types
interface 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}`);
}
}
itTableExists } from "https://esm.town/v/cricks_unmixed4u/openai-client/GlobalRateLimiter.tsx?v=
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 tools
function 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;
ROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
const options = {