Search

3,376 results found for openai (4632ms)

Code
3,281

// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { Hono } from "npm:hono@4.4.12";
app.post("/api/reframe", async (c) => {
const { entry_text } = await c.req.json();
const openai = new OpenAI();
if (!entry_text || typeof entry_text !== "string") {
try {
// Step 1: Analyze the entry for cognitive distortions.
const analysisCompletion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// Step 2: Generate a Socratic question based on the analysis.
const guidanceCompletion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// Handle the root request to serve the UI.
try {
const openai = new OpenAI();
let affirmations = [
"A moment of insight is preparing to bloom.",
try {
// Attempt to fetch fresh affirmations, but have defaults as a fallback.
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "system", content: AFFIRMATION_PROMPT }],
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
// Using the official npm package for maximum stability
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { Hono } from "npm:hono@4.4.12";
app.use("/api/*", cors());
// Helper function to safely create an OpenAI client
function getOpenAIClient() {
return new OpenAI();
}
try {
const openai = getOpenAIClient();
const now = new Date().toISOString();
const conversationId = crypto.randomUUID();
});
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "system", content: INITIAL_PROMPT }],
try {
const openai = getOpenAIClient();
const convResult = await sqlite.execute({
sql: `SELECT user_id, history, latitude, longitude FROM ${T.conversations} WHERE id = :id`
if (historyArr.length >= 7) {
// --- Summarize the conversation ---
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
} else {
// --- Continue the conversation ---
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
*/
import { OpenAI } from "https://esm.town/v/std/openai";
import { Octokit } from "https://esm.sh/@octokit/rest@20.0.2";
import { WebClient } from "https://esm.sh/@slack/web-api@7.0.2";
async function isBugReportLLM(text: string): Promise<boolean> {
try {
// Check if OpenAI API key is available
if (!Deno.env.get("OPENAI_API_KEY")) {
console.warn("OpenAI API key not found - bug detection disabled");
return false;
}
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{
async function findRelatedIssues(slackMessage: string, issues: any[]): Promise<any[]> {
try {
// Check if OpenAI API key is available
if (!Deno.env.get("OPENAI_API_KEY")) {
return [];
}
}).join("\n\n");
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{
1. When a new message is posted in a configured Slack channel (ie. #bugs, or #support), Slack se
2. The val makes an OpenAI call to determine if the message is a bug
tHub for semantically related open issues with a separate OpenAI call
4. It posts a comment in the Slack thread with links to related GitHub issues, with a "Relevance
join/sbir/main.tsx
5 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { Hono } from "npm:hono@4.4.12";
}
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
}
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { stream, streamText } from "npm:hono/streaming";
import { Hono } from "npm:hono@4.4.12";
app.post("/journey", async (c) => {
const { birthData, tripType, tripDuration } = await c.req.json();
const openai = new OpenAI();
const astroData = astrocartography.getPlanetaryLines(birthData);
try {
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "system", content: GENERATION_STYLE_GUIDE }, { role: "user", content: p
// @ts-ignore
import { blob } from "https://esm.town/v/std/blob?v=11";
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { Hono } from "npm:hono@4.4.12";
const promptData = rows[0][0];
const openai = new OpenAI();
const scriptCompletion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
if (!scriptText) throw new Error("AI did not generate a valid script.");
const audioResponse = await openai.audio.speech.create({
model: "tts-1-hd",
voice: TTS_VOICE,
join/echo/main.tsx
4 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { Hono } from "npm:hono@4.4.12";
</main>
<footer>
<p>Powered by <a href="${safeSourceUrl}" target="_blank">Val Town</a> & OpenAI</p>
</footer>
</div>
}
const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
}
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [