Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deepseek model selection #56

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
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
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
Loading