Search
Code3,267
// AI-powered content suggestion generatorimport { OpenAI } from "https://esm.town/v/std/openai";import { TweetAnalysis } from "./analyzer.ts";): Promise<ContentSuggestion[]> { try { const openai = new OpenAI(); // Create a sample of recent tweets for context `; const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini",
const postingFrequency = calculatePostingFrequency(tweets); // Use OpenAI to analyze the content more deeply const aiAnalysis = await performAIContentAnalysis(allContent); /** * Uses OpenAI to perform deeper content analysis */async function performAIContentAnalysis(content: string): Promise<{}> { try { import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const prompt = ` `; const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini",
- **Backend**: `/backend/index.ts` - Handles API requests and serves frontend assets - OpenAI integration for chat completions - API endpoints for authentication, chat, and user data - Supabase integration for database and authentication- **Database**: Supabase- **Authentication**: Supabase Auth- **AI**: OpenAI API- **Styling**: Custom CSS with Tailwind utility classes
import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";import { Hono } from "npm:hono";import { OpenAI } from "https://esm.town/v/std/openai";import { supabase, getSession } from "../shared/supabase.ts";import { AIAgent, Message, Conversation, UserSettings } from "../shared/types.ts";const app = new Hono();const openai = new OpenAI();// Default AI agents if database is not set up }; // Prepare context for OpenAI // Only use the last 10 messages for context to stay within token limits const recentMessages = messageHistory.slice(-10).map((msg: Message) => ({ }); const completion = await openai.chat.completions.create({ messages: recentMessages, model: agent.model,
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" },
<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>
import { fetch } from "https://esm.town/v/std/fetch";import { OpenAI } from "https://esm.town/v/std/openai";import { z } from "npm:zod";}// --- OpenAI Call Wrapper (Minor Abbreviation) ---async function callOpenAI( sysP: string, userP: string, log("DB", "oai", `Call tid=${tid}`, { spL: sysP.length, upL: userP.length }, mid, tid); try { if (!process.env.OPENAI_API_KEY) { log("ER", "oai", "Key missing.", {}, mid, tid); throw new Error("OpenAI Key missing."); } const oai = new OpenAI(); const comp = await oai.chat.completions.create({ model: "gpt-4o-mini", try { const { sys, user } = cfg.p(p); const rawC = await callOpenAI(sys, user, mid, tid, log); if (!rawC) { log("WN", cfg.n, `No LLM content tid=${tid}.`, {}, mid, tid);
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