83 const { messages } = await request.json();
84
85 const { OpenAI } = await import("https://esm.sh/openai");
86 // Cerebras Inference
87 // Very important: do not change this
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91 baseURL: "https://api.cerebras.ai/v1",
210 const stackOverflowResults = await searchStackOverflow(lastUserMessage);
211
212 const { OpenAI } = await import("https://esm.sh/openai");
213 const client = new OpenAI({
214 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
215 baseURL: "https://api.cerebras.ai/v1",
35Use Cerebras for AI on the backend like so:
36
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
230 const { prompt, mode } = await c.req.json();
231
232 const { OpenAI } = await import("https://esm.town/v/std/openai");
233 const openai = new OpenAI();
234
235 if (mode === "image") {
236 const response = await openai.images.generate({
237 model: "dall-e-3",
238 prompt: prompt,
244 return c.json({ imageUrl });
245 } else {
246 const response = await openai.chat.completions.create({
247 messages: [{ role: "user", content: prompt }],
248 model: "gpt-4o-mini",
35Use Cerebras for AI on the backend like so:
36
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
83 const { messages } = await request.json();
84
85 const { OpenAI } = await import("https://esm.sh/openai");
86 // Cerebras Inference
87 // Very important: do not change this
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91 baseURL: "https://api.cerebras.ai/v1",
35Use Cerebras for AI on the backend like so:
36
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"
83 const { messages } = await request.json();
84
85 const { OpenAI } = await import("https://esm.sh/openai");
86 // Cerebras Inference
87 // Very important: do not change this
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91 baseURL: "https://api.cerebras.ai/v1",
2import { createRoot } from "https://esm.sh/react-dom@18.2.0/client?deps=react@18.2.0,react-dom@18.2.0";
3import React, { useCallback, useState } from "https://esm.sh/react@18.2.0";
4import { OpenAI } from "https://esm.town/v/std/openai";
5
6// Static import for syntax highlighting
78 setError(null);
79 try {
80 const openai = new OpenAI();
81
82 // Generate API Code
83 const codeCompletion = await openai.chat.completions.create({
84 model: "gpt-4o-mini",
85 messages: [
104
105 // Generate Tests
106 const testCompletion = await openai.chat.completions.create({
107 model: "gpt-4o-mini",
108 messages: [
125
126 // Generate Documentation
127 const docCompletion = await openai.chat.completions.create({
128 model: "gpt-4o-mini",
129 messages: [
190export default async function server(request: Request): Promise<Response> {
191 if (request.method === "POST" && new URL(request.url).pathname === "/generate-api") {
192 const { OpenAI } = await import("https://esm.sh/openai");
193
194 try {
212 }
213
214 const client = new OpenAI({
215 apiKey: apiKey,
216 baseURL: "https://api.cerebras.ai/v1"