Search
Code3,282
<a href="?q=function" className="example-link">function</a> <a href="?q=discord" className="example-link">discord</a> <a href="?q=openai" className="example-link">openai</a> <a href="?q=react" className="example-link">react</a> </div> <a href="?q=function" className="example-link">function</a> <a href="?q=discord" className="example-link">discord</a> <a href="?q=openai" className="example-link">openai</a> <a href="?q=react" className="example-link">react</a> </div>
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 { Hono } from "https://esm.sh/hono@3.11.7";import { OpenAI } from "https://esm.town/v/std/openai";import { saveItinerary, const app = new Hono();const openai = new OpenAI();function generateId(): string { Provide realistic coordinates within the actual site boundaries.`; const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini",
}, { "title": "An Introduction to OpenAI fine-tuning", "slug": "an-introduction-to-openai-fine-tuning", "link": "/blog/an-introduction-to-openai-fine-tuning", "description": "How to customize OpenAI to your liking", "pubDate": "Fri, 25 Aug 2023 00:00:00 GMT", "author": "Steve Krouse", "slug": "val-town-newsletter-16", "link": "/blog/val-town-newsletter-16", "description": "Our seed round, growing team, Codeium completions, @std/openai, and more", "pubDate": "Mon, 22 Apr 2024 00:00:00 GMT", "author": "Steve Krouse",
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" },
// MEES Assistant API Endpoint// Remember to add your environment variables in Val settings:// - OPENAI_API_KEY// - PINECONE_API_KEY// - ASSISTANT_IDimport { OpenAI } from "https://deno.land/x/openai@v4.20.1/mod.ts";import { Pinecone } from "https://esm.sh/@pinecone-database/pinecone@1.1.2";const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });const pinecone = new Pinecone({ apiKey: Deno.env.get("PINECONE_API_KEY") });const ASSISTANT_ID = Deno.env.get("ASSISTANT_ID"); // Get embedding for query const embeddingResponse = await openai.embeddings.create({ model: "text-embedding-3-small", input: query, let thread; if (threadId) { thread = await openai.beta.threads.retrieve(threadId); } else { thread = await openai.beta.threads.create(); } // Add message to thread await openai.beta.threads.messages.create(thread.id, { role: "user", content: message, // Run the assistant const run = await openai.beta.threads.runs.create(thread.id, { assistant_id: ASSISTANT_ID, }); // Poll for completion let runStatus = await openai.beta.threads.runs.retrieve(thread.id, run.id); let allMediaDisplays = []; while (runStatus.status !== "completed" && runStatus.status !== "failed") { await new Promise(resolve => setTimeout(resolve, 1000)); runStatus = await openai.beta.threads.runs.retrieve(thread.id, run.id); if (runStatus.status === "requires_action") { allMediaDisplays = [...allMediaDisplays, ...mediaDisplays]; await openai.beta.threads.runs.submitToolOutputs(thread.id, run.id, { tool_outputs: toolOutputs, }); // Get the assistant's response const messages = await openai.beta.threads.messages.list(thread.id); const lastMessage = messages.data[0]; const response = lastMessage.content[0].type === "text"
// This approach fetches GitHub activity for two users specified in the URL,// sends it to OpenAI for analysis, and returns collaboration suggestions.// It uses the GitHub API (which doesn't require authentication for public data)// and the OpenAI API (which does require an API key).// Tradeoff: We're using an inline API key for simplicity, which isn't ideal for security.// Note: This might hit rate limits for the GitHub API due to fetching a year of data.import { OpenAI } from "https://esm.town/v/std/openai";const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API keyexport default async function main(req: Request): Promise<Response> { const user1Summary = summarizeActivity(user1Data); const openai = new OpenAI(OPENAI_API_KEY); const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [
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" },
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