94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
4
271}
272
273// --- OpenAI Call Wrapper (MODIFIED to enable JSON mode) ---
274async function callOpenAI(
275 sysP: string,
276 userP: string,
281 log("DB", "oai", `Call tid=${tid}`, { spL: sysP.length, upL: userP.length }, mid, tid);
282 try {
283 const oai = new OpenAI();
284 const comp = await oai.chat.completions.create({
285 model: "gpt-4o-mini",
864 try {
865 const { sys, user } = cfg.p(p);
866 const rawC = await callOpenAI(sys, user, mid, tid, log);
867 if (!rawC) {
868 log("WN", cfg.n, `No LLM content tid=${tid}.`, {}, mid, tid);
198 },
199 {
200 "title": "An Introduction to OpenAI fine-tuning",
201 "slug": "an-introduction-to-openai-fine-tuning",
202 "link": "/blog/an-introduction-to-openai-fine-tuning",
203 "description": "How to customize OpenAI to your liking",
204 "pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205 "author": "Steve Krouse",
417 "slug": "val-town-newsletter-16",
418 "link": "/blog/val-town-newsletter-16",
419 "description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420 "pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421 "author": "Steve Krouse",
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { getAllTools, getToolsByCategory, getToolById, searchTools } from "../database/queries";
4import { AITool, SearchRequest, ToolCategory } from "../../shared/types";
5
6const api = new Hono();
7const openai = new OpenAI();
8
9// Get all tools
65 const allTools = await getAllTools();
66
67 // Use OpenAI to analyze the query and recommend tools
68 const aiResponse = await openai.chat.completions.create({
69 model: "gpt-4o-mini",
70 messages: [
46- Frontend: React with Tailwind CSS
47- Backend: Hono API framework
48- AI: OpenAI for query understanding and tool recommendations
49- Database: SQLite for tool information storage
2import React, { useState, useEffect, useCallback } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import { OpenAI } from "https://esm.town/v/std/openai";
5
6// Enhanced subjects with more detailed metadata
394
395export default async function server(request: Request): Promise<Response> {
396 const { OpenAI } = await import("https://esm.town/v/std/openai");
397 const openai = new OpenAI();
398
399 if (request.method === 'POST') {
402 if (request.url.includes('/generate-question')) {
403 try {
404 const completion = await openai.chat.completions.create({
405 messages: [
406 {
3 const incomingMsg = formData.get("Body")?.toString();
4
5 // Send the SMS text to OpenAI
6 const response = await fetch("https://api.openai.com/v1/chat/completions", {
7 method: "POST",
8 headers: {
9 Authorization: `Bearer ${Deno.env.get("OPENAI_API_KEY")}`,
10 "Content-Type": "application/json",
11 },
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" },
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
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" },