14Supports: checkbox, date, multi_select, number, rich_text, select, status, title, url, email
15
16- Uses `NOTION_API_KEY`, `OPENAI_API_KEY` stored in env variables and uses [Valtown blob storage](https://esm.town/v/std/blob) to store information about the database.
17- Use `get_notion_db_info` to use the stored blob if exists or create one, use `get_and_save_notion_db_info` to create a new blob (and replace an existing one if exists).
3import Instructor from "npm:@instructor-ai/instructor";
4import { Client } from "npm:@notionhq/client";
5import OpenAI from "npm:openai";
6import { z } from "npm:zod";
7
26};
27
28const oai = new OpenAI({
29 apiKey: process.env.OPENAI_API_KEY ?? undefined,
30});
31
133 if (request.method === "POST" && new URL(request.url).pathname === "/convert") {
134 try {
135 const { OpenAI } = await import("https://esm.town/v/std/openai");
136 const { blob } = await import("https://esm.town/v/std/blob");
137 const openai = new OpenAI();
138
139 const body = await request.json();
192
193 try {
194 const completion = await openai.chat.completions.create({
195 messages: [
196 {
1# OpenAI Structured Output Demo
2
3Ensure responses follow JSON Schema for structured outputs
5The following demo uses zod to describe and parse the response to JSON.
6
7Learn more in the [OpenAI Structured outputs
8 docs](https://platform.openai.com/docs/guides/structured-outputs/introduction).
9
10
11Migrated from folder: Archive/openai_structured_output_demo
27 try {
28 const imageURL = (await textToImageDalle(
29 process.env.openai,
30 text,
31 1,
1# Telegram DALLE Bot
2
3A personal telegram bot you can message to create images with OpenAI's [DALLE](https://openai.com/dall-e-2) ✨
4
5
1/** @jsxImportSource https://esm.sh/react */
2import OpenAI from "https://esm.sh/openai";
3import React, { useState } from "https://esm.sh/react";
4import { createRoot } from "https://esm.sh/react-dom/client";
6import { systemPrompt } from "https://esm.town/v/weaverwhale/jtdPrompt";
7
8// Move OpenAI initialization to server function
9let openai;
10
11function App() {
139 const url = new URL(request.url);
140
141 // Initialize OpenAI here to avoid issues with Deno.env in browser context
142 if (!openai) {
143 const apiKey = Deno.env.get("OPENAI_API_KEY");
144 openai = new OpenAI({ apiKey });
145 }
146
150
151 // Generate DALL-E prompt using GPT
152 const completion = await openai.chat.completions.create({
153 messages: [
154 {
168
169 // Generate DALL-E image
170 const response = await openai.images.generate({
171 model: "dall-e-3",
172 prompt: dallePrompt,
10const { endpoint } = VAL;
11
12import { OpenAI } from "https://esm.town/v/std/openai";
13
14const openai = new OpenAI();
15
16async function POST(cmd: string, data: { [key: string]: string }) {
67 const q = text.split(" ").slice(1).join(" ");
68 console.log("q", q);
69 const completion = await openai.chat.completions.create({
70 messages: [
71 { role: "user", content: q },
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
28 }
29
30 const stream = await openai.chat.completions.create(body);
31
32 if (!body.stream) {
3
4import { Hono } from "npm:hono";
5import { OpenAI } from "npm:openai";
6
7const trendGPT = async (data, onData) => {
8 const openai = new OpenAI();
9
10 const chatStream = await openai.chat.completions.create({
11 messages: [
12 { role: "system", content: prompt.replaceAll("\n", "") },