236export default async function server(request: Request): Promise<Response> {
237if (request.method === "POST") {
238const { OpenAI } = await import("https://esm.town/v/std/openai");
239const openai = new OpenAI();
240241const { question } = await request.json();
242243const completion = await openai.chat.completions.create({
244messages: [
245{
7- `index.ts` - Main API entry point with Hono framework (HTTP trigger)
8- `database.ts` - SQLite database operations for storing resumes and job requirements
9- `parser.ts` - Resume parsing logic using OpenAI's GPT models
10- `scorer.ts` - Candidate scoring algorithms and feedback generation
11
1import { OpenAI } from "https://esm.town/v/std/openai";
2import type { Resume, JobRequirement, ScoringResult, ParsedResumeData } from "../shared/types";
3import { calculateSimilarity } from "../shared/utils";
45const openai = new OpenAI();
67/**
197`;
198199const completion = await openai.chat.completions.create({
200messages: [{ role: "user", content: prompt }],
201model: "gpt-4o-mini",
1import { OpenAI } from "https://esm.town/v/std/openai";
2import type { ParsedResumeData } from "../shared/types";
34const openai = new OpenAI();
56/**
7* Parses resume text using OpenAI to extract structured information
8*/
9export async function parseResume(resumeText: string): Promise<ParsedResumeData> {
48`;
4950const completion = await openai.chat.completions.create({
51messages: [{ role: "user", content: prompt }],
52model: "gpt-4o-mini",
57const content = completion.choices[0]?.message?.content;
58if (!content) {
59throw new Error("Failed to get a response from OpenAI");
60}
61104`;
105106const completion = await openai.chat.completions.create({
107messages: [{ role: "user", content: prompt }],
108model: "gpt-4o-mini",
113const content = completion.choices[0]?.message?.content;
114if (!content) {
115throw new Error("Failed to get a response from OpenAI");
116}
117
5## Features
67- Resume text analysis using OpenAI's GPT models
8- Keyword extraction and skills matching
9- Candidate scoring and ranking
40## Technologies Used
4142- OpenAI API for natural language processing
43- SQLite for data storage
44- Hono for backend API
untitled-2444index.ts10 matches
6import { SyntaxHighlighter } from "./components/SyntaxHighlighter.ts";
7import { DebugConsole } from "./components/DebugConsole.ts";
8import { OpenAIConnector } from "../shared/OpenAIConnector.ts";
9import { ThemeManager } from "./components/ThemeManager.ts";
10import { ConfettiManager } from "./components/ConfettiManager.ts";
18const syntaxHighlighter = new SyntaxHighlighter();
19const debugConsole = new DebugConsole();
20const openAIConnector = new OpenAIConnector();
21const themeManager = new ThemeManager();
22const confettiManager = new ConfettiManager();
27
28// Set up all event handlers
29setupFormHandling(tokenizer, scriptEditor, syntaxHighlighter, openAIConnector, confettiManager, textFormatter);
30setupTokenCounter(tokenizer);
31setupTemplateSelector(templateManager);
32setupAdvancedOptions(openAIConnector, debugConsole);
33setupResultActions(scriptEditor, textFormatter);
34setupHistoryModal(historyManager, scriptEditor);
51scriptEditor: ScriptEditor,
52syntaxHighlighter: SyntaxHighlighter,
53openAIConnector: OpenAIConnector,
54confettiManager: ConfettiManager,
55textFormatter: TextFormatter
144const apiKeyInput = document.getElementById("apiKey") as HTMLInputElement;
145if (apiKeyInput && apiKeyInput.value && localStorage.getItem("useDirectApi") === "true") {
146// Process directly with OpenAI API
147const prompt = createPromptForScriptType(
148text,
153);
154
155const response = await openAIConnector.createChatCompletion({
156model,
157messages: [{ role: "user", content: prompt }],
314315// Set up advanced options
316function setupAdvancedOptions(openAIConnector: OpenAIConnector, debugConsole: DebugConsole) {
317const advancedOptionsBtn = document.getElementById("advancedOptionsBtn") as HTMLButtonElement;
318const advancedOptions = document.getElementById("advancedOptions") as HTMLDivElement;
350
351if (!apiKey.startsWith("sk-")) {
352alert("Invalid API key format. OpenAI API keys start with 'sk-'");
353return;
354}
356try {
357// Set the API key in the connector
358openAIConnector.setApiKey(apiKey);
359
360// Store the preference (but not the key itself)
untitled-2444index.html2 matches
318<div class="md:col-span-3">
319<div class="flex items-center justify-between">
320<label for="apiKey" class="block text-sm font-medium text-gray-700 dark:text-gray-300">OpenAI API Key (Optional)</label>
321<span class="text-xs text-gray-500 dark:text-gray-400">Direct API connection</span>
322</div>
649
650<footer class="mt-8 text-center text-sm text-gray-500 dark:text-gray-400">
651<p>Powered by OpenAI GPT-4 • <a href="#" id="viewSourceLink" target="_top" class="text-indigo-600 dark:text-indigo-400 hover:underline">View Source</a></p>
652</footer>
653</div>
PRChecker2index.tsx1 match
16// Call AI service with your private API key
17// Replace with your actual AI service URL
18const aiResponse = await fetch("https://api.openai.com/v1/chat/completions", {
19method: "POST",
20headers: {
untitled-2444README.md10 matches
1# Script Improver Pro
23A Val Town application that processes large scripts through OpenAI's GPT-4 model to make them clearer, more concise, and better written.
45## Features
10- Combines processed outputs seamlessly
11- Simple, responsive UI with token counting and progress tracking
12- **Direct OpenAI API Connection** - Use your own API key for direct processing
13- **Debug Console** - View API requests, responses, and token usage
14- **Script Type Detection** - Automatically identifies screenplay, technical, marketing, academic, or creative content
211. The user pastes their script into the text area and provides optional instructions
222. The application splits the text into chunks of approximately 3330 tokens each
233. Each chunk is processed sequentially through OpenAI's GPT-4 model
244. The processed chunks are combined, handling overlaps to avoid duplication
255. The improved script is displayed to the user
2829- `/index.ts` - Main HTTP endpoint and route handler
30- `/backend/processor.ts` - Text processing logic and OpenAI integration
31- `/backend/openaiProxy.ts` - Server-side proxy for OpenAI API calls
32- `/backend/scriptTypeDetector.ts` - Automatic script type detection
33- `/shared/tokenizer.ts` - Advanced token counting and text chunking
34- `/shared/OpenAIConnector.ts` - Direct OpenAI API connection handling
35- `/frontend/index.html` - Main HTML template
36- `/frontend/index.ts` - Frontend JavaScript logic
42- **Backend**: Hono.js for HTTP routing
43- **Frontend**: Vanilla TypeScript with Tailwind CSS
44- **AI**: OpenAI GPT-4 for text processing
45- **Styling**: Tailwind CSS for responsive design
46- **Syntax Highlighting**: highlight.js for code highlighting
512. Select script type or use auto-detection
523. Choose an instruction template or write custom instructions
534. (Optional) Set your OpenAI API key for direct processing
545. Click "Improve Script" to process
556. View, compare, and download the improved script
5859### Direct API Connection
60You can use your own OpenAI API key for direct processing, bypassing the server proxy. This can be useful for:
61- Processing very large scripts
62- Using custom model parameters
80## Limitations
8182- Token counting is approximate and may not exactly match OpenAI's tokenizer
83- Very large scripts may take longer to process
84- The quality of improvements depends on the clarity of instructions and the quality of the input script
untitled-2444processor.ts10 matches
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { Tokenizer } from "../shared/tokenizer.ts";
3import { blob } from "https://esm.town/v/std/blob";
45// Use the standard OpenAI library for server-side processing
6const openai = new OpenAI();
7const tokenizer = new Tokenizer();
812const OVERLAP_TOKENS = 250;
1314// OpenAI model configuration
15const DEFAULT_MODEL = "gpt-4o";
16const DEFAULT_TEMPERATURE = 0.7;
1718/**
19* Process large text by splitting into chunks and sending to OpenAI
20*/
21export async function processLargeText(
71}
72
73// Process with OpenAI
74const processedChunk = await processChunkWithOpenAI(
75chunk,
76contextualInstructions,
287288/**
289* Process a single chunk with OpenAI
290*/
291async function processChunkWithOpenAI(
292chunk: string,
293instructions: string,
307for (let attempt = 0; attempt < 3; attempt++) {
308try {
309const completion = await openai.chat.completions.create({
310model: config.model,
311messages: [{ role: "user", content: prompt }],