prithivMLmods commited on
Commit
6da23ac
·
verified ·
1 Parent(s): 25039b1

update app

Browse files
Files changed (1) hide show
  1. Home.tsx +6 -9
Home.tsx CHANGED
@@ -425,16 +425,13 @@ export default function Home() {
425
  const response = await ai.models.generateContent({
426
  model: 'gemini-2.5-flash-image',
427
  contents: {parts},
428
- config: {
429
- responseMimeType: 'application/json',
430
- },
431
  });
432
 
433
  let foundImage = false;
434
- const parsedResponse = JSON.parse(response.text);
435
 
436
- if(parsedResponse.candidates && parsedResponse.candidates[0].content.parts) {
437
- for (const part of parsedResponse.candidates[0].content.parts) {
438
  if (part.inlineData) {
439
  const imageUrl = `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`;
440
  setResultImages([imageUrl]);
@@ -445,7 +442,7 @@ export default function Home() {
445
  }
446
 
447
  if (!foundImage) {
448
- const textMessage = parsedResponse.text;
449
  setErrorMessage(
450
  textMessage ||
451
  'The model did not return an image. Please try a different prompt.',
@@ -691,7 +688,7 @@ export default function Home() {
691
  <div className="info-tooltip-container">
692
  <Info className="w-4 h-4 info-icon" />
693
  <span className="info-tooltip">
694
- The model used for this mode is <code>imagen-3.0-generate-001</code>.
695
  </span>
696
  </div>
697
  )}
@@ -699,7 +696,7 @@ export default function Home() {
699
  <div className="info-tooltip-container">
700
  <Info className="w-4 h-4 info-icon" />
701
  <span className="info-tooltip">
702
- The model used for image editing is <code>gemini-1.5-flash-latest</code>.
703
  </span>
704
  </div>
705
  )}
 
425
  const response = await ai.models.generateContent({
426
  model: 'gemini-2.5-flash-image',
427
  contents: {parts},
 
 
 
428
  });
429
 
430
  let foundImage = false;
431
+ const responseData = response;
432
 
433
+ if(responseData.candidates && responseData.candidates[0].content.parts) {
434
+ for (const part of responseData.candidates[0].content.parts) {
435
  if (part.inlineData) {
436
  const imageUrl = `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`;
437
  setResultImages([imageUrl]);
 
442
  }
443
 
444
  if (!foundImage) {
445
+ const textMessage = responseData.text;
446
  setErrorMessage(
447
  textMessage ||
448
  'The model did not return an image. Please try a different prompt.',
 
688
  <div className="info-tooltip-container">
689
  <Info className="w-4 h-4 info-icon" />
690
  <span className="info-tooltip">
691
+ The model used for this mode is <code>imagen-4.0-generate-001</code>.
692
  </span>
693
  </div>
694
  )}
 
696
  <div className="info-tooltip-container">
697
  <Info className="w-4 h-4 info-icon" />
698
  <span className="info-tooltip">
699
+ The model used for image editing is <code>gemini-2.5-flash-image</code>.
700
  </span>
701
  </div>
702
  )}