5import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
6import { Octokit } from "npm:octokit";
7import { OpenAI } from "https://esm.town/v/std/openai";
89// Environment variables, set them in the left sidebar
25*/
26async function generateUserFocusedSummary(fullCommitMessage: string, commitType: string): Promise<string> {
27const openai = new OpenAI();
28
29const prompt = `You are writing release notes for a developer tool. Based on this commit message, write a concise one-liner.
5152try {
53const completion = await openai.chat.completions.create({
54messages: [{ role: "user", content: prompt }],
55model: "gpt-4o-mini",
Townie-09system_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" },
Townie-09.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
autonomous-valREADME.md1 match
9Configure the following variables in your environment:
10- `AGENT_API_KEY` (This is a secure token that you choose to secure the agent.tsx POST endpoint)
11- `OPENAI_API_KEY` (An OpenAI API Key)
12- `EXA_API_KEY` (Optional, though needed if you use the web search tool)
13
autonomous-valagent.tsx2 matches
1import { anthropic } from "npm:@ai-sdk/anthropic";
2import { openai } from "npm:@ai-sdk/openai";
3import { generateText, streamText } from "npm:ai";
4import { getSystemPrompt } from "./prompt.tsx";
34const maxSteps = 10;
3536const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
3738const options = {
markdown-embed.cursorrules4 matches
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9596### OpenAI
9798```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102messages: [
103{ role: "user", content: "Say hello in a creative way" },
openai-clientmain.tsx9 matches
1import { OpenAI } from "https://esm.sh/openai@4.85.1";
2import { sqlite } from "https://esm.town/v/std/sqlite";
37};
89interface ChatOpenAI {
10invoke(messages: Message[]): Promise<string>;
11}
1213export function ChatOpenAI(model: string): ChatOpenAI {
14const openai = new OpenAI();
1516return {
17invoke: async (messages: Message[]): Promise<string> => {
18const completion = await openai.chat.completions.create({
19messages: messages.map(message => ({
20role: message.role as "user" | "assistant" | "system",
29}
3031// Decorator for ChatOpenAI that will eventually add rate limiting
32export function GlobalRateLimitedChatOpenAI(model: string, requestsPerSecond: number): ChatOpenAI {
33const openAi = ChatOpenAI(model);
3435const rateLimiter = new GlobalRateLimiter(requestsPerSecond);
39await rateLimiter.check();
4041return openAi.invoke(messages);
42},
43};
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" },
thirdTimerval-town.mdc4 matches
93Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
9495### OpenAI
9697```ts
98import { OpenAI } from "https://esm.town/v/std/openai";
99const openai = new OpenAI();
100const completion = await openai.chat.completions.create({
101messages: [
102{ role: "user", content: "Say hello in a creative way" },
953// --- Main Request Handler (Server Code - MODIFIED) ---
954export default async function(req: Request) {
955const { OpenAI } = await import("https://esm.town/v/std/openai");
956const { fetch } = await import("https://esm.town/v/std/fetch");
957// PDFExtract is kept if you want to add document features later, but not primary for this use case.
965const action = url.searchParams.get("action"); // New: "loanAssumptionInfo"
966const sourceUrl = import.meta.url.replace("esm.town", "val.town");
967const openai = new OpenAI();
968const MAX_TEXT_LENGTH_ANALYSIS = 10000; // Reduced as input is smaller now
969992}
993994// callOpenAI function (same as original, but uses gpt-4o by default)
995async function callOpenAI(
996openaiInstance: OpenAI,
997systemPrompt: string,
998userMessage: string, // For this app, userMessage to AI might be empty if all info is in systemPrompt
1003): Promise<object | string> {
1004// ... (implementation from original)
1005log.push({ agent: agentName, type: "step", message: `Calling OpenAI model ${model}...` });
1006try {
1007const response = await openaiInstance.chat.completions.create({
1008model: model,
1009messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
1124.replace("%%USER_NAME%%", analysisInput.userName);
1125// The %%INPUT_SOURCE_DESCRIPTION%% and %%LEGAL_TASK_QUERY%% are not in the new prompt in this direct way.
1126// The userMessage to openAI can be kept minimal or empty as the system prompt is rich.
1127const userMessageForAI = ""; // Or analysisInput.documentText if you want to provide more context there.
11281129const analysisAgentName = "HomeAdvantage AI";
1130const aiResponse = await callOpenAI(
1131openai,
1132finalSystemPrompt,
1133userMessageForAI,