Search
Code3,914
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" }, <footer style={styles.footer}> <p style={styles.footerText}> π‘οΈ SafeSense Guardian-AI v2.0 β’ Powered by OpenAI GPT-4 β’ <span style={styles.footerStats}> {moderationHistory.length} analyses performed</span> </p> if (request.method === "POST" && url.pathname === "/moderate") { try { const { OpenAI } = await import("https://esm.town/v/std/openai"); const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY")); const body = await request.json(); }`; const response = await openai.chat.completions.create({ model, messages: [ }`; const response = await openai.chat.completions.create({ model, messages: [ ) { try { const { OpenAI } = await import("https://esm.town/v/std/openai"); // Val Town builtβin proxy [web:26][web:36] const openai = new OpenAI(); const body = await request.json(); if (type === "text") { const text = String(body.text || ""); const resp = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ const imageDataUrl: string = body.image; // Expect a full data URL: data:image/jpeg;base64,xxx [web:32][web:38] const resp = await openai.chat.completions.create({ model: "gpt-4o", messages: [ // infer likely content risk (no real PDF parsing to respect sandbox). [web:40] const docData = String(body.document || ""); const resp = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ Features: - Client UI to submit text, images, or documents (PDF) for moderation. - Server endpoints that call OpenAI (moderation + image description) and return a structured safety verdict: { safe: boolean, category: string[], description } NOTE: Replace the OpenAI import / initialization if your runtime requires API keys or different SDK.*/ try { const body = await request.json(); const { OpenAI } = await import('https://esm.town/v/std/openai'); const openai = new OpenAI(); // return structure try { // Try moderation API const mod = await openai.moderations.create({ model: 'omni-moderation-latest', input: body.payload }); responsePayload.details.moderation = mod; const flagged = (mod.results && mod.results[0] && mod.results[0].flagged) || false; } catch (e) { // Fallback: ask chat model to classify const chat = await openai.chat.completions.create({ model: 'gpt-4o', messages: [ // Describe the image first try { const chat = await openai.chat.completions.create({ model: 'gpt-4o', messages: [ responsePayload.details.description = desc; // Run moderation on the description + short prompt const mod = await openai.moderations.create({ model: 'omni-moderation-latest', input: desc }); responsePayload.details.moderation = mod; const flagged = (mod.results && mod.results[0] && mod.results[0].flagged) || false; const docPrompt = `You are a content safety assistant. A document named "${body.filename}" with mime "${body.mime}" is provided as base64. Attempt a high-level safety analysis. If you can detect sexual content, hate, violence, self-harm, illegal instructions, or PII exposure, mark UNSAFE and explain why. Otherwise mark SAFE. Respond as JSON with keys: verdict (SAFE/UNSAFE), categories (list), summary (one-line), notes (detailed).\n\nBase64 (first 4000 chars): ${String(body.payload).slice(0,4000)}`; const chat = await openai.chat.completions.create({ model: 'gpt-4o', messages: [{ role: 'user', content: docPrompt }] }); const textResp = chat.choices[0].message.content || ''; responsePayload.details.review = textResp;export default async function(req: Request): Promise<Response> { // Handle CORS for OpenAI if (req.method === "OPTIONS") { return new Response(null, {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" },\_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" }], model: "gpt-4o-mini",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" },import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";import { Octokit } from "npm:octokit";import { OpenAI } from "https://esm.town/v/std/openai";// Environment variables, set them in the left sidebar */async function generateUserFocusedSummary(fullCommitMessage: string, commitType: string): Promise<string> { const openai = new OpenAI(); const prompt = `You are writing release notes for a developer tool. Based on this commit message, write a concise one-liner. try { const completion = await openai.chat.completions.create({ messages: [{ role: "user", content: prompt }], model: "gpt-4o-mini",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" },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