Search
Code3,285
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";import { Octokit } from "npm:octokit";import { OpenAI } from "https://esm.town/v/std/openai";// Environment variables, set them in the left sidebar */async function generateUserFocusedSummary(fullCommitMessage: string, commitType: string): Promise<string> { const openai = new OpenAI(); const prompt = `You are writing release notes for a developer tool. Based on this commit message, write a concise one-liner. try { const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini",
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { 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 create a fresh table.### OpenAI```tsimport { 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" },
Configure the following variables in your environment: - `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)- `OPENAI_API_KEY` (An OpenAI API Key)- `EXA_API_KEY` (Optional, though needed if you use the web search tool)
import { anthropic } from "npm:@ai-sdk/anthropic";import { openai } from "npm:@ai-sdk/openai";import { generateText, streamText } from "npm:ai";import { getSystemPrompt } from "./prompt.tsx"; const maxSteps = 10; const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1"); const options = {
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { 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 create a fresh table.### OpenAI```tsimport { 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 create a fresh table.### OpenAI```tsimport { 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" },
// --- Main Request Handler (Server Code - MODIFIED) ---export default async function(req: Request) { const { OpenAI } = await import("https://esm.town/v/std/openai"); const { fetch } = await import("https://esm.town/v/std/fetch"); // PDFExtract is kept if you want to add document features later, but not primary for this use case. const action = url.searchParams.get("action"); // New: "loanAssumptionInfo" const sourceUrl = import.meta.url.replace("esm.town", "val.town"); const openai = new OpenAI(); const MAX_TEXT_LENGTH_ANALYSIS = 10000; // Reduced as input is smaller now } // callOpenAI function (same as original, but uses gpt-4o by default) async function callOpenAI( openaiInstance: OpenAI, systemPrompt: string, userMessage: string, // For this app, userMessage to AI might be empty if all info is in systemPrompt ): Promise<object | string> { // ... (implementation from original) log.push({ agent: agentName, type: "step", message: `Calling OpenAI model ${model}...` }); try { const response = await openaiInstance.chat.completions.create({ model: model, messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }], .replace("%%USER_NAME%%", analysisInput.userName); // The %%INPUT_SOURCE_DESCRIPTION%% and %%LEGAL_TASK_QUERY%% are not in the new prompt in this direct way. // The userMessage to openAI can be kept minimal or empty as the system prompt is rich. const userMessageForAI = ""; // Or analysisInput.documentText if you want to provide more context there. const analysisAgentName = "HomeAdvantage AI"; const aiResponse = await callOpenAI( openai, finalSystemPrompt, userMessageForAI,
}export default async function(req: Request) { const { OpenAI } = await import("https://esm.town/v/std/openai"); const { fetch } = await import("https://esm.town/v/std/fetch"); const { PDFExtract, PDFExtractOptions } = await import("npm:pdf.js-extract"); const action = url.searchParams.get("action"); const sourceUrl = import.meta.url.replace("esm.town", "val.town"); const openai = new OpenAI(); const MAX_TEXT_LENGTH_SUGGESTION = 20000; const MAX_TEXT_LENGTH_ANALYSIS = 30000; } } async function callOpenAI( openaiInstance: OpenAI, systemPrompt: string, userMessage: string, agentName: string, ): Promise<object | string> { log.push({ agent: agentName, type: "step", message: `Calling OpenAI model ${model}...` }); try { const response = await openaiInstance.chat.completions.create({ model: model, messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }], ); const suggestionAgentName = "Task Suggestion AI"; const suggestionsResponse = await callOpenAI( openai, suggestionPrompt, "", ); const analysisAgentName = "Legal Analysis AI"; const aiResponse = await callOpenAI( openai, finalSystemPrompt, documentTextToAnalyze,
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
lost1991
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
No docs found