Search

3,266 results found for openai (1761ms)

Code
3,171

if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
const openai = new OpenAI();
// Use the val's URL as a unique key for database tables
const echoPrompt = getEchoPrompt();
const completion = await openai.chat.completions.create({
messages: [
{
// First, generate the agent prompt
const completion2 = await openai.chat.completions.create({
messages: [
{
// Then, generate commands for the agent based on its purpose and description
const commandsCompletion = await openai.chat.completions.create({
messages: [
{
}
// Format the history into OpenAI message format
const messages = [
{
// Add conversation history if it exists
if (history && history.length > 0) {
// Filter out system messages and map to OpenAI format
history.forEach(msg => {
if (msg.role !== "system") {
// Chat with the agent using the stored prompt and history
const completion = await openai.chat.completions.create({
messages: messages,
model: "gpt-4o-mini",
// Execute the command with the AI
const completion = await openai.chat.completions.create({
messages: messages,
model: "gpt-4o-mini",
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{
import { OpenAI } from "https://esm.town/v/std/openai";
// Telegram Bot Token - you would replace this with your actual bot token
const TELEGRAM_API_URL = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}`;
// OpenAI for generating research insights
const openai = new OpenAI();
// Helper function to send Telegram message
async function processResearchRequest(text: string) {
try {
const completion = await openai.chat.completions.create({
messages: [
{
return completion.choices[0].message.content || "I couldn't generate a response.";
} catch (error) {
console.error("OpenAI Error:", error);
return "Sorry, there was an error processing your research request.";
}
if (request.method === "POST") {
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const { topic } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
if (request.method === "POST") {
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const { topic } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
if (request.method === "POST") {
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const { topic } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
export default async function server(request: Request): Promise<Response> {
if (request.method === "POST") {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
try {
const { query } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
export default async function server(request: Request): Promise<Response> {
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const KEY = "My_Scheduler";
const taskList = tasks.rows.map(t => `${t.task} (${t.duration} mins, ${t.priority} priority)
const suggestion = await openai.chat.completions.create({
messages: [
{
import { email } from "https://esm.town/v/std/email";
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
export default async function (e: Email) {
const openai = new OpenAI();
// Ensure we have text content to analyze
try {
// Use GPT to draft an intelligent reply
const completion = await openai.chat.completions.create({
messages: [
{
abas/C_s/main.tsx
3 matches
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const systemPrompt = `
`;
const aiCompletion = await openai.chat.completions.create({
messages: [
{ role: "system", content: systemPrompt },