Search
Code3,285
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" },
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" },
const PINECONE_API_KEY = Deno.env.get("PINECONE_API_KEY"); const PINECONE_HOST = Deno.env.get("PINECONE_HOST"); const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY"); console.log("PINECONE_HOST:", PINECONE_HOST); console.log("Has API keys:", !!PINECONE_API_KEY, !!OPENAI_API_KEY); try { // Get embedding const embResponse = await fetch("https://api.openai.com/v1/embeddings", { method: "POST", headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "Content-Type": "application/json", },
export const searchEngine = { async search(parsedQuery: any, originalQuery: string) { const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY"); const PINECONE_API_KEY = Deno.env.get("PINECONE_API_KEY"); const PINECONE_HOST = Deno.env.get("PINECONE_HOST"); console.log("Wants latest?", wantsLatest); const embedding = await searchEngine.getEmbedding(originalQuery, OPENAI_API_KEY); const filter = {}; async getEmbedding(text: string, apiKey: string) { const response = await fetch("https://api.openai.com/v1/embeddings", { method: "POST", headers: { if (!response.ok) { const error = await response.text(); console.error("OpenAI embedding error:", error); throw new Error(`Embedding generation failed: ${response.status}`); }
export const answerBot = { async generateAnswer(query: string, searchResults: any, threadId?: string) { const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY"); // Get or create thread ]; const response = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "Content-Type": "application/json", }, if (!response.ok) { const error = await response.text(); console.error("OpenAI API error:", error); throw new Error(`OpenAI API failed: ${response.status}`); }
export const queryParser = { async parse(query: string) { const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY"); const response = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "Content-Type": "application/json", },
const PINECONE_API_KEY = Deno.env.get("PINECONE_API_KEY"); const PINECONE_HOST = Deno.env.get("PINECONE_HOST"); const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY"); console.log("PINECONE_HOST:", PINECONE_HOST); console.log("Has API keys:", !!PINECONE_API_KEY, !!OPENAI_API_KEY); try { // Get embedding const embResponse = await fetch("https://api.openai.com/v1/embeddings", { method: "POST", headers: { "Authorization": `Bearer ${OPENAI_API_KEY}`, "Content-Type": "application/json", },
import { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "What are some interesting walks in Hertfordshire, starting in Hemel" },
import { Hono } from "https://esm.sh/hono@3.11.7";import { OpenAI } from "https://esm.town/v/std/openai";import type { AIPrioritizeAllResponse, AIPriorityResponse } from "../../shared/types.ts";import { getAllTodos, updateTodoAIPriority } from "../database/queries.ts";const ai = new Hono();const openai = new OpenAI();// Get AI priority suggestion for a single todo`; const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini", const response = completion.choices[0]?.message?.content; if (!response) { throw new Error("No response from OpenAI"); }`; const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini", const response = completion.choices[0]?.message?.content; if (!response) { throw new Error("No response from OpenAI"); }
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