Search

4,018 results found for β€œopenai” (6812ms)

Code
3,914

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" },
<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 pro
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 differen
*/
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:
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:
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.filena
const chat = await openai.chat.completions.create({ model: 'gpt-4o', messages: [{ role
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 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" },
\_2 or \_3) to create a fresh table.
### 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" }],
model: "gpt-4o-mini",
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" },
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): Promis
const openai = new OpenAI();
const prompt = `You are writing release notes for a developer tool. Based on this commit messa
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 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" },
…
6
…