Search

3,265 results found for openai (1936ms)

Code
3,170

Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { 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 cre
### OpenAI
```ts
import { 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 cre
### OpenAI
```ts
import { 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 cre
### OpenAI
```ts
import { 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" },
export default async function server(request: Request): Promise<Response> {
if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const { message } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to cre
### OpenAI
```ts
import { 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" },
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 KEY = "todo_app";
const openai = new OpenAI();
// Ensure tables exist
const { examDate } = await request.json();
const completion = await openai.chat.completions.create({
messages: [
{
import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import { OpenAI } from "https://esm.town/v/std/openai";
function WomenInSTEMBlog() {
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 = "Women_In_STEM";
const SCHEMA_VERSION = 5;
for (const woman of womenAndInventions) {
// Generate concise, inspirational biography
const biographyCompletion = await openai.chat.completions.create({
messages: [{
role: "user",
// Generate detailed invention description
const inventionCompletion = await openai.chat.completions.create({
messages: [{
role: "user",
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 KEY = "bedtimeStoriesChatRoom";
const openai = new OpenAI();
// Increment version to force table recreation
// Generate bedtime story
if (url.pathname === "/story") {
const completion = await openai.chat.completions.create({
messages: [{
role: "user",
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",