Search
Code3,279
import { openai } from "npm:@ai-sdk/openai";import { generateText, streamText } from "npm:ai";import { getSystemPrompt } from "./prompt.tsx"; const options = { model: openai("gpt-4.1"), temperature: 0.1, maxSteps,
2. It fetches the Abercrombie & Fitch website with browser-like headers3. Extracts both general content and specific promotional elements4. Uses OpenAI to analyze if there's a special sale or promotion5. If a sale is detected, it sends an email notification with details6. Tracks the state of sales to avoid sending duplicate notifications2. The email will be sent to the email address associated with your Val Town account.3. Make sure you have set up your OpenAI API key in Val Town environment variables.## CustomizationIf the AI analysis isn't working:- Verify your OpenAI API key is correctly set in Val Town- Check if you have sufficient credits in your OpenAI account- Review the logs to see the AI's response and reasoning
import { email } from "https://esm.town/v/std/email";import { blob } from "https://esm.town/v/std/blob";import { OpenAI } from "https://esm.town/v/std/openai";// This function will run on a schedule via cron// Function to use AI to analyze if there's a saleasync function analyzeForSale(pageContent): Promise<SaleAnalysis> { const openai = new OpenAI(); const prompt = ``; const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: prompt }
import { Hono } from "https://esm.sh/hono@3.11.7";import { OpenAI } from "https://esm.town/v/std/openai";import * as db from "../database/queries.ts";import type { ConversationRequest, ConversationResponse } from "../../shared/types.ts";const api = new Hono();const openai = new OpenAI();// Get all subjects }); // Prepare messages for OpenAI const systemPrompt = `You are an educational assistant helping a student learn about ${concept.title} in ${concept.subject}. Your goal is to explain concepts clearly, ask thoughtful questions to check understanding, and provide helpful feedback. ]; // Get response from OpenAI const completion = await openai.chat.completions.create({ messages: apiMessages, model: "gpt-4o-mini", let suggestedFollowUps: string[] = []; try { const followUpCompletion = await openai.chat.completions.create({ messages: [ ...apiMessages,
- Frontend: React with TypeScript- Database: SQLite for data storage- AI: OpenAI API for conversational learning- Styling: TailwindCSS
1. Enter your name or a keyword in the input field2. Click the "Generate Quote" button3. The application sends your input to the OpenAI API4. A personalized motivational quote is generated and displayed- **Frontend**: HTML, CSS (Tailwind CSS), and JavaScript- **Backend**: Val Town HTTP trigger with OpenAI API integration- **AI**: Uses OpenAI's GPT-3.5-Turbo model to generate personalized quotes quickly## Project Structure## Dependencies- OpenAI API (via Val Town's standard library)- Tailwind CSS (via CDN)
import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";import { OpenAI } from "https://esm.town/v/std/openai";// Initialize OpenAI clientconst openai = new OpenAI();export default async function(req: Request): Promise<Response> { } // Generate quote using OpenAI - using gpt-3.5-turbo for faster response const completion = await openai.chat.completions.create({ messages: [ { }); console.log("OpenAI response:", completion); // Debug log let quote = completion.choices[0]?.message?.content || "Could not generate a quote. Please try again.";
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" },
- **Rule-based AI**: Provides pre-written orthodox responses based on topic detection- **ChatGPT Integration**: Optional use of OpenAI's GPT models for more dynamic responses- **Bible Verses**: Includes relevant Bible verses to support orthodox arguments- **Modern Web Interface**: Clean, responsive design with settings panel
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