Search

3,343 results found for openai (1739ms)

Code
3,248

## ✨ Features
-**AI-Powered Conversion**: Uses OpenAI GPT-4o-mini to intelligently convert questions
-**Smart Caching**: Stores results to avoid redundant API calls
-**Rate Limiting**: Respects Val Town's OpenAI API limits (50 requests/minute)
-**TypeScript SDK**: Clean, typed interface for easy integration
-**Batch Processing**: Convert multiple questions with built-in rate limiting
## ⚡ Rate Limiting
The API includes intelligent rate limiting to respect Val Town's OpenAI API limits:
- **50 requests per minute** maximum
## 🔧 Technical Details
- **AI Model**: OpenAI GPT-4o-mini (via Val Town's built-in OpenAI integration)
- **Database**: SQLite for caching (via Val Town's SQLite integration)
- **Framework**: Hono for the web API
import { Hono } from "npm:hono";
import { cors } from "npm:hono/cors";
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
let requestCount = 0;
let resetTime = Date.now() + 60000; // Reset every minute
const RATE_LIMIT = 50; // Conservative limit per minute for OpenAI
async function checkRateLimit(): Promise<boolean> {
}
const openai = new OpenAI();
const prompt = `Convert this "when will" question into a declarative statement suitable for a
try {
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",
return statement;
} catch (error) {
console.error("OpenAI API error:", error);
throw new Error("Failed to convert question to statement");
}
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { 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 cre
### OpenAI
```ts
import { 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" },
/** AI models, AI labs */
"https://openai.com/news/rss.xml",
"https://raw.githubusercontent.com/Olshansk/rss-feeds/main/feeds/feed_anthropic_news.xml",
"https://raw.githubusercontent.com/Olshansk/rss-feeds/main/feeds/feed_ollama.xml",
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { 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 { stream } from "npm:hono@4.4.12/streaming";
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES & PROMPT ---
const { messages } = await c.req.json();
const openai = new OpenAI();
// Create a streaming completion
const completionStream = await openai.chat.completions.create({
model: "gpt-4o",
messages: messages,
- [ ] Get OpenTownie or Gemini or Claude or OpenAI to synthesize the core of these patterns into
- [ ] Convert this or into the basic react router guest book (and preserve this forum app in ano
- [ ] To what extent can these patterns be packaged up into a Val Town Router project? Would be
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
`Give me just the sqlite command for this task${tableSpecificSnippet}, with no formatting or
// Initialize OpenAI
const openai = new OpenAI();
try {
// Generate response using OpenAI
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: decodedPrompt },
<AIAssistantStoredInstruction>
<option name="actionId" value="AIAssistant.General.ProjectPrompt" />
e.g., add _2 or _3) to create a fresh table.&#10;&#10;### OpenAI&#10;&#10;```ts&#10;import { Ope
</AIAssistantStoredInstruction>
</value>