Search
Code3,282
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)
}, { "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",
</div> <div class="border rounded-lg p-4"> <h3 class="font-semibold text-orange-600 mb-2">🤖 OpenAI</h3> <ul class="text-sm text-gray-600 space-y-1"> <li>• openai_chat</li> </ul> </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 { OpenAI } from "https://esm.town/v/std/openai";import type { AnalysisResponse } from "../../shared/types.ts";const openai = new OpenAI();export async function analyzeImage(imageData: string, fileName: string): Promise<AnalysisResponse> { const base64Data = imageData.replace(/^data:image\/[a-z]+;base64,/, ''); const response = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ const audioFile = new File([audioBlob], fileName, { type: 'audio/wav' }); const transcription = await openai.audio.transcriptions.create({ file: audioFile, model: "whisper-1", // Analyze the transcribed text const textAnalysis = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ // In practice, you'd need to extract frames from the video const response = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [export async function generateSearchSuggestions(query: string): Promise<string[]> { try { const response = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [
- **Multi-Media Support**: Image, video, and audio recognition- **Real-time Capture**: In-browser media capture capabilities- **AI Analysis**: Powered by OpenAI's vision and audio models- **Intelligent Search**: Find similar content based on descriptions- **Secure Storage**: User data and media metadata stored securely## Technology Stack- **Backend**: Hono, SQLite, OpenAI API- **Frontend**: React, TailwindCSS- **AI/ML**: OpenAI GPT-4 Vision, Whisper- **Storage**: Val Town Blob storage- **Authentication**: JWT-based sessions1. Set up environment variables: - `OPENAI_API_KEY`: Your OpenAI API key - `JWT_SECRET`: Secret for JWT token signing
}, { "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",
// Get your API key from Val.town environment variables const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY"); const ASSISTANT_ID = Deno.env.get("ASSISTANT_ID"); if (!OPENAI_API_KEY || !ASSISTANT_ID) { throw new Error( "Missing API key or Assistant ID in environment variables. Please set OPENAI_API_KEY and ASSISTANT_ID.", ); } if (!threadId || threadId === "") { console.log("Creating new thread..."); const threadResponse = await fetch("https://api.openai.com/v1/threads", { method: "POST", headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "Content-Type": "application/json", "OpenAI-Beta": "assistants=v2", }, body: JSON.stringify({}), // Add message and run assistant console.log("Running assistant..."); const runResponse = await fetch(`https://api.openai.com/v1/threads/${threadId}/runs`, { method: "POST", headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "Content-Type": "application/json", "OpenAI-Beta": "assistants=v2", }, body: JSON.stringify({ const statusResponse = await fetch( `https://api.openai.com/v1/threads/${threadId}/runs/${runId}`, { headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "OpenAI-Beta": "assistants=v2", }, }, console.log("Getting messages..."); const messagesResponse = await fetch( `https://api.openai.com/v1/threads/${threadId}/messages?order=desc&limit=1`, { headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "OpenAI-Beta": "assistants=v2", }, },
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" },
{ getRandomRegexExplanation, saveRegexExplanation, getRegexExplanationById }, ReactMarkdown, { OpenAI }, { renderToString }, { jsx, jsxs, Fragment }, import("https://esm.town/v/stainless_em/brainrotdb"), import("npm:react-markdown@7"), import("https://esm.town/v/std/openai"), import("npm:react-dom@19/server.browser"), import("npm:react@19/jsx-runtime"), } const openai = new OpenAI(); const abortController = new AbortController(); 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