Search

3,280 results found for ā€œopenaiā€ (2334ms)

Code
3,185

import { Hono } from "npm:hono@4.4.12";
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai";
import type { Context } from "npm:hono@4.4.12";
import { streamText } from "npm:hono/streaming";
try {
const openai = new OpenAI();
const agentStream = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "system", content: systemPromptWithContext }, { role: "user", content:
const { refined_prompt, company_context } = await c.req.json<GenerateCriteriaBody>();
try {
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
const { refined_prompt, criteria, raw_output, language } = await c.req.json<EvaluateBody>();
try {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
const { refined_prompt, raw_output, evaluation, language } = await c.req.json<RefineBody>();
try {
const openai = new OpenAI();
const stream = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- TYPE DEFINITIONS ---
async function processTestCase(
testCase: TestCase,
openai: OpenAI,
): Promise<TestResult> {
// Phase 1: Solver
const solverCompletion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "system", content: SOLVER_PROMPT }, {
// Phase 2: Verifier
const verifierCompletion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
reasoning: solverOutput.chain_of_thought,
};
const evaluatorCompletion = await openai.chat.completions.create({
model: "gpt-4o-2024-05-13",
messages: [
throw new Error("Invalid or empty test cases provided.");
}
const openai = new OpenAI();
const results = await Promise.all(
testCases.map((testCase) => processTestCase(testCase, openai)),
);
return new Response(JSON.stringify(results), {
import {OpenAI} from "https://esm.town/v/std/openai"
import {getQuizTeams} from "./database.ts"
}
// Check if OpenAI API key is available
const apiKey = Deno.env.get("OPENAI_API_KEY")
if (!apiKey) {
console.log("OpenAI API key not available, using fallback suggestions")
return {
suggestions: getFallbackSuggestions(language),
try {
const openai = new OpenAI()
const completion = await openai.chat.completions.create({
model: "gpt-5-nano",
messages: [
const response = completion.choices[0]?.message?.content || ""
console.log(`OpenAI response for ${language}:`, response)
// Parse response into array of suggestions
}
} else {
console.log("OpenAI returned insufficient suggestions, using fallback")
return {
suggestions: getFallbackSuggestions(language),
} catch (error) {
console.error("OpenAI API error:", error)
return {
suggestions: getFallbackSuggestions(language),
## Usage
The application generates a single workout using OpenAI while avoiding the last 2 generated work
import { Hono } from "https://esm.sh/hono@3.11.7";
import { OpenAI } from "https://esm.town/v/std/openai";
import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
import { blob } from "https://esm.town/v/std/blob";
app.onError((err) => Promise.reject(err));
const openai = new OpenAI();
interface WorkoutComponent {
try {
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: prompt }],
model: "gpt-4o-mini",
const content = completion.choices[0]?.message?.content;
if (!content) {
throw new Error("No content received from OpenAI");
}
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" },
#### Issues in Epic 3:
##### Issue #3.1: OpenAI Integration Service
**Labels**: `backend`, `ai`, `medium-priority`
**Story Points**: 5
**Dependencies**: None (can be done in parallel)
Integrate OpenAI API for generating culturally appropriate team name suggestions.
**Acceptance Criteria:**
- [ ] OpenAI API integration with proper error handling
- [ ] Multi-language prompt engineering (Hindi, English, Gujarati)
- [ ] Rate limiting to prevent API abuse
**Technical Tasks:**
- Implement OpenAI API client
- Create language-specific prompts
- Add rate limiting middleware
**Labels**: `frontend`, `ui`, `medium-priority`
**Story Points**: 3
**Dependencies**: Issue #3.1 (OpenAI Integration), Issue #1.4 (Registration Form)
Add team name suggestion interface to registration form.
F --> G[3.2 Team Suggestions UI]
H[3.1 OpenAI Integration] --> G
F --> I[4.1 Enhanced UX]
- **Mitigation**: Implement proper connection handling and test early
**Issue #3.1 - OpenAI Integration**: 🟔 **MEDIUM RISK**
- **Risk**: External API dependency and rate limits
- **Impact**: AI features may not work consistently
### External Dependencies
- **OpenAI API Access**: Required for Issue #3.1
- **Admin Key Environment Variable**: Required for admin features
- **Val Town Platform**: All issues depend on platform constraints
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
│ │ │
ā”œā”€ Quiz Form ā”œā”€ Quiz API Routes ā”œā”€ OpenAI API
ā”œā”€ Team Management ā”œā”€ Database Layer ā”œā”€ Val Town Runtime
ā”œā”€ Admin Interface ā”œā”€ Validation └─ SQLite
```
## OpenAI Integration
### API Configuration
```typescript
import { OpenAI } from "https://esm.town/v/std/openai";
export async function generateTeamNameSuggestions(
userContext?: string
): Promise<string[]> {
const openai = new OpenAI();
const prompts = {
try {
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
} catch (error) {
console.error("OpenAI API error:", error);
return getFallbackSuggestions(language);
}
interface QuizEnvironment {
ADMIN_KEY: string; // Admin access key
OPENAI_API_KEY?: string; // OpenAI API key (optional)
QUIZ_ENABLED?: string; // Feature flag
DEBUG_MODE?: string; // Debug logging
const checks = {
database: await checkDatabase(),
openai: await checkOpenAI(),
quiz_system: 'up' as const
};
| Requirement ID | Description | Priority |
|---|---|---|
| QR-007 | AI-powered team name suggestions via OpenAI | Should Have |
| QR-008 | Duplicate team name prevention | Should Have |
| QR-009 | Mobile-responsive design | Must Have |
### External Dependencies
- **OpenAI API**: For team name generation
- **Val Town Platform**: Runtime and hosting constraints
- **SQLite**: Database engine limitations
### High-Risk Items
1. **OpenAI API Dependency**
- Risk: Service unavailability affects team name suggestions
- Mitigation: Graceful fallback, feature remains optional
### External Dependencies
- OpenAI API for team name generation
- Internet connectivity for users (mobile data)
- Modern web browser support (ES6+)
// @ts-nocheck
import { Hono } from "npm:hono@4.4.12";
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { blob } from "https://esm.town/v/std/blob?v=11";
const app = new Hono();
const openai = new OpenAI();
async function getSim(run_id) {
messages.push({ role: "user", content: `Current State: ${JSON.stringify(status)}. Formulate
const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: message
const responseMessage = completion.choices[0].message;
messages.pop();