Search

3,373 results found for openai (1930ms)

Code
3,278

// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES & PROMPTS ---
// Handle API POST requests
if (req.method === "POST") {
const openai = new OpenAI();
let body;
}
const completion = await openai.chat.completions.create({
model: model,
messages: messages,
console.log("\n1. Twitter API credentials:");
console.log(" - TWITTER_BEARER_TOKEN: Your Twitter API bearer token");
console.log("\n2. OpenAI API credentials:");
console.log(" - OPENAI_API_KEY: Your OpenAI API key");
console.log("\n3. Dashboard authentication:");
console.log(" - AUTH_USERNAME: Username for dashboard authentication");
const requiredVars = [
"TWITTER_BEARER_TOKEN",
"OPENAI_API_KEY",
"AUTH_USERNAME",
"AUTH_PASSWORD",
import { JOB_EXPECTATIONS_2025_06_28 } from "./job_expectations.ts";
import { AttioClient } from "./clients/attio.ts";
import { OpenAIClient } from "./clients/openai.ts";
import { EmailClient } from "./clients/email.ts";
import type { JobApplication, CandidateReport } from "./clients/types.ts";
// Initialize API clients
const openaiClient = new OpenAIClient();
const attioClient = new AttioClient();
const emailClient = new EmailClient();
async function processJobApplication(application: JobApplication): Promise<CandidateReport> {
try {
// Step 1: Generate AI analysis using OpenAI client
const report = await openaiClient.processJobApplication(application, JOB_EXPECTATIONS_2025_0
// Step 2: Save to Attio CRM using Attio client
message: "Job Application Processor v4.0 - Enhanced Candidate Communications",
features: [
"Modular OpenAI, Attio, and Email API clients",
"GPT-4o preprocessing + O3 analysis with web search",
"Three AI-generated candidate response templates (positive/neutral/negative)",
return c.json({
message: "Test processing complete using OpenAI Responses API [TEST MODE]",
sampleApplication,
report,
message: "Test failed",
error: error.message,
note: "Make sure OPENAI_API_KEY is set in environment variables"
}, 500);
}
- **Framework**: Hono for HTTP routing
- **Storage**: None (stateless webhook processor)
- **AI**: OpenAI GPT-4o (preprocessing) + O3 (analysis) with Responses API
- **Search**: OpenAI native web search (advanced depth, 10 max results)
- **CRM**: Attio integration for candidate tracking
## Environment Variables (Required)
- `OPENAI_API_KEY` - OpenAI API key for GPT-4o and O3 models
- `ATTIO_API_KEY` - Attio CRM API key for candidate record creation
│ ├── types.ts # Shared TypeScript interfaces
│ ├── attio.ts # AttioClient - CRM operations
│ └── openai.ts # OpenAIClient - AI processing
├── utils/ # Utility classes
│ ├── tokens.ts # TokenEstimator - text/token analysis
- `createCandidateRecord()` - Complete CRM workflow
**OpenAIClient** (`clients/openai.ts`)
- `filterJobExpectations()` - GPT-4o preprocessing
- `generateCandidateAnalysis()` - O3 analysis with web search
- `processJobApplication()` - Complete AI workflow
## OpenAI Responses API Important Notes
- Use `max_output_tokens` NOT `max_completion_tokens`
- o3 model does NOT support `temperature` parameter
- Web search tool supports `search_depth: "advanced"` and `max_results: 10`
- Responses API is stateful - can use `previous_response_id` for multi-turn
- API endpoint: `https://api.openai.com/v1/responses`
## Attio CRM Integration
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
if (req.method === "POST") {
try {
// Initialize OpenAI with the API key from environment variables
const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
const body = await req.json();
const { name, description } = body;
];
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: messages,
join/muse/main.tsx
3 matches
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- DATA ---
if (req.method === "POST" && action === "generateShowcase") {
try {
const openai = new OpenAI();
const body = await req.json();
const { textures } = body;
];
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: messages,
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
if (req.method === "POST" && action === "generatePattern") {
try {
const openai = new OpenAI();
const { theme, score, assets } = await req.json();
];
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: messages,
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI PERSONA & PROMPTS (SERVER-SIDE ONLY) ---
if (req.method === "POST") {
try {
const openai = new OpenAI();
const body = await req.json();
}
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
// @ts-ignore
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
// --- AI BEHAVIORAL GUIDELINES ---
if (req.method === "POST") {
try {
const openai = new OpenAI();
const body = await req.json();
const completion = await openai.chat.completions.create({
model: "gpt-4o",
messages: [
import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
/**
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
*/
export class OpenAI {
private rawOpenAIClient: RawOpenAI;
/**
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
*
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) th
*/
constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
this.rawOpenAIClient = new RawOpenAI({
...options,
baseURL: "https://std-openaiproxy.web.val.run/v1",
apiKey: Deno.env.get("valtown"),
organization: null,
get chat() {
return this.rawOpenAIClient.chat;
}
get beta() {
return {
chat: this.rawOpenAIClient.beta.chat,
};
}