Search
Code3,280
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- AI BEHAVIORAL GUIDELINES & PROMPTS --- const url = new URL(req.url.endsWith("/") ? req.url : req.url + "/"); const action = url.searchParams.get("action"); const openai = new OpenAI(); if (req.method !== "POST") { // Stage 1: Analyze Input const analysisCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: PROMPT_ANALYZE }, { role: "user", content: userContext }], JSON.stringify(structuredOutline) }\n---\nRecipient Address:\n${userInput.recipient}\n---\nSender Address:\n${userInput.sender}`; const composeCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: PROMPT_COMPOSE }, { role: "user", content: composeUserMessage }], // Stage 3: Internal Critique of Pre-Draft const firstReviewCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: PROMPT_REDTEAM_REVIEW }, { role: "user", content: preDraftText }], JSON.stringify(firstCritique) }`; const revisionCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: PROMPT_REVISE }, { role: "user", content: revisionUserMessage }], // Stage 5: Final Critique of Revised Draft const finalReviewCompletion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: PROMPT_REDTEAM_REVIEW }, { role: "user", content: revisedLetterText }],
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" },
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 { render } from "https://esm.sh/preact-render-to-string@6.5.6";import { blob } from "https://esm.town/v/std/blob?v=11";import { OpenAI } from "https://esm.town/v/std/openai?v=4";import { sqlite } from "https://esm.town/v/std/sqlite?v=4";import { Hono } from "npm:hono@4.4.12"; c.executionCtx.waitUntil((async () => { try { const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: VENT_ANALYSIS_PROMPT }, { c.executionCtx.waitUntil((async () => { try { const openai = new OpenAI(); const founderSummary = "A B2B SaaS company building developer tools for cloud-native observability."; // Placeholder const prompt = THESIS_ALIGNMENT_PROMPT .replace("{investorWritings}", body.public_writings); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: prompt }],
import { OpenAI } from "https://esm.town/v/std/openai";import { Hono } from "npm:hono@4";const app = new Hono();const openai = new OpenAI();app.get("/", async c => c.text("Hello World"));app.get("/openai", async (c) => { const response = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },
/** * OpenAI API Client * Documentation: https://platform.openai.com/docs/api-reference */export class OpenAIClient { private readonly apiKey: string; private readonly baseUrl = "https://api.openai.com/v1"; constructor(apiKey?: string) { this.apiKey = apiKey || Deno.env.get('OPENAI_API_KEY') || ''; if (!this.apiKey) { throw new Error('OPENAI_API_KEY is required'); } } if (!response.ok) { await ApiLogger.handleApiError(response, url, 'OpenAIClient', options.body); } // Otherwise, log the unexpected error and re-throw ApiLogger.logApiError(error, 'OpenAIClient', url); throw error; } }); ApiLogger.logOpenAIResponse(response, data as unknown as Record<string, unknown>, "preprocessing"); const filteredExpectations = data.choices?.[0]?.message?.content || allExpectations; }); ApiLogger.logOpenAIResponse(response, data as unknown as Record<string, unknown>, "gpt-4.1-analysis"); // Extract the final message content from the response if (!finalMessage || !finalMessage.content || !finalMessage.content[0]) { throw new Error('No valid response content from OpenAI'); } }); ApiLogger.logOpenAIResponse(response, data as unknown as Record<string, unknown>, "candidate-feedback"); const outputMessages = data.output || []; if (!finalMessage || !finalMessage.content || !finalMessage.content[0]) { throw new Error('No valid response content from OpenAI for feedback generation'); }
}// ===== OPENAI API TYPES =====/** * OpenAI API documentation: https://platform.openai.com/docs/api-reference */
// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";import { sqlite } from "https://esm.town/v/std/sqlite?v=4"; const action = url.searchParams.get("action"); await initializeDatabase(); const openai = new OpenAI(); const extractJson = (text: string) => { switch (action) { case "startSimulation": { const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: SCENARIO_GENERATOR_PROMPT }], Process this action and respond with the specified JSON object.`; const completion = await openai.chat.completions.create({ model: "gpt-4o", 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