Search
Code3,264
// Fetch AI-powered weather insight const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const aiResponse = await openai.chat.completions.create({ messages: [ {
// Fetch AI-powered weather insight const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const aiResponse = await openai.chat.completions.create({ messages: [ {
Frontend: React 18, TailwindCSSAPIs: Open-Meteo, OpenAI GPT-4oHosting: ESM-based module imports
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); // Enhanced server-side logging } const openai = new OpenAI(); const url = new URL(request.url); // Call AgentA to create the tool definition const agentACompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" }, `; const agentBCompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" }, }); // Use AgentB (a separate OpenAI instance) to process the tool request const agentBPrompt = ` You are AgentB, a specialized tool agent designed to process specific information requests. `; const agentBCompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" }, }); // Fallback response if OpenAI fails let agentAResponse: AgentResponse = { actionType: "direct_response", `; const agentACompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" },
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite"); }; const openai = new OpenAI(); const KEY = extractKey(new URL(import.meta.url)); const SCHEMA_VERSION = 3; // Increment schema version for tool support // Call AgentA to create the tool definition const agentACompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" }, `; const agentBCompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" }, } // Use AgentB (a separate OpenAI instance) to process the tool request const agentBPrompt = ` You are AgentB, a specialized tool agent designed to process specific information requests. `; const agentBCompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" }, }); // Fallback response if OpenAI fails let agentAResponse: AgentResponse = { actionType: "direct_response", `; const agentACompletion = await openai.chat.completions.create({ model: "gpt-4o-mini", response_format: { type: "json_object" },
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite"); const openai = new OpenAI(); const url = new URL(request.url); const path = url.pathname.split("/").filter(Boolean); `; const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: componentPrompt }],
"description": "A sample blah manifest demonstrating various tool types and configurations.", "env": { "OPENAI_API_KEY": Deno.env.get("OPENAI_API_KEY"), }, "tools": [
import { openai } from "npm:@ai-sdk/openai";import { generateText } from "npm:ai"; try { const { text: fact } = await generateText({ model: openai("gpt-4o-mini"), system: "You are an expert in conspiracy.", prompt: `Provide an interesting conspiracy for fun`,
# askSMHIUsing OpenAI chat completion with function calls to [SMHI](https://en.wikipedia.org/wiki/Swedish_Meteorological_and_Hydrological_Institute) apiThe API is instructed to use the current time in Europe/Stockholm timezone. ## Relevant API documentation* [SMHI, forecast documentation](https://opendata.smhi.se/apidocs/metfcst/get-forecast.html)* [OPEN AI, GPT function calling documentation](https://platform.openai.com/docs/guides/function-calling?api-mode=chat&lang=javascript)## How to use this endpoint## Enviroment variables* OPENAI_CHAT: Needs to be authorized to write chat completions and to the moderation API.## Packages used* openai: For typesafe API request and responses* valibot: for describing the SMHI API response and function API input* valibot/to-json-schema: Transform the schema to json schema (readable by the GPT API)
import { offset, removeOffset } from "npm:@formkit/tempo";import { isWithinTokenLimit } from "npm:gpt-tokenizer/model/gpt-4o";import { OpenAI } from "npm:openai";import * as v from "npm:valibot";import { openAIModeration } from "./gpt/moderation";import { getWeatherAtCoordinate } from "./smhi/forecast/service";import { getSmhiForecastResponseZodSchema } from "./smhi/schema"; return { error: "Too many tokens in question" }; } const { flagged } = await openAIModeration([question]); if (flagged) { return { error: "Be nice in your question" }; }[], }; const openai = new OpenAI({ apiKey: process.env.OPENAI_CHAT }); const completion = await openai.chat.completions.create({ model: completionOptions.model, store: completionOptions.store, }] : []; const formattedFunctionResponseData = await openai.chat.completions.create({ model: completionOptions.model, store: completionOptions.store,
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