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

fix: replaced deepseek api call with gemini #143

Merged
merged 1 commit into from
Feb 11, 2025
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
47 changes: 23 additions & 24 deletions frontend/src/app/insights/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,26 @@ export default function InsightsPage() {
const data = await response.json();
setInsights(data.insights);

// Get scores from database
const scoresResponse = await fetch(`/api/tests/${testId}/progress`);
if (!scoresResponse.ok) {
throw new Error("Failed to fetch scores");
}
const scoresData = await scoresResponse.json();
const { scores } = scoresData;
setScores(scoresData.scores);

// Get public figure match
const figureResponse = await fetch('/api/public-figures');
if (!figureResponse.ok) {
throw new Error("Failed to fetch public figure match");
}
const figureData = await figureResponse.json();
setPublicFigure(figureData.celebrity || 'Unknown Match');
// Get scores from database
const scoresResponse = await fetch(`/api/tests/${testId}/progress`);
if (!scoresResponse.ok) {
throw new Error("Failed to fetch scores");
}
const scoresData = await scoresResponse.json();
const { scores } = scoresData;
setScores(scoresData.scores);

// Get public figure match
const figureResponse = await fetch('/api/public-figures');
if (!figureResponse.ok) {
throw new Error("Failed to fetch public figure match");
}
const figureData = await figureResponse.json();
setPublicFigure(figureData.celebrity || 'Unknown Match');

// Call DeepSeek API for full analysis
// Call Gemini API for full analysis (Pro users only)
if (isProUser) {
const deepSeekResponse = await fetch("/api/deepseek", {
const geminiResponse = await fetch("/api/gemini-flash", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -98,13 +98,13 @@ export default function InsightsPage() {
}),
});

if (deepSeekResponse.status === 200) {
const deepSeekData = await deepSeekResponse.json();
setFullAnalysis(deepSeekData.analysis);
if (geminiResponse.status === 200) {
const geminiData = await geminiResponse.json();
setFullAnalysis(geminiData.analysis);
} else {
console.error(
"Error fetching DeepSeek analysis:",
deepSeekResponse.statusText,
"Error fetching Gemini analysis:",
geminiResponse.statusText,
);
setFullAnalysis(
"Failed to generate analysis. Please try again later.",
Expand Down Expand Up @@ -138,7 +138,6 @@ export default function InsightsPage() {
const downloadImage = () => {
if (!canvasRef.current) return;
try {

const canvas = canvasRef.current;
const dataUrl = canvas.toDataURL('image/png');
const link = document.createElement('a');
Expand Down
Loading