Search

115 results found for openai (685ms)

Code
113

1. Click [**Remix**](/?intent=remix)
2. Add environment variables:
- `OPENAI_API_KEY` — for AI lead qualification
- `GITHUB_TOKEN` — for accessing GitHub API
([create one here](https://github.com/settings/tokens))
1. Click [**Remix**](/?intent=remix)
2. Add environment variables:
- `OPENAI_API_KEY` — for AI lead qualification
- `GITHUB_TOKEN` — for accessing GitHub API
([create one here](https://github.com/settings/tokens))
app.post("/", async (c) => {
// Early API key check to avoid confusing when using the tester ui
if (!Deno.env.get("OPENAI_API_KEY")) {
return c.json(
{ error: "Add OPENAI_API_KEY in Environment Variables" },
503,
);
// Test endpoint for the welcome UI
app.post("/test", async (c) => {
if (!Deno.env.get("OPENAI_API_KEY")) {
return c.json(
{ error: "Add OPENAI_API_KEY in Environment Variables" },
503,
);
// Reanalyze a lead
app.post("/lead/:id/reanalyze", async (c) => {
if (!Deno.env.get("OPENAI_API_KEY")) {
return c.json(
{ error: "Add OPENAI_API_KEY in Environment Variables" },
503,
);
import { readFile } from "https://esm.town/v/std/utils/index.ts";
import { Agent, run, RunResult, webSearchTool } from "npm:@openai/agents@0.3.0";
import { getLeadById, storeLead, updateLeadOutput } from "./db.ts";
// 3. Protocol Specific Checks - Ensures response conforms to expected format.
if (tag === "COMPAT") {
// Expects OpenAI-style response structure: { choices: [{ message: { content: ... } }] }
const isOAI = !!json?.choices?.[0]?.message?.content;
return isOAI
},
{
name: "OPENAI_PROTOCOL", // A group for standard OpenAI API compatibility.
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",
},
{
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",
}`;
/* "https://text.pollinations.ai/",
"https://text.pollinations.ai/openai",
"https://text.pollinations.ai/openai/v1",
"https://text.pollinations.ai/openai/v2",
"https://gen.pollinations.ai/v1/chat/completions",
"https://gen.pollinations.ai/v1",
"https://gen.pollinations.ai/openai",
"https://gen.pollinations.ai/openai/v1",
"https://gen.pollinations.ai/openai/chat/comoletions",
"",*/
const payloadVariations = [
{ name: "RAW_STRING", body: prompt, headers: {"Content-Type": "text/plain"} },
ngify({messages: [{role:"user", content:prompt}], model: "openai"}), headers: {"Content-Type": "
{ name: "SIMPLE_PROMPT_OBJ", body: JSON.stringify({prompt: prompt}), headers: {"Cont
{ name: "INPUT_OBJ", body: JSON.stringify({inputs: prompt}), headers: {"Content-Type
#### `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",
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