Search

4,002 results found for openai (6323ms)

Code
3,898

bomb/hmmm/main.ts
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
try {
const openai = new OpenAI();
// Construct the precise user message for the AI
`;
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
brian@airbnb.com,Brian Chesky
drew@dropbox.com,Drew Houston
sam@openai.com,Sam Altman
tim@apple.com,Tim Cook
jeff@amazon.com,Jeff Bezos
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 c
### 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",
// Version 1.0.0
import OpenAI from "npm:openai@4.73.0";
// ============================================================================
/**
* Analyzes a company using OpenAI with web search to generate a lead score
*/
export async function analyzeCompany(
apiKey: string
): Promise<LeadAssessment> {
const client = new OpenAI({ apiKey });
// Clean up the URL
}
const apiKey = Deno.env.get("OPENAI_API_KEY");
if (!apiKey) {
return Response.json(
{ error: "OpenAI API key not configured" },
{ status: 500 }
);
# Val Town Lead Scoring System
panies to determine their fit as Val Town customers. Uses OpenAI's latest GPT-4o model with web
## Overview
```
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Web UI │────▶│ HTTP Handler│────▶│ OpenAI API │
└─────────────┘ └──────────────┘ └─────────────┘
│ │
2. **Score Engine** (`analyzeCompany`)
- Orchestrates OpenAI analysis
- Enforces structured output schema
- Applies scoring weights
- **Runtime**: Deno (Val Town environment)
- **AI Model**: OpenAI GPT-4o-2024-11-20
- **Language**: TypeScript
- **Styling**: Inline CSS (Val Town design system)
### Environment Variables
- `OPENAI_API_KEY`: Required for AI analysis
- `VAL_TOWN_URL`: Base URL for the Val (auto-configured)
- **Invalid URLs**: Returns 400 with error message
- **API Key Missing**: Returns 500 with configuration error
- **OpenAI Errors**: Gracefully degrades with error display
- **Network Issues**: Timeout and retry logic included
1. Fork this Val to your account
2. Set your `OPENAI_API_KEY` in environment variables
3. The Val auto-deploys on save
4. Access via the generated URL
- **Analysis Time**: 10-20 seconds per company
- **Rate Limits**: Respects OpenAI rate limits
- **Caching**: Results can be cached client-side
- **Concurrent Requests**: Handle multiple via API
### Updating the Model
To use a different OpenAI model, change:
```typescript
1. Check the Val Town logs for errors
2. Ensure environment variables are set
3. Verify OpenAI API key has sufficient credits
4. Test with known-good company URLs
---
Built with Val Town • Powered by OpenAI
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- TYPE DEFINITIONS ---
const app = new Hono();
const openai = new OpenAI();
/**
`;
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
`;
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
try {
const completion = await openai.chat.completions.create({
model: "gpt-4o",
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" },
const REALTIME_BASE_URL = "https://api.openai.com/v1/realtime";
const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
if (!OPENAI_API_KEY) {
throw new Error("🔴 OpenAI API key not configured");
}
export function makeHeaders(contentType?: string) {
const obj: Record<string, string> = {
Authorization: `Bearer ${OPENAI_API_KEY}`,
};
if (contentType) obj["Content-Type"] = contentType;