Search
Code3,215
// ============================================================================// OPENAI INTEGRATION (40 lines)// ============================================================================async function callOpenAI(prompt: string): Promise<SimpleAnalysisResult> { const requestBody = { model: 'gpt-4o-mini', }; // Log the full request being sent to OpenAI console.log('=== OPENAI REQUEST BEING SENT ==='); console.log('Model:', requestBody.model); console.log('Max completion tokens:', requestBody.max_completion_tokens); console.log('Response format:', requestBody.response_format); console.log('=== PROMPT BEING SENT TO OPENAI ==='); console.log(prompt); console.log('=== END PROMPT ==='); console.log('Request body size (chars):', JSON.stringify(requestBody).length); console.log('=== END OPENAI REQUEST ==='); const response = await fetch('https://api.openai.com/v1/chat/completions', { method: 'POST', headers: { 'Authorization': `Bearer ${Deno.env.get('OPENAI_API_KEY')}`, 'Content-Type': 'application/json' }, if (!response.ok) { throw new Error(`OpenAI API error: ${response.status} - ${response.statusText}`); } const content = data.choices[0].message.content; // Log the response from OpenAI console.log('=== OPENAI RESPONSE RECEIVED ==='); console.log('Usage:', data.usage); console.log('Model used:', data.model); console.log('Response content length:', content?.length || 0); console.log('=== OPENAI RESPONSE CONTENT ==='); console.log(content); console.log('=== END OPENAI RESPONSE ==='); try { return JSON.parse(content); } catch (error) { console.error('Failed to parse OpenAI response:', content); throw new Error('Invalid JSON response from OpenAI'); }} const prompt = buildAnalysisPrompt(teamStats, roster); console.log('Calling OpenAI for enhanced analysis...'); // Get AI analysis const analysis = await callOpenAI(prompt); console.log(`Analysis complete. Grade: ${analysis.overall_grade}, Recommendations: ${analysis.waiver_recommendations.length}`);
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" },
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); if (request.method === "POST" && new URL(request.url).pathname === "/chat") { async start(controller) { try { const chatCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI Error:", error); controller.enqueue( new TextEncoder().encode(
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); if (request.method === "POST" && new URL(request.url).pathname === "/chat") { async start(controller) { try { const chatCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI Error:", error); controller.enqueue( new TextEncoder().encode(
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); if (request.method === "POST" && new URL(request.url).pathname === "/chat") { async start(controller) { try { const chatCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI Error:", error); controller.enqueue( new TextEncoder().encode(
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); if (request.method === "POST" && new URL(request.url).pathname === "/chat") { async start(controller) { try { const chatCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI Error:", error); controller.enqueue( new TextEncoder().encode(
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); if (request.method === "POST" && new URL(request.url).pathname === "/chat") { async start(controller) { try { const chatCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI Error:", error); controller.enqueue( new TextEncoder().encode(
export default async function server(request: Request): Promise<Response> { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(); if (request.method === "POST" && new URL(request.url).pathname === "/chat") { async start(controller) { try { const chatCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [ } } catch (error) { console.error("OpenAI Error:", error); controller.enqueue( new TextEncoder().encode(
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