Skip to content

Commit

Permalink
Merge pull request #143 from LazarusAA/gemini-flash-lite-api
Browse files Browse the repository at this point in the history
fix: replaced deepseek api call with gemini
  • Loading branch information
LazarusAA authored Feb 11, 2025
2 parents fdbf19b + 34e31bd commit 06401e9
Showing 1 changed file with 23 additions and 24 deletions.
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

0 comments on commit 06401e9

Please sign in to comment.