stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
translateToEnglishWithOpenAImain.tsx4 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function translateToEnglishWithOpenAI(text: string) {
4const openai = new OpenAI();
5const completion = await openai.chat.completions.create({
6messages: [
7{
confidentWhiteOxmain.tsx3 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23const openai = new OpenAI();
45const completion = await openai.chat.completions.create({
6messages: [
7{
Towniesystem_prompt.txt4 matches
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
8990### OpenAI
9192```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96messages: [
97{ role: "user", content: "Say hello in a creative way" },
HHGtoMyDay.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
untitled-2512new-file-9861.tsx11 matches
11* and also to upload new resources.
12* * It utilizes the LLM-Safe Fork of @std/sqlite (adjust import if necessary).
13* Assumes 'openai' secret is set in Val Town environment variables.
14* * Last Updated: 2025-05-08 (SQLite refactor, Glassmorphic UI, and Upload Form)
15*/
625export default async function(req: Request) {
626// --- Dynamic Imports (Inside Handler for Val Town) ---
627const { OpenAI } = await import("https://esm.town/v/std/openai");
628const val_fetch = (await import("https://esm.town/v/std/fetch")).fetch;
629const { PDFExtract } = await import("npm:pdf.js-extract");
653}
654655// --- Helper Function: Call OpenAI API ---
656async function callOpenAI(
657openai: OpenAI,
658systemPrompt: string,
659userMessage: string,
662): Promise<{ role: "assistant" | "system"; content: string | object }> {
663try {
664const response = await openai.chat.completions.create({
665model,
666messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
680return { role: "assistant", content };
681} catch (error) {
682console.error(`OpenAI call failed (ExpectJSON: ${expectJson}):`, error);
683let msg = "Error communicating with AI.";
684if (error.message) msg += ` Details: ${error.message}`;
685if ((error as any).status === 401) msg = "OpenAI Auth Error. Check your 'openai' secret in Val Town.";
686if ((error as any).status === 429) msg = "OpenAI Rate Limit Exceeded.";
687return { role: "system", content: msg };
688}
694log: LogEntry[],
695): Promise<{ finalLog: LogEntry[]; extractedTagsCount: number; documentIdentifier: string | null }> {
696const openai = new OpenAI();
697log.push({ agent: "System", type: "step", message: "Workflow started." });
698805log.push({ agent: "System", type: "step", message: "Extracting searchable tags with LLM..." });
806const tagAgent = "Autism Tag Extraction Agent";
807const llmResponse = await callOpenAI(openai, autismTagExtractionSystemPrompt, textToAnalyze, "gpt-4o", true);
808809let extractedTags: string[] = [];
1import { email } from "https://esm.town/v/std/email";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { JSDOM } from "npm:jsdom";
4import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from "npm:node-html-markdown";
16);
1718const openai = new OpenAI();
19console.log(trendingMarkdown);
2021const completion = await openai.chat.completions.create({
22messages: [
23{
untitled-4923main.tsx12 matches
10* * A GET request to this Val will display a UI to view and search stored tags.
11* * It utilizes the LLM-Safe Fork of @std/sqlite (adjust import if necessary).
12* Assumes 'openai' secret is set in Val Town environment variables.
13* * Last Updated: 2025-05-08 (SQLite refactor and Glassmorphic UI)
14*/
472export default async function(req: Request) {
473// --- Dynamic Imports (Inside Handler for Val Town) ---
474const { OpenAI } = await import("https://esm.town/v/std/openai");
475const val_fetch = (await import("https://esm.town/v/std/fetch")).fetch;
476const { PDFExtract } = await import("npm:pdf.js-extract");
500}
501502// --- Helper Function: Call OpenAI API (Unchanged from previous) ---
503async function callOpenAI(
504openai: OpenAI,
505systemPrompt: string,
506userMessage: string,
509): Promise<{ role: "assistant" | "system"; content: string | object }> {
510try {
511const response = await openai.chat.completions.create({
512model,
513messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
527return { role: "assistant", content };
528} catch (error) {
529console.error(`OpenAI call failed (ExpectJSON: ${expectJson}):`, error);
530let msg = "Error communicating with AI.";
531if (error.message) msg += ` Details: ${error.message}`;
532if ((error as any).status === 401) msg = "OpenAI Auth Error. Check your 'openai' secret in Val Town.";
533if ((error as any).status === 429) msg = "OpenAI Rate Limit Exceeded.";
534// Consider more specific error handling or re-throwing
535return { role: "system", content: msg }; // Or return an actual Error object / throw
542log: LogEntry[],
543): Promise<{ finalLog: LogEntry[]; extractedTagsCount: number; documentIdentifier: string | null }> {
544const openai = new OpenAI(); // Ensure your OpenAI secret is set in Val Town
545log.push({ agent: "System", type: "step", message: "Workflow started." });
546629log.push({ agent: "System", type: "step", message: "Extracting searchable tags with LLM..." });
630const tagAgent = "Autism Tag Extraction Agent";
631const llmResponse = await callOpenAI(openai, autismTagExtractionSystemPrompt, textToAnalyze, "gpt-4o", true);
632633let extractedTags: string[] = [];
654type: "error",
655message: `LLM call failed or returned unexpected format.`,
656details: llmResponse.content, // content here will be the error message from callOpenAI
657});
658}
stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },