Search
Code3,282
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" },
// Your Telegram Bot Token (provided by you)const BOT_TOKEN = '8016525726:AAHkYt9R87OTWDcELwjCrOCmjNBTJZCEk4M';// Your OpenAI API Key (You MUST replace 'YOUR_OPENAI_API_KEY' with your actual key)const OPENAI_API_KEY = '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'; // !! REPLACE THIS PLACEHOLDER !!const CHANNEL_USERNAME = '@mandoqa'; // The target channel username// Base URLs for APIsconst TELEGRAM_API_BASE = `https://api.telegram.org/bot${BOT_TOKEN}`;const OPENAI_API_BASE = 'https://api.openai.com/v1';// Key prefix for storing sent subjects in KV try { const prompt = buildQuizPrompt(randomSubject); const openaiResponse = await fetch(`${OPENAI_API_BASE}/chat/completions`, { method: 'POST', headers: { 'Authorization': `Bearer ${OPENAI_API_KEY}`, 'Content-Type': 'application/json' }, }); const openaiResult = await openaiResponse.json(); if (!openaiResponse.ok) { console.error('OpenAI API Error:', openaiResult); return `Error calling OpenAI API: ${openaiResult.error?.message || 'Unknown error'}`; } // Parse the LLM's JSON response const llmResponseContent = openaiResult.choices[0]?.message?.content; if (!llmResponseContent) { console.error('OpenAI response content missing:', openaiResult); return 'Error: OpenAI response content missing.'; } } catch (error) { console.error('Error communicating with OpenAI API:', error); return `Error communicating with OpenAI API: ${error.message}`; }
from fastapi import APIRouter, HTTPException, Dependsfrom typing import List, Optionalimport openaiimport osfrom datetime import datetime, timedeltaDEMO_USER_ID = 1# OpenAI configurationopenai.api_key = os.getenv('OPENAI_API_KEY')# Health checkasync def process_voice_input(request: VoiceProcessRequest): try: if not openai.api_key: raise HTTPException(status_code=500, detail="OpenAI API key not configured") response = openai.ChatCompletion.create( model="gpt-4", messages=[async def process_receipt(request: ReceiptProcessRequest): try: if not openai.api_key: raise HTTPException(status_code=500, detail="OpenAI API key not configured") response = openai.ChatCompletion.create( model="gpt-4-vision-preview", messages=[
pydantic==2.5.0python-multipart==0.0.6openai==1.3.0python-dotenv==1.0.0Pillow==10.1.0
- **Styling:** TailwindCSS with custom animations- **Voice:** Web Speech API- **AI:** OpenAI for receipt processing## 📁 Project Structure
- 🎙️ Record voice notes directly in the browser- 🤖 AI-powered transcription using OpenAI Whisper- 🔗 Share voice notes via unique URLs- ⏰ Set expiration by max listens or date- **Database**: SQLite for voice note metadata- **Storage**: Val Town Blob storage for audio files- **AI**: OpenAI Whisper for transcription- **Frontend**: React with TypeScript- **Styling**: TailwindCSS
// https://oops--06dc8e5037c411f088ef9e149126039e.web.val.runimport { OpenAI } from "npm:openai";const client = new OpenAI({ apiKey: "Placeholder", // This is the default and can be omitted baseURL: "https://oops--06dc8e5037c411f088ef9e149126039e.web.val.run/v1",
import { Hono } from "https://esm.sh/hono@3.11.7";import { OpenAI } from "https://esm.town/v/std/openai";import { blob } from "https://esm.town/v/std/blob";import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";});const openai = new OpenAI();// Serve static files console.log("Added user message"); // Prepare messages for OpenAI (limit to last 10 messages to avoid token limits) const recentMessages = conversation.messages.slice(-10); const openaiMessages = recentMessages.map(msg => ({ role: msg.role as "user" | "assistant", content: msg.content })); console.log("Calling OpenAI with", openaiMessages.length, "messages"); // Get AI response const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: openaiMessages, max_tokens: 1000, temperature: 0.7, }); console.log("OpenAI response received"); const aiContent = completion.choices[0]?.message?.content; if (!aiContent) { throw new Error("No content in OpenAI response"); }
- Typing indicators- Responsive design- OpenAI GPT integration## Project Structure## Setup1. Set your OpenAI API key in environment variables as `OPENAI_API_KEY`2. The app will be available at the HTTP endpoint
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