Search

107 results found for openai (320ms)

Code
105

#### `POST /generate-ai-name`
Test AI thread naming (requires OPENAI_API_KEY).
```json
{
| `AUTOTHREAD_ENABLE_AI` | No | Enable AI naming in cron |
| `AUTOTHREAD_CHANNEL_ALLOWLIST` | No | Comma-separated channel IDs |
| `OPENAI_API_KEY` | For AI | OpenAI API key (Val Town std lib) |
### Objectives
Use OpenAI to generate contextual thread names and summaries from recent messages.
### Scope
- Gather message context (5 before, 2 after target message)
- Call OpenAI for thread name + summary
- Post summary as first message in created thread
- Graceful fallback to deterministic naming on AI failure
### Dependencies
- Gate 2 complete
- `OPENAI_API_KEY` environment variable
### Task List
| Implement context gathering | Collect last ~4 messages before target (or up to 5 min of histor
| Create AI prompt for thread naming | Returns `thread_name` (≤100 chars) and `summary` (2-5 bul
| Call OpenAI API | Use `gpt-4o-mini`, limit tokens appropriately |
| Create thread with AI name | Use AI-generated name, fallback to deterministic on failure |
| Post summary in thread | Send AI summary as first message in new thread |
| `AUTOTHREAD_CHANNEL_ALLOWLIST` | 1 | No | Comma-separated channel IDs |
| `AUTOTHREAD_ENABLE_AI` | 3 | No | Enable AI naming when `true` |
| `OPENAI_API_KEY` | 3 | For AI | OpenAI API key (Val Town std lib) |
---
- `DISCORD_BOT_TOKEN` - Discord bot authentication
- `DISCORD_GUILD_ID` - Guild to monitor
- `OPENAI_API_KEY` - For AI naming (optional)
### Bug Fix Applied
```
### 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: "Hello" }],
model: "gpt-4o-mini",
createThread.ts (script - utility)
├─ Calls OpenAI/Claude for thread title
└─ Creates thread via Discord API
"Bash(find:*)",
"Bash(deno check:*)",
"WebFetch(domain:platform.openai.com)",
"WebSearch"
],
},
{
name: "OPENAI_PROTOCOL",
tag: "COMPAT",
configs: [{
ep: "https://text.pollinations.ai/openai",
m: "POST",
v: "OAI_OBJ",
tag: "META",
configs: [{
ep: "https://text.pollinations.ai/openai",
m: "GET",
v: "NONE",
tag: "LEGACY",
configs: [{
ep: "https://text.pollinations.ai/openai",
m: "POST",
v: "RAW_TEXT",
desc: "Returns full JSON with internal reasoning content.",
configs: [
{ ep: "https://text.pollinations.ai/openai", m: "POST", v: "OAI_OBJ" },
{ ep: "https://text.pollinations.ai/openai", m: "POST", v: "OAI_NO_MODEL" }
]
},
desc: "Returns service info/docs regardless of prompt.",
configs: [
{ ep: "https://text.pollinations.ai/openai", m: "GET", v: "NONE" },
{ ep: "https://text.pollinations.ai/prompt", m: "GET", v: "NONE" }
]
desc: "Returns clarification requests or generic greetings.",
configs: [
{ ep: "https://text.pollinations.ai/openai", m: "POST", v: "RAW_TEXT" },
{ ep: "https://text.pollinations.ai/openai", m: "POST", v: "FORM_DATA" }
]
}
const Payloads = {
stringify({messages: [{role:"user", content: p}], model: "openai"}),
OAI_NO_MODEL: (p) => JSON.stringify({messages: [{role:"user", content: p}]}),
RAW_TEXT: (p) => p,
try {
const res = await fetch("https://text.pollinations.ai/openai", {
method: 'POST',
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: "model=openai&prompt=" + encodeURIComponent(p)
});
try {
const res = await fetch("https://text.pollinations.ai/openai", {
method: 'POST',
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: "model=openai&prompt=" + encodeURIComponent(p)
});
const NODES = [
{ name: "TIER_1_RAW", url: "https://text.pollinations.ai/", headers: {"Content-Type"
e: "TIER_2_REASONING", url: "https://text.pollinations.ai/openai", headers: {"Content-Type": "ap
"TIER_3_SIMPLE_JSON", url: "https://text.pollinations.ai/openai", headers: {"Content-Type": "ap
TIER_4_PARAM_WRAPPED", url: "https://text.pollinations.ai/openai", headers: {"Content-Type": "ap
"TIER_5_URL_ENCODED", url: "https://text.pollinations.ai/openai", headers: {"Content-Type": "ap
"TIER_6_INPUT_SCHEMA", url: "https://text.pollinations.ai/openai", headers: {"Content-Type": "ap
];
openai-agents
kidjs
openai-agents
Template to use the OpenAI Agents SDK
Public
openai-agents
EatPraySin
openai-agents
Template to use the OpenAI Agents SDK
Public

Users

No users found

Docs

No docs found
8
Next