Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/services/aiService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AIPrompt } from '../types';
import { saveAIResponse } from './storageService';
import { saveAIResponse, getUserProfile } from './storageService';

// Model configuration
const MODEL = 'mistralai/Mistral-7B-Instruct-v0.2';
Expand Down Expand Up @@ -32,8 +32,9 @@ export function getResumeData(): string | null {
/**
* Check if resume has been uploaded
*/
export function hasResume(): boolean {
return resumeData !== null;
export async function hasResume(): Promise<boolean> {
const profile = await getUserProfile();
return !!profile.resumeData;
}

/**
Expand All @@ -45,8 +46,8 @@ export async function generateAIResponse(
userProfile: any
): Promise<string> {
try {
if (!hasResume()) {
throw new Error('Please upload your resume first before generating responses');
if (!await hasResume()) {
throw new Error('Please upload your resume in your profile settings before generating responses');
}

console.log('Generating AI response for question:', question);
Expand All @@ -68,7 +69,7 @@ export async function generateAIResponse(
- Skills: ${userProfile.skills}

Resume content:
${resumeData}
${userProfile.resumeData}
`;

// Make the API call to Hugging Face
Expand Down
Loading