Search

3,267 results found for openai (1875ms)

Code
3,172

* Hono JSX
* HTMX (probably overcomplicates things; should remove)
* @stevekrouse/openai, which is a light wrapper around @std/openai
I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it:
import { email } from "https://esm.town/v/std/email";
import { extractValInfo } from "https://esm.town/v/stevekrouse/extractValInfo";
import { OpenAI } from "npm:openai";
function stripHtmlBackticks(html: string): string {
export default async function(e: Email) {
const openai = new OpenAI();
console.log(`from: ${e.from} to: ${e.to} subject: ${e.subject}, cc: ${e.cc}, bcc: ${e.bcc}`);
}
const summary = await openai.chat.completions.create({
messages: [
{
import process from "node:process";
import { marked } from "npm:marked";
import { OpenAI } from "npm:openai";
function pm(...lines: string[]): string {
);
const client = new OpenAI({ apiKey: process.env.PERPLEXITY_API_KEY, baseURL: "https://api.perp
const response = await client.chat.completions.create({
model: "sonar",
<a href="?q=function" className="example-link">function</a>
<a href="?q=discord" className="example-link">discord</a>
<a href="?q=openai" className="example-link">openai</a>
<a href="?q=react" className="example-link">react</a>
</div>
<a href="?q=function" className="example-link">function</a>
<a href="?q=discord" className="example-link">discord</a>
<a href="?q=openai" className="example-link">openai</a>
<a href="?q=react" className="example-link">react</a>
</div>
<a href="?q=function" className="example-link">function</a>
<a href="?q=discord" className="example-link">discord</a>
<a href="?q=openai" className="example-link">openai</a>
<a href="?q=react" className="example-link">react</a>
</div>
<a href="?q=function" className="example-link">function</a>
<a href="?q=discord" className="example-link">discord</a>
<a href="?q=openai" className="example-link">openai</a>
<a href="?q=react" className="example-link">react</a>
</div>
<a href="?q=function" className="example-link">function</a>
<a href="?q=discord" className="example-link">discord</a>
<a href="?q=openai" className="example-link">openai</a>
<a href="?q=react" className="example-link">react</a>
</div>
<a href="?q=function" className="example-link">function</a>
<a href="?q=discord" className="example-link">discord</a>
<a href="?q=openai" className="example-link">openai</a>
<a href="?q=react" className="example-link">react</a>
</div>
AIWB/test1/main.tsx
15 matches
// Combined Frontend (React/ChakraUI) and Backend (Hono/OpenAI) for Val Town
// Funding Assistant Dashboard Prototype - v6 (Corrected AgencyInfo Prompt Logic)
export default async function server(request: Request): Promise<Response> {
// Only import server-side dependencies here
const { OpenAI } = await import("https://esm.town/v/std/openai");
// const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite"); // DB optional
const { Hono } = await import("npm:hono");
// --- OpenAI Client ---
// Ensure API key is set as Val Town env var 'openai'
let openai;
try {
openai = new OpenAI();
} catch (e) {
console.error("FATAL: Failed to initialize OpenAI client. Is the 'openai' environment varia
// Return a generic server error response if OpenAI cannot be initialized
error: "Server configuration error. Unable to initialize OpenAI client." }), {
status: 500,
headers: { "Content-Type": "application/json" },
];
// --- Call OpenAI ---
console.log(`Calling OpenAI for agent: ${agentType}...`);
const completion = await openai.chat.completions.create({
messages: messages,
model: "gpt-4o",
} catch (error) {
// Catches errors in request handling, OpenAI API call itself, etc.
console.error(`Critical error initiating agent ${agentType}:`, error);
let errorMsg = `Server error initiating agent ${agentType}.`;
// Check for specific OpenAI errors if needed for better diagnostics
// if (error instanceof OpenAI.APIError) { errorMsg = `OpenAI API Error: ${error.status}
else if (error.message) {
errorMsg = `${errorMsg} Details: ${error.message}`;
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" },
- [ ] Get OpenTownie or Gemini or Claude or OpenAI to synthesize the core of these patterns into
- [ ] Convert this or into the basic react router guest book (and preserve this forum app in ano
- [ ] To what extent can these patterns be packaged up into a Val Town Router project? Would be