20 console.log("๐ต Sending request to Groq API");
21 const start = Date.now();
22 const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
23 method: "POST",
24 headers: {
63 console.log("๐ค Sending request to Groq Whisper API");
64 const start = Date.now();
65 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
66 method: "POST",
67 headers: {
198
199 app.post("/extract-recipe", async (c) => {
200 const { OpenAI } = await import("https://esm.town/v/std/openai");
201 const openai = new OpenAI();
202
203 const formData = await c.req.formData();
224
225 try {
226 const response = await openai.chat.completions.create({
227 model: "gpt-4o",
228 messages: [
124 if (request.method === 'POST' && new URL(request.url).pathname === '/chat') {
125 try {
126 const { OpenAI } = await import("https://esm.town/v/std/openai");
127 const openai = new OpenAI();
128
129 const body = await request.json();
130 const completion = await openai.chat.completions.create({
131 messages: body.messages.map((msg: Message) => ({
132 role: msg.role,
143 });
144 } catch (error) {
145 console.error('OpenAI Error:', error);
146 return new Response(JSON.stringify({
147 message: 'Sorry, I encountered an error processing your request.'
67 console.log("๐ค Sending request to Groq Whisper API");
68 const start = Date.now();
69 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
70 method: "POST",
71 headers: {
157 console.log("๐ต Sending request to Groq API");
158 const start = Date.now();
159 const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
160 method: "POST",
161 headers: {
213 console.log("๐ Sending request to Groq Speech API");
214 const start = Date.now();
215 const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
216 method: "POST",
217 headers: {
68 console.log("๐ค Sending request to Groq Whisper API");
69 const start = Date.now();
70 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
71 method: "POST",
72 headers: {
158 console.log("๐ต Sending request to Groq API");
159 const start = Date.now();
160 const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
161 method: "POST",
162 headers: {
214 console.log("๐ Sending request to Groq Speech API");
215 const start = Date.now();
216 const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
217 method: "POST",
218 headers: {
68 console.log("๐ค Sending request to Groq Whisper API");
69 const start = Date.now();
70 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
71 method: "POST",
72 headers: {
158 console.log("๐ต Sending request to Groq API");
159 const start = Date.now();
160 const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
161 method: "POST",
162 headers: {
214 console.log("๐ Sending request to Groq Speech API");
215 const start = Date.now();
216 const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
217 method: "POST",
218 headers: {
68 console.log("๐ค Sending request to Groq Whisper API");
69 const start = Date.now();
70 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
71 method: "POST",
72 headers: {
158 console.log("๐ต Sending request to Groq API");
159 const start = Date.now();
160 const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
161 method: "POST",
162 headers: {
214 console.log("๐ Sending request to Groq Speech API");
215 const start = Date.now();
216 const response = await fetch("https://api.groq.com/openai/v1/audio/speech", {
217 method: "POST",
218 headers: {
37
38 // Call Groq API
39 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
40 method: "POST",
41 headers: {
137Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
138
139### OpenAI
140```ts
141import { OpenAI } from "https://esm.town/v/std/openai";
142const openai = new OpenAI();
143const completion = await openai.chat.completions.create({
144 messages: [
145 { role: "user", content: "Say hello in a creative way" },