Search
Code3,665
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" },### Widget Integration- Each tool specifies `openai/outputTemplate` in metadata- Widgets automatically render based on structured content- Consistent styling across all clothing-related widgets1. **Cloudinary upload fails**: Check environment variables2. **No outfit suggestions**: Ensure both tops and bottoms are in closet3. **Widget not displaying**: Verify `openai/outputTemplate` metadata### Debug Tips- All widgets use the `useToolOutput` hook to access structured data- Theme support via `useTheme` hook (light/dark mode)- Interactive actions send follow-up messages to ChatGPT via `getOpenAI().sendFollowUpMessage()`### Styling- Displays a single wardrobe item with image and category- Uses inline styles for consistent appearance- Accesses data via `globalThis.openai?.toolOutput?.structuredContent`### 2. MultiItemCard (`/frontend/widgets/components/MultiItemCard.tsx`)### MCP Integration- Proper `_meta` configuration with `openai/outputTemplate`- Structured content matching component expectations- Error handling for missing data### Data Access Pattern- Uses `globalThis.openai?.toolOutput?.structuredContent`- Direct access to structured data (no hooks needed)- Matches the original component specifications exactlyexport default function OutfitCard() { // @ts-ignore const sc = (globalThis as any).openai?.toolOutput?.structuredContent; const { top, bottom } = sc ?? {}; if (!top || !bottom) return null;export default function MultiItemCard() { // @ts-ignore const items = (globalThis as any).openai?.toolOutput?.structuredContent?.items ?? []; if (!items.length) return null;export default function ItemCard() { // @ts-ignore: ChatGPT injects toolOutput const sc = (globalThis as any).openai?.toolOutput?.structuredContent; const item = sc?.item; if (!item) return null;import type { WeatherOutput } from "../../../shared/types.ts";import { useTheme, useToolOutput } from "../hooks.ts";import { getOpenAI } from "../openai-types.ts";export function WeatherWidget() { async function handleRefresh() { await getOpenAI()?.sendFollowUpMessage({ prompt: `Refresh weather for ${location}`, }); async function handleChangeLocation() { await getOpenAI()?.sendFollowUpMessage({ prompt: "Change weather location", });import type { TodoListOutput, Todo } from "../../../shared/types.ts";import { useTheme, useToolOutput } from "../hooks.ts";import { getOpenAI } from "../openai-types.ts";export function TodoWidget() { async function handleAddTodo() { await getOpenAI()?.sendFollowUpMessage({ prompt: "Add a new todo item", }); async function handleToggleTodo(todo: Todo) { await getOpenAI()?.sendFollowUpMessage({ prompt: `${todo.completed ? "Mark as incomplete" : "Mark as complete"}: ${todo.text}`, }); async function handleDeleteTodo(todo: Todo) { await getOpenAI()?.sendFollowUpMessage({ prompt: `Delete todo: ${todo.text}`, });import type { CounterOutput } from "../../../shared/types.ts";import { useTheme, useToolOutput } from "../hooks.ts";import { getOpenAI } from "../openai-types.ts";export function CounterWidget() { async function handleIncrement() { await getOpenAI()?.sendFollowUpMessage({ prompt: `Increment counter by ${step}`, }); async function handleDecrement() { await getOpenAI()?.sendFollowUpMessage({ prompt: `Decrement counter by ${step}`, }); async function handleReset() { await getOpenAI()?.sendFollowUpMessage({ prompt: "Reset counter to 0", });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