Skip to content

Commit

Permalink
Merge pull request #56 from chenyuan99/feature/add-deepseek-model-sel…
Browse files Browse the repository at this point in the history
…ection
  • Loading branch information
XJerrY1029 authored Feb 6, 2025
2 parents 56db9d0 + 8e1f7ec commit 507510c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
33 changes: 29 additions & 4 deletions frontend/src/pages/JobGPT.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import React, { useState } from 'react';
import { FileText, Upload, ThumbsUp } from 'lucide-react';
import { jobgptService } from '../services/jobgptService';
import { JobGPTMode, JobGPTState } from '../types/jobgpt';
import { JobGPTMode, JobGPTState, DeepseekModel } from '../types/jobgpt';

const initialState: JobGPTState = {
mode: 'why_company', // Updated default mode
mode: 'why_company',
model: 'deepseek-coder-6.7b',
isLoading: false,
error: null,
input: '',
output: '',
};

const MODELS: DeepseekModel[] = [
'deepseek-coder-6.7b',
'deepseek-coder-33b'
];

export function JobGPT() {
const [state, setState] = useState<JobGPTState>(initialState);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
Expand All @@ -19,6 +25,10 @@ export function JobGPT() {
setState({ ...state, mode, input: '', output: '', error: null });
};

const handleModelChange = (model: DeepseekModel) => {
setState({ ...state, model });
};

const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setState({ ...state, input: e.target.value });
};
Expand All @@ -32,8 +42,8 @@ export function JobGPT() {
setState({ ...state, isLoading: true, error: null });

try {
const response = await jobgptService.generatePrompt(state.input, state.mode);
setState({ ...state, isLoading: false, output: response.response }); // Updated to use response instead of prompt
const response = await jobgptService.generatePrompt(state.input, state.mode, state.model);
setState({ ...state, isLoading: false, output: response.response });
} catch (error: any) {
setState({ ...state, isLoading: false, error: error.message });
}
Expand Down Expand Up @@ -96,6 +106,21 @@ export function JobGPT() {
General
</button>
</div>

<div className="mb-4">
<label className="block text-sm font-medium text-gray-700 mb-2">Model</label>
<select
className="w-full p-2 border rounded bg-white"
value={state.model}
onChange={(e) => handleModelChange(e.target.value as DeepseekModel)}
>
{MODELS.map(model => (
<option key={model} value={model}>
{model}
</option>
))}
</select>
</div>

<textarea
className="w-full h-32 p-2 border rounded mb-4"
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/services/jobgptService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import axios from 'axios';
import { JobGPTResponse, ResumeUploadResponse, JobGPTMode } from '../types/jobgpt';
import { JobGPTResponse, ResumeUploadResponse, JobGPTMode, DeepseekModel } from '../types/jobgpt';

const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';

export const jobgptService = {
generatePrompt: async (prompt: string, mode: JobGPTMode): Promise<JobGPTResponse> => {
generatePrompt: async (prompt: string, mode: JobGPTMode, model: DeepseekModel): Promise<JobGPTResponse> => {
try {
const response = await axios.post(`${API_URL}/api/jobgpt/prompt`, {
prompt,
mode
mode,
model
});
return response.data;
} catch (error: any) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types/jobgpt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type JobGPTMode = 'why_company' | 'behavioral' | 'general';
export type DeepseekModel = 'deepseek-coder-6.7b' | 'deepseek-coder-33b';

export interface JobGPTResponse {
response: string;
Expand All @@ -14,6 +15,7 @@ export interface ResumeUploadResponse {

export interface JobGPTState {
mode: JobGPTMode;
model: DeepseekModel;
isLoading: boolean;
error: string | null;
input: string;
Expand Down

0 comments on commit 507510c

Please sign in to comment.