47- **Frontend**: React with TypeScript
48- **Visualizations**: Canvas API, SVG animations
49- **AI Simulation**: OpenAI API for entity communication
50- **Data Storage**: Val Town blob storage
51- **Styling**: TailwindCSS with custom neon effects
con-juanindex.html1 match
205await handlePatternsExample(typingIndicator);
206} else {
207// For general questions, use the OpenAI API
208await handleGeneralQuestion(question, typingIndicator);
209}
Towniesystem_prompt.txt4 matches
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
8990### OpenAI
9192```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96messages: [
97{ role: "user", content: "Say hello in a creative way" },
Townie.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
autonomous-valREADME.md1 match
7Configure the following variables in your environment:
8- `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)
9- `OPENAI_API_KEY` (An OpenAI API Key)
10- `EXA_API_KEY` (Optional, though needed if you use the web search tool)
11
autonomous-valagent.tsx2 matches
1import { anthropic } from "npm:@ai-sdk/anthropic";
2import { openai } from "npm:@ai-sdk/openai";
3import { generateText, streamText } from "npm:ai";
4import { getSystemPrompt } from "./prompt.tsx";
34const maxSteps = 10;
3536const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
3738const options = {
autonomous-valagent.tsx2 matches
1import { anthropic } from "npm:@ai-sdk/anthropic";
2import { openai } from "npm:@ai-sdk/openai";
3import { generateText, streamText } from "npm:ai";
4import { getSystemPrompt } from "./prompt.tsx";
34const maxSteps = 10;
3536const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
3738const options = {
untitled-7748telegram-image-bot.ts7 matches
1// Telegram Bot that uses OpenAI's DALL-E to generate images
2import { OpenAI } from "https://esm.town/v/std/openai";
34// Initialize OpenAI client
5const openai = new OpenAI();
67// Telegram Bot API types
91}
9293// Function to generate an image using OpenAI's DALL-E
94async function generateImage(prompt: string) {
95try {
96const response = await openai.images.generate({
97model: "dall-e-3",
98prompt: prompt,
123chatId,
124"👋 Welcome to the Image Generation Bot!\n\n" +
125"I can generate images based on your descriptions using OpenAI's DALL-E model.\n\n" +
126"Simply send me a description of the image you want to create, and I'll generate it for you.\n\n" +
127"For example: *A serene lake surrounded by mountains at sunset*"
Hubspot-Research.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
nightwatchmain.tsx16 matches
1// Val Town Narrative Engine with Integrated Test UI
2// =============================================================================
3import { OpenAI } from "https://esm.town/v/std/openai"; // Val Town's OpenAI integration
4// import { Env } from "https://esm.town/v/std/env"; // Not needed if OpenAI() handles API key
56// --- Configuration & Constants ---
7const OPENAI_MODEL = "gpt-4o";
8const MAX_TOKENS_RESPONSE = 700;
9127}
128129// --- OpenAI System Prompt (same as before) ---
130const SYSTEM_PROMPT = `
131You are a Rick and Morty-styled transdimensional narrative engine, probably cobbled together by Rick in a drunken stupor. Your primary role is to generate hilariously chaotic, compelling, and atmospherically bizarre narrative turns for an epic journey to save the multiverse (or, you know, whatever Rick feels like doing).
549} = ensureDefaultsAndInferStates(inputContext);
550551const contextForOpenAI = {
552...processedContext,
553_inferred_states_for_your_convenience: {
558};
559const userMessage = `Input Context JSON (with inferred states for your reference):\n${
560JSON.stringify(contextForOpenAI, null, 2)
561}`;
562563try {
564const openai = new OpenAI();
565const completion = await openai.chat.completions.create({
566model: OPENAI_MODEL,
567response_format: { type: "json_object" },
568messages: [
576const rawContent = completion.choices[0]?.message?.content;
577if (!rawContent) {
578console.error("OpenAI returned an empty response message.");
579return new Response(
580JSON.stringify(
581getFallbackOutput("OpenAI empty response.", processedContext),
582),
583{ status: 500, headers: { "Content-Type": "application/json" } },
595) {
596console.error(
597"OpenAI response missing critical fields or incorrect structure.",
598JSON.stringify(generatedJson, null, 2),
599);
602JSON.stringify(
603getFallbackOutput(
604"OpenAI response schema validation failed after generation.",
605processedContext,
606),
618});
619} catch (error) {
620console.error("Error during OpenAI API call or processing:", error);
621let errorMessage = "Internal server error";
622if (error.response && error.response.data && error.response.data.error) { // More specific OpenAI error
623errorMessage = `OpenAI API Error: ${error.response.data.error.message}`;
624} else if (error.message) {
625errorMessage = error.message;