Search

4,007 results found for openai (7339ms)

Code
3,903

<div class="relative">
<select x-model="selectedModel" @change="onModelChange()" class="px-2 py-1 pr-8
<option value="openai/gpt-oss-120b">openai/gpt-oss-120b</option>
<option value="openai/gpt-oss-20b">openai/gpt-oss-20b</option>
<option value="llama-3.1-8b-instant">llama-3.1-8b-instant</option>
<option value="llama-3.3-70b-versatile">llama-3.3-70b-versatile</option>
<span>JSON mode</span>
</label>
xt-xs" x-show="selectedModel && selectedModel.startsWith('openai/gpt-oss')">
<input type="checkbox" x-model="useBrowserSearch" @change="onUseBrowserSearchCha
<span>browser search</span>
</label>
xt-xs" x-show="selectedModel && selectedModel.startsWith('openai/gpt-oss')">
<input type="checkbox" x-model="useCodeInterpreter" @change="onUseCodeInterprete
<span>code interpreter</span>
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" },
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" },
- `main.tsx` - Main cron function and Discord webhook
- `fetch-vals.ts` - Fetches and filters new vals using Val Town SDK
- `ai-summarizer.ts` - Generates OpenAI summaries for vals without READMEs
## Additional logic
- Filter out commonly remixed utility vals like Blob Admin, SQLiteExplorer
- Skip shallow remixes (forks with ≤3 versions)
`main.tsx` files for AI summaries and limit code sent to OpenAI to 5KB to avoid token limits
## Setup
1. Set `DISCORD_WEBHOOK` environment variable
2. Set `OPENAI_API_KEY` environment variable
3. Set `testMode = false` in main.tsx for production
import { OpenAI } from "npm:openai";
import ValTown from "npm:@valtown/sdk";
const openai = new OpenAI();
const client = new ValTown();
}
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{
}
const openaiApiKey = __secrets['OPENAI_API_KEY'];
if (!openaiApiKey) {
return Response.json(
{ error: 'OpenAI API key not configured' },
{ status: 500 }
);
Please respond with only the poem, no explanations or additional text:`;
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${openaiApiKey}`,
'Content-Type': 'application/json',
},
if (!response.ok) {
const errorData = await response.text();
console.error('OpenAI API error:', errorData);
return Response.json(
{ error: 'Failed to generate poem' },
}
const apiKey = __secrets['openai_api_key'];
if (!apiKey) {
return Response.json({ error: 'API key not configured' }, { status: 500 });
}
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
if (!response.ok) {
console.error('OpenAI API error:', await response.text());
return Response.json({ error: 'Failed to generate poem' }, { status: 500 });
}
}
const apiKey = __secrets['openai_api_key'];
if (!apiKey) {
return Response.json(
{ error: "OpenAI API key not configured" },
{ status: 500 }
);
}
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
if (!response.ok) {
const error = await response.text();
console.error('OpenAI API error:', error);
return Response.json(
{ error: "Failed to generate poem. Please try again." },
}
// Get OpenAI API key from environment
const apiKey = __secrets['OPENAI_KEY'];
if (!apiKey) {
console.error('OpenAI API key not configured');
return Response.json(
{ error: 'API key not configured' },
}
// Call OpenAI API
const openaiResponse = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
});
if (!openaiResponse.ok) {
const error = await openaiResponse.text();
console.error('OpenAI API error:', error);
return Response.json(
{ error: 'Failed to generate poem' },
}
const data = await openaiResponse.json();
const poem = data.choices[0]?.message?.content?.trim();