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" },
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import * as ta from "npm:technicalindicators";
237}
238239// --- OpenAI Call Function ---
240async function callOpenAI(
241systemPrompt: string,
242userMessage: string,
248): Promise<{ role: "assistant" | "system"; content: string }> {
249const callId = Math.random().toString(36).substring(2, 8);
250const logPfx = `OpenAI Call [${agentName} ${taskId.split("-")[1] || taskId} ${callId}]`;
251try {
252log("DEBUG", agentName, `${logPfx}: Initiating (${model}, JSON: ${isJsonOutputRequired})...`);
253const openai = new OpenAI();
254const res = await openai.chat.completions.create({
255model,
256messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
260const content = res.choices?.[0]?.message?.content;
261if (!content) {
262log("ERROR", agentName, `${logPfx}: OpenAI returned empty/invalid response.`);
263throw new Error("Invalid/empty AI response.");
264}
270let code = err.status || (err.response ? err.response.status : null);
271const errData = err.response?.data || err.error || err.response || err;
272if (errData?.message) { errMsg = `OpenAI Err (${code || "?"}) via ${agentName}: ${errData.message}`; }
273else if (errData?.error?.message) {
274errMsg = `OpenAI Err (${code || "?"}) via ${agentName}: ${errData.error.message}`;
275}
276else if (err.message) { errMsg += ` Details: ${err.message}`; }
285" (ACTION: Bad request/prompt issue)"; else if (
286err.code === "ENOTFOUND" || err.code === "ECONNREFUSED" || err.cause?.code === "UND_ERR_CONNECT_TIMEOUT"
287) errMsg += " (ACTION: Network error)"; else if (code >= 500) errMsg += " (ACTION: OpenAI server issue)";
288const escapedErr = errMsg.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n");
289if (isJsonOutputRequired) {
595const taskId = task.taskId;
596log("INFO", agentName, `Task ${taskId}. Goals hash: ${hashCode(JSON.stringify(task.payload))}`);
597const result = await callOpenAI(
598tickerSuggestionAgentSystemPrompt,
599JSON.stringify(task.payload),
938context: { newsSentiment: context?.newsSentiment?.[ticker] ?? "N/A" },
939});
940const result = await callOpenAI(
941tickerInterpretationAgentSystemPrompt,
942input,
1054pastPerformanceContext: pastPerformanceContext ?? "N/A",
1055});
1056const result = await callOpenAI(
1057synthesisChartingDataAgentSystemPrompt,
1058input,
vt-blog-1get-old-posts.ts5 matches
198},
199{
200"title": "An Introduction to OpenAI fine-tuning",
201"slug": "an-introduction-to-openai-fine-tuning",
202"link": "/blog/an-introduction-to-openai-fine-tuning",
203"description": "How to customize OpenAI to your liking",
204"pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205"author": "Steve Krouse",
417"slug": "val-town-newsletter-16",
418"link": "/blog/val-town-newsletter-16",
419"description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420"pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421"author": "Steve Krouse",
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" },
vt-blogget-old-posts.ts5 matches
198},
199{
200"title": "An Introduction to OpenAI fine-tuning",
201"slug": "an-introduction-to-openai-fine-tuning",
202"link": "/blog/an-introduction-to-openai-fine-tuning",
203"description": "How to customize OpenAI to your liking",
204"pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205"author": "Steve Krouse",
417"slug": "val-town-newsletter-16",
418"link": "/blog/val-town-newsletter-16",
419"description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420"pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421"author": "Steve Krouse",
MyStevens.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" },
survivor-trackerREADME.md1 match
25- Frontend: **React** with **TailwindCSS**
26- Backend: **Hono** framework with SQLite storage
27- AI Guidance: Simulated AI responses (can be replaced with actual OpenAI integration)
2829## Getting Started
survivor-trackerprocessor.ts12 matches
6import { PersonalStatus, DailyLog, Task, TrackStatus } from "../database/queries.ts";
78// Interface for OpenAI response
9interface OpenAICompletion {
10choices: {
11message: {
1617// Mock AI function for generating responses
18// In production, replace with actual OpenAI integration
19export const generateAIResponse = async (prompt: string): Promise<string> => {
20// Simulate AI response generation
58};
5960// This would be replaced with a real OpenAI call in production
61const callOpenAI = async (prompt: string): Promise<string> => {
62// Simulate network delay
63await new Promise(resolve => setTimeout(resolve, 500));
67/*
68// Real implementation would look like this:
69import { OpenAI } from "npm:openai";
70
71const openai = new OpenAI();
72const completion = await openai.chat.completions.create({
73messages: [
74{ role: "system", content: "You are an expert business coach helping an independent consultant execute their 21-day survival plan." },
104
105// Call AI to generate response
106return await callOpenAI(filledPrompt);
107};
108130
131// Call AI to generate response
132return await callOpenAI(filledPrompt);
133};
134170
171// Call AI to generate response
172const aiResponse = await callOpenAI(filledPrompt);
173
174// Parse the response to extract metrics, gaps, and adjustments
198
199// Call AI to generate response
200return await callOpenAI(filledPrompt);
201};
202