Search
Code3,172
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";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ {
try { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const parseResponse = await openai.chat.completions.create({ messages: [{ role: "system", const parsedQuery = parseResponse.choices[0].message.content || ''; Logger.log('OpenAI parsed query', { parsedQuery }); const [rootNode, context] = parsedQuery.split('|').map(s => s.trim());
if (typeof document !== "undefined") { client(); }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(); // Use the val's URL as a unique key for database tables const echoPrompt = getEchoPrompt(); const completion = await openai.chat.completions.create({ messages: [ { // First, generate the agent prompt const completion2 = await openai.chat.completions.create({ messages: [ { // Then, generate commands for the agent based on its purpose and description const commandsCompletion = await openai.chat.completions.create({ messages: [ { } // Format the history into OpenAI message format const messages = [ { // Add conversation history if it exists if (history && history.length > 0) { // Filter out system messages and map to OpenAI format history.forEach(msg => { if (msg.role !== "system") { // Chat with the agent using the stored prompt and history const completion = await openai.chat.completions.create({ messages: messages, model: "gpt-4o-mini", // Execute the command with the AI const completion = await openai.chat.completions.create({ messages: messages, model: "gpt-4o-mini",
import React, { useState, useEffect, useContext, createContext } from "https://esm.sh/react@18.2.0";import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";import { OpenAI } from "https://esm.town/v/std/openai";// Accessibility Utilities const generateAIResponse = async (text) => { try { const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: "أنت مساعد ذكي مخصص للمكفوفين، مهمتك تقديم مساعدة شاملة وداعمة" }, const imageData = canvas.toDataURL('image/jpeg'); const openai = new OpenAI(); const response = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ try { const openai = new OpenAI(); const routeResponse = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [
console.log("🔊 Sending request to Groq Speech API"); const start = Date.now(); const response = await fetch("https://api.groq.com/openai/v1/audio/speech", { method: "POST", headers: {
console.log("🔵 Sending request to Groq API"); const start = Date.now(); const response = await fetch("https://api.groq.com/openai/v1/chat/completions", { method: "POST", headers: {
console.log("🎤 Sending request to Groq Whisper API"); const start = Date.now(); const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", { method: "POST", headers: {
app.post("/extract-recipe", async (c) => { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const formData = await c.req.formData(); try { const response = await openai.chat.completions.create({ model: "gpt-4o", messages: [
if (request.method === 'POST' && new URL(request.url).pathname === '/chat') { try { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); const body = await request.json(); const completion = await openai.chat.completions.create({ messages: body.messages.map((msg: Message) => ({ role: msg.role, }); } catch (error) { console.error('OpenAI Error:', error); return new Response(JSON.stringify({ message: 'Sorry, I encountered an error processing your request.'
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