Towniesystem_prompt.txt4 matches
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
8990### OpenAI
9192```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96messages: [
97{ role: "user", content: "Say hello in a creative way" },
reelMitrajsREADME.md2 matches
2const prompt = `Generate a short 15-second Instagram reel script and 5 viral hashtags for the topic: "${topic}". Make the script engaging and desi style.`;
34const res = await fetch("https://api.openai.com/v1/chat/completions", {
5method: "POST",
6headers: {
7"Authorization": `Bearer ${Deno.env.get("OPENAI_API_KEY")}`,
8"Content-Type": "application/json",
9},
untitled-509README.md2 matches
2const prompt = `Generate a short 15-second Instagram reel script and 5 viral hashtags for the topic: "${topic}". Make the script engaging and desi style.`;
34const res = await fetch("https://api.openai.com/v1/chat/completions", {
5method: "POST",
6headers: {
7"Authorization": `Bearer ${Deno.env.get("OPENAI_API_KEY")}`,
8"Content-Type": "application/json",
9},
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { sqlite } from "https://esm.town/v/std/sqlite";
3import nlp from "npm:compromise";
10}
1112const openai = new OpenAI();
13const app = express();
14app.use(express.json());
119// 1. Parse intent + slots
120// const prompt = buildIntentPrompt(text);
121// const completion = await openai.chat.completions.create({
122// messages: [
123// { role: "system", content: prompt },
147const rows = transformRows<Item>(result);
148const prompt = buildKnowledgePrompt(text, rows);
149const completion = await openai.chat.completions.create({
150messages: [
151{ role: "system", content: prompt },
resume-parserresumeSchemas.ts9 matches
34/**
5* Transforms a Zod schema into a format suitable for OpenAI by:
6* - Adding additionalProperties: false to all objects
7* - Making all fields required
8* - Removing validation constraints that OpenAI might struggle with
9*
10* Specifically removes:
17* @returns A new Zod schema with modified properties
18*/
19export function transformSchemaForOpenAI<T extends ZodType>(schema: T): T {
20// Helper to process each schema type
21function processSchema(schema: ZodTypeAny): ZodTypeAny {
104// For unions, just convert to the first type for simplicity
105// This is a simplification that might lose some information
106// but ensures OpenAI has a concrete type to work with
107return processSchema(schema._def.options[0])
108}
277standardization: z.string().describe("If the value has confidence > 0.8 keep pass the original value as is, Otherwise pass in following format, suitable for tooltip: UpdatedStandardValue=ReasonBehindUpdation")
278})
279// Create a simplified schema for OpenAI with fewer parameters
280// This addresses the 100 parameter limit in OpenAI's response_format
281export const SimplifiedResumeSchema = z.object({
282personalInfo: z.object({
345})
346347// Example of how to use the transformSchemaForOpenAI function:
348// This creates a version of SimplifiedResumeSchema that's suitable for OpenAI
349export const OpenAICompatibleResumeSchema = transformSchemaForOpenAI(SimplifiedResumeSchema)
350
untitled-1162new-file-7114.tsx3 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(req: Request): Promise<Response> {
11});
12}
13const openai = new OpenAI();
1415try {
28}
2930const stream = await openai.chat.completions.create(body);
3132if (!body.stream) {
rosey.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
stevensDemo.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },
resume-parseropenai.ts33 matches
1import {OpenAI} from "npm:openai"
2import {ParsedResume, ResumeParserOptions, ConfidenceField, DateRange} from "../types/resume.ts"
3import {generatePrompt} from "../prompts/resumePrompts.ts"
4import {OpenAICompatibleResumeSchema, ParsedResumeSchema} from "../schemas/resumeSchemas.ts"
5import {z} from "npm:@hono/zod-openapi"
6import {zodResponseFormat} from "npm:openai/helpers/zod"
78/**
9* Parse resume text using OpenAI and return structured data
10*
11* @param resumeText The plain text of the resume to parse
23}
2425// Initialize OpenAI client (uses API key from environment in ValTown)
26const openai = new OpenAI()
2728// Get extraction prompt
59${extractionFocus}${extractLanguages}${extractSummary}`
6061console.log("Calling OpenAI API for initial extraction...")
626364// Call OpenAI API with enhanced system prompt and structured output schema
65const completion = await openai.beta.chat.completions.parse({
66model: "gpt-4o",
67messages: [
69{role: "user", content: extractPrompt + "\n\nResume Text:\n" + resumeText}
70],
71response_format: zodResponseFormat(OpenAICompatibleResumeSchema, 'parsedResume')
72})
737778if (!responseContent) {
79throw new Error("Empty response from OpenAI")
80}
818586console.error("JSON parsing error:", error)
87throw new Error("Failed to parse OpenAI response as valid JSON")
88}
89} catch (error) {
90console.error("OpenAI parsing error:", error)
91// Provide specific error message based on the error type
92if ((error as Error).message.includes("429")) {
93throw new Error("OpenAI rate limit exceeded. Please try again later.")
94} else if ((error as Error).message.includes("401") || (error as Error).message.includes("403")) {
95throw new Error("Authentication error with OpenAI API. Check your API key.")
96} else {
97throw new Error("Failed to parse resume with OpenAI: " + (error as Error).message)
98}
99}
101102/**
103* Validate extracted data using OpenAI
104*
105* @param data The extracted resume data to validate
108export async function validateResumeWithAI(data: ParsedResume): Promise<ParsedResume> {
109try {
110// Initialize OpenAI client
111const openai = new OpenAI()
112113// Get validation prompt
136Always return the complete JSON structure with your improvements.`
137138console.log("Calling OpenAI API for validation and standardization...")
139140141// Call OpenAI API with enhanced validation
142const completion = await openai.beta.chat.completions.parse({
143model: "gpt-4o",
144messages: [
146{role: "user", content: validationPrompt + "\n\nResume Data:\n" + JSON.stringify(data)}
147],
148response_format: zodResponseFormat(OpenAICompatibleResumeSchema, 'validResume')
149})
150154155if (!responseContent) {
156throw new Error("Empty validation response from OpenAI")
157}
158165}
166} catch (error) {
167console.error("OpenAI validation error:", error)
168console.warn("Using original data due to validation API error")
169// Return original data if validation API call fails
173174/**
175* Helper function to check if OpenAI extraction result is valid
176* and retry if necessary with a different prompt strategy
177*
198console.log("Initial extraction had issues, attempting retry with different strategy...")
199200// Initialize OpenAI client
201const openai = new OpenAI()
202203// Create a simplified extraction prompt focused on missing data
214215216// Call OpenAI API with retry strategy
217const completion = await openai.beta.chat.completions.parse({
218model: "gpt-4o",
219messages: [
230Please provide a complete and corrected JSON response following the exact same schema.` }
231],
232response_format: zodResponseFormat(OpenAICompatibleResumeSchema, 'retriedResume')
233})
234254255/**
256* Convert simplified OpenAI schema format to full ParsedResume format with confidence fields
257* @param simplified Simplified resume data returned from OpenAI
258* @returns Fully structured resume data with confidence fields
259*/
ab457573e37_.cursorrules4 matches
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107messages: [
108{ role: "user", content: "Say hello in a creative way" },