Search

4,101 results found for openai (1280ms)

Code
3,995

#### [NEW] [ai.ts](file:///Users/clock2/Developer/vt/yt_drop_v2/backend/ai.ts)
OpenAI-powered tag generation:
- `generateTags()` - Analyzes video title/description to suggest category,
subcategory, and tags
- Uses Val Town's OpenAI integration
- Structured JSON response parsing
YouTube Data API v3 integration with oEmbed fallback
- **[ai.ts](file:///Users/clock2/Developer/vt/yt_drop_v2/backend/ai.ts)** -
OpenAI-powered tag generation
### Main Application
### ✅ AI-Powered Features
- OpenAI GPT-4o-mini integration
- Automatic category, subcategory, and tag generation
- Manual tag regeneration via edit modal
- LastLogin automatically handles OAuth - no manual configuration needed
- YouTube API has daily quota limits (check Google Cloud Console)
- OpenAI calls use Val Town's standard OpenAI integration
- All data is stored in Val Town's SQLite database (persistent)
// AI-powered tag generation using OpenAI
import { OpenAI } from "https://esm.town/v/std/openai";
import type { AITagsResponse } from "../shared/types.ts";
import { DEFAULT_CATEGORIES } from "../shared/constants.ts";
const openai = new OpenAI();
/**
}`;
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
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" },
import { readFile } from "https://esm.town/v/std/utils/index.ts";
import { Agent, run, webSearchTool } from "npm:@openai/agents@0.3.0";
import { storeLead } from "./db.ts";
const d = inputData.data || inputData;
if (!Deno.env.get("OPENAI_API_KEY")) {
const outputData = {
...Object.fromEntries(PASSTHROUGH_KEYS.map(k => [k, d[k] ?? ""])),
match: null,
reasoning: "Set OPENAI_API_KEY environment variable to enable AI research",
};
await storeLead(inputData, outputData);
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" },
["aiforswes", ["AI"], "https://www.aiforswes.com/feed"],
["tesslBlog", ["AI"], "https://rss-generator.artivilla.com/rss/tessl.xml"],
["openaiNews", ["AI"], "https://openai.com/news/rss.xml"],
[
"anthropicNews",
migitech/rep/main.ts
13 matches
};
// ---------- OpenAI mutation with evolutionary context ----------
async function mutatePayloadViaOpenAI(args: {
openaiKey: string;
model: string;
agentId: string;
}): Promise<{ payloadSource: string }> {
const {
openaiKey,
model,
agentId,
const resp = await fetchWithRetry(
"https://api.openai.com/v1/chat/completions",
{
method: "POST",
headers: {
Authorization: `Bearer ${openaiKey}`,
"Content-Type": "application/json",
},
if (!resp.ok) {
const text = await resp.text().catch(() => "");
throw new Error(`OpenAI error: ${resp.status} ${text.slice(0, 300)}`);
}
const parsed = safeJsonParse(content ?? "{}");
if (!parsed?.payloadSource) {
throw new Error("OpenAI JSON missing payloadSource.");
}
const {
VALTOWN_API_KEY,
OPENAI_API_KEY,
REP_VALID,
REP_MODEL = "gpt-4-turbo-preview",
const url = new URL(req.url);
if (!VALTOWN_API_KEY || !OPENAI_API_KEY || !REP_VALID) {
return Response.json(
{
error:
"Missing env: VALTOWN_API_KEY, OPENAI_API_KEY, REP_VALID are required.",
},
{ status: 500 },
}
const { payloadSource } = await mutatePayloadViaOpenAI({
openaiKey: OPENAI_API_KEY,
model: REP_MODEL,
agentId: AGENT_ID,