94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
1# BeeGPT - Bee-Themed AI Assistant
2
3A fun, bee-themed wrapper for OpenAI's GPT models that adds bee personality, puns, and facts to AI responses, plus a bee-themed image generator.
4
5## Features
13## How It Works
14
15BeeGPT uses OpenAI's API to generate responses and images, but adds a bee-themed personality layer through prompt engineering. The system includes:
16
171. A backend API that communicates with OpenAI
182. A bee-themed prompt that instructs the AI to respond with bee-related content
193. A bee-themed image generator that enhances prompts with bee elements
35
36- Built on Val Town
37- Uses OpenAI's GPT models (gpt-4o-mini for chat)
38- Uses OpenAI's DALL-E 3 for image generation
39- Frontend built with HTML, CSS, and vanilla JavaScript
40- Styled with Tailwind CSS via CDN
49## Environment Variables
50
51This project requires an OpenAI API key to be set in your Val Town environment variables.
52
53## License
359 <footer class="bg-yellow-500 text-black p-3 text-center text-sm">
360 <p>
361 BeeGPT - Powered by OpenAI | <a
362 href="https://val.town"
363 target="_top"
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// Bee-themed personality prompt
62 }
63
64 // Call OpenAI with bee persona
65 const completion = await openai.chat.completions.create({
66 model: "gpt-4o-mini",
67 messages: [
110 try {
111 // Generate image using DALL-E
112 const response = await openai.images.generate({
113 model: "dall-e-3",
114 prompt: enhancedPrompt,
119 });
120
121 console.log("OpenAI response:", JSON.stringify(response));
122
123 const imageUrl = response.data[0]?.url;
124
125 if (!imageUrl) {
126 throw new Error("No image URL returned from OpenAI");
127 }
128
136 },
137 );
138 } catch (openaiError) {
139 console.error("OpenAI API Error:", openaiError);
140
141 // Check if it's a content policy violation
142 if (openaiError.message && openaiError.message.includes("content policy")) {
143 return new Response(
144 JSON.stringify({
145 error: "Your image request was rejected due to content policy. Please try a different prompt.",
146 details: openaiError.message,
147 }),
148 {
154
155 // Check if it's a rate limit error
156 if (openaiError.message && openaiError.message.includes("rate limit")) {
157 return new Response(
158 JSON.stringify({
159 error: "Rate limit exceeded. Please try again later.",
160 details: openaiError.message,
161 }),
162 {
167 }
168
169 throw openaiError; // Re-throw for general error handling
170 }
171 } catch (error) {
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// Bee-themed personality prompt
62 }
63
64 // Call OpenAI with bee persona
65 const completion = await openai.chat.completions.create({
66 model: "gpt-4o-mini",
67 messages: [
110 try {
111 // Generate image using DALL-E
112 const response = await openai.images.generate({
113 model: "dall-e-3",
114 prompt: enhancedPrompt,
119 });
120
121 console.log("OpenAI response:", JSON.stringify(response));
122
123 const imageUrl = response.data[0]?.url;
124
125 if (!imageUrl) {
126 throw new Error("No image URL returned from OpenAI");
127 }
128
136 },
137 );
138 } catch (openaiError) {
139 console.error("OpenAI API Error:", openaiError);
140
141 // Check if it's a content policy violation
142 if (openaiError.message && openaiError.message.includes("content policy")) {
143 return new Response(
144 JSON.stringify({
145 error: "Your image request was rejected due to content policy. Please try a different prompt.",
146 details: openaiError.message,
147 }),
148 {
154
155 // Check if it's a rate limit error
156 if (openaiError.message && openaiError.message.includes("rate limit")) {
157 return new Response(
158 JSON.stringify({
159 error: "Rate limit exceeded. Please try again later.",
160 details: openaiError.message,
161 }),
162 {
167 }
168
169 throw openaiError; // Re-throw for general error handling
170 }
171 } catch (error) {
236export default async function server(request: Request): Promise<Response> {
237 if (request.method === "POST") {
238 const { OpenAI } = await import("https://esm.town/v/std/openai");
239 const openai = new OpenAI();
240
241 const { question } = await request.json();
242
243 const completion = await openai.chat.completions.create({
244 messages: [
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";
4
5const openai = new OpenAI();
6
7/**
197 `;
198
199 const completion = await openai.chat.completions.create({
200 messages: [{ role: "user", content: prompt }],
201 model: "gpt-4o-mini",
1import { OpenAI } from "https://esm.town/v/std/openai";
2import type { ParsedResumeData } from "../shared/types";
3
4const openai = new OpenAI();
5
6/**
7 * Parses resume text using OpenAI to extract structured information
8 */
9export async function parseResume(resumeText: string): Promise<ParsedResumeData> {
48 `;
49
50 const completion = await openai.chat.completions.create({
51 messages: [{ role: "user", content: prompt }],
52 model: "gpt-4o-mini",
57 const content = completion.choices[0]?.message?.content;
58 if (!content) {
59 throw new Error("Failed to get a response from OpenAI");
60 }
61
104 `;
105
106 const completion = await openai.chat.completions.create({
107 messages: [{ role: "user", content: prompt }],
108 model: "gpt-4o-mini",
113 const content = completion.choices[0]?.message?.content;
114 if (!content) {
115 throw new Error("Failed to get a response from OpenAI");
116 }
117
5## Features
6
7- Resume text analysis using OpenAI's GPT models
8- Keyword extraction and skills matching
9- Candidate scoring and ranking
40## Technologies Used
41
42- OpenAI API for natural language processing
43- SQLite for data storage
44- Hono for backend API