Search
Code3,282
- **SQLite Database**: Execute queries and manage database operations- **Email**: Send emails through Val Town's email service- **OpenAI Integration**: Access OpenAI API through Val Town's service- **File Operations**: Read and list project files- **Environment Variables**: Access environment configuration
- `email_send` - Send emails4. **OpenAI** - `openai_chat` - Generate text with OpenAI5. **File Operations**
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";import { email } from "https://esm.town/v/std/email";import { OpenAI } from "https://esm.town/v/std/openai";import { readFile, listFiles } from "https://esm.town/v/std/utils@85-main/index.ts";import { MCPTool, MCPToolResult } from "./types.ts"; }, { name: "openai_chat", description: "Generate text using OpenAI's chat completion API", inputSchema: { type: "object", } }, model: { type: "string", default: "gpt-4o-mini", description: "OpenAI model to use" }, max_tokens: { type: "number", description: "Maximum tokens to generate" }, temperature: { type: "number", description: "Sampling temperature" } case "email_send": return await handleEmailSend(args); case "openai_chat": return await handleOpenAIChat(args); case "file_read": return await handleFileRead(args);}async function handleOpenAIChat(args: any): Promise<MCPToolResult> { validateRequired(args, ["messages"]); const openai = new OpenAI(); const options: any = { messages: args.messages, if (args.temperature !== undefined) options.temperature = args.temperature; const completion = await openai.chat.completions.create(options); return {
## Technology Stack- **Backend**: Hono + SQLite + OpenAI- **Frontend**: React + TypeScript + TailwindCSS- **Offline**: Service Workers + Cache API
1. When a new message is posted in a configured Slack channel (ie. #bugs, or #support), Slack sends an event to this Val2. The val makes an OpenAI call to determine if the message is a bug 3. If it is, then it searches GitHub for semantically related open issues with a separate OpenAI call4. It posts a comment in the Slack thread with links to related GitHub issues, with a "Relevance Score"
*/import { OpenAI } from "https://esm.town/v/std/openai";import { Octokit } from "https://esm.sh/@octokit/rest@20.0.2";import { WebClient } from "https://esm.sh/@slack/web-api@7.0.2";async function isBugReportLLM(text: string): Promise<boolean> { try { // Check if OpenAI API key is available if (!Deno.env.get("OPENAI_API_KEY")) { console.warn("OpenAI API key not found - bug detection disabled"); return false; } const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ {async function findRelatedIssues(slackMessage: string, issues: any[]): Promise<any[]> { try { // Check if OpenAI API key is available if (!Deno.env.get("OPENAI_API_KEY")) { return []; } }).join("\n\n"); const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ {
# OpenAI ProxyThis OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openaiMigrated from folder: openai/openaiproxy
import { parseBearerString } from "https://esm.town/v/andreterron/parseBearerString";import { API_URL } from "https://esm.town/v/std/API_URL?v=5";import { OpenAIUsage } from "https://esm.town/v/std/OpenAIUsage";import { RateLimit } from "npm:@rlimit/http";const client = new OpenAIUsage();const allowedPathnames = [ // Proxy the request const url = new URL("." + pathname, "https://api.openai.com"); url.search = search; const headers = new Headers(req.headers); headers.set("Host", url.hostname); headers.set("Authorization", `Bearer ${Deno.env.get("OPENAI_API_KEY")}`); headers.set("OpenAI-Organization", Deno.env.get("OPENAI_API_ORG")); const modifiedBody = await limitFreeModel(req, user); }); const openAIRes = await fetch(url, { method: req.method, headers, // Remove internal header const res = new Response(openAIRes.body, openAIRes); res.headers.delete("openai-organization"); return res;}
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" },
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