63Backend & Flask (Python) \\
64Database & MongoDB / Firebase \\
65NLP API & OpenAI GPT \\
66Styling & TailwindCSS / Bootstrap \\
67\hline
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
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";
34 const maxSteps = 10;
35
36 const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
37
38 const options = {
839
840export default async function(req: Request) {
841 const { OpenAI } = await import("https://esm.town/v/std/openai");
842 const { PDFExtract } = await import("npm:pdf.js-extract");
843
853 const action = url.searchParams.get("action");
854 const sourceUrl = import.meta.url.replace("esm.town", "val.town");
855 const openai = new OpenAI();
856 const MAX_TEXT_SUGGEST = 20000;
857 const MAX_TEXT_ANALYZE = 30000;
882 agentName: string,
883 ): Promise<object> {
884 log.push({ agent: agentName, type: "step", message: `Calling OpenAI gpt-4o...` });
885 try {
886 const response = await openai.chat.completions.create({
887 model: "gpt-4o",
888 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
6 */
7
8import { OpenAI } from "https://esm.town/v/std/openai";
9import { Octokit } from "https://esm.sh/@octokit/rest@20.0.2";
10import { WebClient } from "https://esm.sh/@slack/web-api@7.0.2";
129async function isBugReportLLM(text: string): Promise<boolean> {
130 try {
131 // Check if OpenAI API key is available
132 if (!Deno.env.get("OPENAI_API_KEY")) {
133 console.warn("OpenAI API key not found - bug detection disabled");
134 return false;
135 }
136
137 const openai = new OpenAI();
138 const completion = await openai.chat.completions.create({
139 messages: [
140 {
249async function findRelatedIssues(slackMessage: string, issues: any[]): Promise<any[]> {
250 try {
251 // Check if OpenAI API key is available
252 if (!Deno.env.get("OPENAI_API_KEY")) {
253 return [];
254 }
271 }).join("\n\n");
272
273 const openai = new OpenAI();
274 const completion = await openai.chat.completions.create({
275 messages: [
276 {
119
1201. When a new message is posted in a configured Slack channel (ie. #bugs, or #support), Slack sends an event to this Val
1212. The val makes an OpenAI call to determine if the message is a bug
1223. If it is, then it searches GitHub for semantically related open issues with a separate OpenAI call
1234. It posts a comment in the Slack thread with links to related GitHub issues, with a "Relevance Score"
124
6 */
7
8import { OpenAI } from "https://esm.town/v/std/openai";
9import { Octokit } from "https://esm.sh/@octokit/rest@20.0.2";
10import { WebClient } from "https://esm.sh/@slack/web-api@7.0.2";
129async function isBugReportLLM(text: string): Promise<boolean> {
130 try {
131 // Check if OpenAI API key is available
132 if (!Deno.env.get("OPENAI_API_KEY")) {
133 console.warn("OpenAI API key not found - bug detection disabled");
134 return false;
135 }
136
137 const openai = new OpenAI();
138 const completion = await openai.chat.completions.create({
139 messages: [
140 {
249async function findRelatedIssues(slackMessage: string, issues: any[]): Promise<any[]> {
250 try {
251 // Check if OpenAI API key is available
252 if (!Deno.env.get("OPENAI_API_KEY")) {
253 return [];
254 }
271 }).join("\n\n");
272
273 const openai = new OpenAI();
274 const completion = await openai.chat.completions.create({
275 messages: [
276 {
119
1201. When a new message is posted in a configured Slack channel (ie. #bugs, or #support), Slack sends an event to this Val
1212. The val makes an OpenAI call to determine if the message is a bug
1223. If it is, then it searches GitHub for semantically related open issues with a separate OpenAI call
1234. It posts a comment in the Slack thread with links to related GitHub issues, with a "Relevance Score"
124
856
857export default async function(req: Request) {
858 const { OpenAI } = await import("https://esm.town/v/std/openai");
859 const { PDFExtract } = await import("npm:pdf.js-extract");
860
870 const action = url.searchParams.get("action");
871 const sourceUrl = import.meta.url.replace("esm.town", "val.town");
872 const openai = new OpenAI();
873 const MAX_TEXT_SUGGEST = 20000;
874 const MAX_TEXT_ANALYZE = 30000;
899 agentName: string,
900 ): Promise<object> {
901 log.push({ agent: agentName, type: "step", message: `Calling OpenAI gpt-4o...` });
902 try {
903 const response = await openai.chat.completions.create({
904 model: "gpt-4o",
905 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },