Search

3,380 results found for openai (7392ms)

Code
3,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): Promis
const openai = new OpenAI();
const prompt = `You are writing release notes for a developer tool. Based on this commit messa
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 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" },
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;
ROPIC_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 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" },
// --- 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
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 sys
): 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: userMessa
.replace("%%USER_NAME%%", analysisInput.userName);
// The %%INPUT_SOURCE_DESCRIPTION%% and %%LEGAL_TASK_QUERY%% are not in the new prompt in
// 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
const analysisAgentName = "HomeAdvantage AI";
const aiResponse = await callOpenAI(
openai,
finalSystemPrompt,
userMessageForAI,
legal/docs/main.tsx
10 matches
}
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: userMessa
);
const suggestionAgentName = "Task Suggestion AI";
const suggestionsResponse = await callOpenAI(
openai,
suggestionPrompt,
"",
);
const analysisAgentName = "Legal Analysis AI";
const aiResponse = await callOpenAI(
openai,
finalSystemPrompt,
documentTextToAnalyze,