1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { OpenAI } from "https://esm.town/v/std/openai";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5
32 }
33
34 const openai = new OpenAI();
35
36 try {
37 const completion = await openai.chat.completions.create({
38 model: "gpt-4o-mini",
39 messages: [
67 enhancedPrompt
68 });
69 } catch (openaiError) {
70 console.error("OpenAI API error:", openaiError);
71 return c.json({
72 error: "OpenAI service error",
73 message: "There was an issue with the AI service. Please try again later."
74 }, 503);
6
7- Simple, clean interface for entering prompts
8- AI-powered enhancement using OpenAI
9- Before/after comparison
10- Copy-to-clipboard functionality
151. Enter your basic prompt in the input area
162. Click "Enhance Prompt"
173. The application uses OpenAI to analyze and improve your prompt
184. View the enhanced version and copy it for use with your preferred AI system
19
21
22- Frontend: HTML, JavaScript with Tailwind CSS for styling
23- Backend: TypeScript API using Hono framework and OpenAI integration
24- Deployed on Val Town
25
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
50 }
51
52 const openai = new OpenAI();
53
54 // Create different prompts based on the content type
65 }
66
67 const completion = await openai.chat.completions.create({
68 messages: [
69 {
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { LicenseInfo, ScanResponse } from "../shared/types.ts";
125 const dataURI = `data:${imageFile.type};base64,${base64Image}`;
126
127 // Process with OpenAI
128 const licenseInfo = await extractLicenseInfo(dataURI);
129
183
184/**
185 * Extracts license information from an image using OpenAI's Vision capabilities
186 */
187async function extractLicenseInfo(imageDataUri: string): Promise<LicenseInfo> {
188 const openai = new OpenAI();
189
190 const response = await openai.chat.completions.create({
191 model: "gpt-4o",
192 messages: [
242 return JSON.parse(jsonString) as LicenseInfo;
243 } catch (error) {
244 console.error("Error parsing OpenAI response:", error);
245 return { rawText: content };
246 }
108
109 <footer class="mt-12 text-center text-sm text-gray-500">
110 <p>This application processes images using OpenAI's API. Images are not stored permanently.</p>
111 <p class="mt-1">
112 <a
16
171. Upload an image of a driver's license
182. The application uses OpenAI's Vision capabilities to analyze the image
193. The extracted information is returned in a structured JSON format
20
33## Privacy Notice
34
35This application processes images using OpenAI's API. Images are not stored permanently but are transmitted to OpenAI for processing. Please ensure you have appropriate consent before uploading any personal identification documents.
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3
4// Initialize OpenAI client
5const openai = new OpenAI();
6
7// Medical analysis prompt to guide the AI
66 const dataURI = `data:${imageFile.type};base64,${base64Image}`;
67
68 // Send the image to OpenAI for analysis
69 const response = await openai.chat.completions.create({
70 model: "gpt-4-vision-preview",
71 messages: [
90 });
91
92 // Extract the analysis from OpenAI's response
93 const analysis = response.choices[0]?.message?.content || "Analysis failed";
94
12
131. Users upload a medical image through the web interface
142. The image is sent to OpenAI's Vision API with specific medical analysis prompts
153. The AI analyzes the image and provides potential diagnoses or observations
164. Results are displayed to the user
20- Frontend: HTML, JavaScript, and TailwindCSS for styling
21- Backend: TypeScript with Val Town's HTTP trigger
22- AI: OpenAI's Vision API for image analysis
23
24## Limitations
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
45 }
46
47 const openai = new OpenAI();
48
49 // Prepare messages with history and enhanced system prompt
66 ];
67
68 const completion = await openai.chat.completions.create({
69 messages,
70 model: "gpt-4o-mini",
80 <footer class="mt-8 text-center text-gray-500 text-sm">
81 <p>
82 Digital 3D AI Teacher - Powered by OpenAI and Three.js
83 <br>
84 <a id="view-source" href="#" target="_top" class="text-indigo-500 hover:underline">View Source</a>