Search

4,002 results found for β€œopenai” (1721ms)

Code
3,898

import { email } from "https://esm.town/v/std/email";
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
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" },
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" },
- **Blob Storage**: `import { blob } from "https://esm.town/v/std/blob"`
- **SQLite**: Use Drizzle ORM instead of raw SQL
- **OpenAI**: `import { OpenAI } from "https://esm.town/v/std/openai"`
- **Email**: `import { email } from "https://esm.town/v/std/email"`
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { Hono } from "npm:hono@4.4.12";
import { stream } from "npm:hono@4.4.12/streaming";
app.post("/api", async (c) => {
const { action } = c.req.query();
const openai = new OpenAI();
try {
}
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
);
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini", // Use a faster model for chat
messages: [
);
const streamResponse = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// FINAL INTEGRATED VERSION (Parts 1-6)
import { Hono } from "npm:hono@4.4.12";
import { OpenAI } from "https://esm.town/v/std/openai";
import type { Context } from "npm:hono@4.4.12";
import { streamText } from "npm:hono@4.4.12/streaming";
// --- BACKEND SERVICES ---
const services = {
async callOpenAI(
systemPrompt: string,
userContent: string | object,
c = null,
} = options;
const openai = new OpenAI();
const messages: any[] = [{ role: "system", content: systemPrompt }, {
role: "user",
if (isJson) requestPayload.response_format = { type: "json_object" };
try {
const completion = await openai.chat.completions.create(requestPayload);
if (stream && c) {
return streamText(c, async (s) => {
return completion;
} catch (e) {
console.error(`Error calling OpenAI: ${e.message}`);
throw new Error("AI service failed.");
}
}
const userContent = `Company Context: ${JSON.stringify(company_context)}`;
return services.callOpenAI(config.prompts.INDUSTRY_GENERATOR, userContent, {
c,
isJson: true,
);
try {
const completion = await services.callOpenAI(
"You are a helpful assistant following strict output rules.",
prompt,
},
};
return services.callOpenAI(config.prompts.DYNAMIC_LIST_GENERATOR, payload, {
c,
isJson: true,
`Task: ${task}\n\n` +
`MANDATE: The refined prompt MUST yield a tangible, industry-standard deliverable typical fo
return services.callOpenAI(config.prompts.PROMPT_REFINER, userContent, {
c,
isJson: true,
// in case the userPrompt logic diverges more significantly later.
if (category === "prompt_building") {
return services.callOpenAI(systemPrompt, userPrompt, { c, stream: true });
} else {
return services.callOpenAI(systemPrompt, userPrompt, { c, stream: true });
}
});
briefing,
);
const criteriaCompletion = await services.callOpenAI(
"You are a helpful assistant following strict output rules.",
criteriaPrompt,
raw_output: first_draft,
};
return services.callOpenAI(config.prompts.EVALUATOR_AGENT, userContent, {
c,
isJson: true,
## QA Critique
${critique}`;
return services.callOpenAI(config.prompts.REFINER_AGENT, userContent, {
c,
stream: true,
import { Hono } from "npm:hono@4.4.12";
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES & PROMPTS ---
const app = new Hono();
const openai = new OpenAI(); // Initialized once
// Middleware to ensure OpenAI key is set
app.use("/api/*", async (c, next) => {
if (!Deno.env.get("OPENAI_API_KEY")) {
return c.json(
{ error: "OPENAI_API_KEY environment variable is not set." },
500,
);
}
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini", // Use a fast and efficient model for this task
messages: [
}
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
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" },
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { Hono } from "npm:hono@4.4.12";
import { stream } from "npm:hono@4.4.12/streaming";
* @param occupationTitle - The O*NET title of the expert (e.g., "Software Developers").
* @param context - The user's company context.
* @returns A string representing the complete system prompt for the OpenAI API.
*/
function createDocumentPrompt(
<header class="header">
<h1>Tribal Knowledge Engine</h1>
<p>AI-Powered Professional Document Generator β€’ Powered by O*NET + OpenAI</p>
</header>
app.post("/api", async (c) => {
const { action } = c.req.query();
const openai = new OpenAI();
try {
}
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
);
const streamResponse = await openai.chat.completions.create({
model: "gpt-4o",
messages: [