Skip to content

Conversation

Copy link

Copilot AI commented Nov 18, 2025

The Gemini service was using incorrect API syntax for Google Search grounding (tools='google_search_retrieval'), causing "Unknown field for FunctionDeclaration" errors. Additionally, responses contained AI-generated formatting (bullets, markdown) and variable length output unsuitable for UI display.

Changes

Backend: gemini_service.py

  • Upgraded google-generativeai 0.3.2 → 0.8.5 for correct API support
  • Fixed grounding initialization:
# Before
self.model = genai.GenerativeModel('gemini-2.0-flash-exp', tools='google_search_retrieval')

# After
google_search_tool = types.Tool(google_search_retrieval=genai.protos.GoogleSearchRetrieval())
self.model = genai.GenerativeModel('gemini-2.0-flash-exp', tools=[google_search_tool])
  • Added _format_response_to_sentences(): strips markdown/bullets, returns exactly 10 sentences
  • Applied formatting to fact_check_text() and fact_check_image() outputs

Frontend: ResultCard.tsx

  • Enhanced sentence parsing for improved readability
  • Changed <div> to <p> for semantic HTML

Example formatted output:

Raw: "**Verdict: True**\n\n* First point\n* Second point..."
Formatted: "Verdict: True First point Second point..." (exactly 10 sentences, no markdown)

Testing

  • CodeQL: no vulnerabilities
  • Verified formatting handles edge cases (empty, single, many sentences)
Original prompt

I have installed google-genai. Now implemnet gemini call with google search grounding. Final output to UI should be in 10 senetences. Format should look good. No star or AI generated bullet.

[Chronological Review: The conversation began with the user requesting to connect to their private GitHub repository and pull code. The user then shifted focus to running React code from the frontend, opting to use a package manager. The user encountered issues with the command `npm run dev`, leading to inquiries about its failure. The conversation progressed to debugging login issues from the frontend, where the user provided detailed error messages related to bcrypt and FastAPI. The user requested the creation of demo user credentials for login and reported errors during image fact-checking, indicating a need for adjustments in API calls. The user also provided troubleshooting guides and documentation for resolving these issues. The latest requests involved implementing a Gemini call with Google search grounding and formatting the output for the UI.]

[Intent Mapping:

  1. "Connect to my private repo -https://github.com/DevDaring/Fact_Checker.git and pull all codes." - User wants to access their repository.
  2. "Run react code from frontend." - User aims to execute frontend code.
  3. "Why this command is not working - npm run dev." - User seeks to understand a command failure.
  4. "Check and tell me why I can execute npm run dev on frontend folder?" - User requests troubleshooting for command execution.
  5. "Look why these issue occur when I tried to login from frontend..." - User needs help with login errors.
  6. "Create a User credential so that I can login." - User wants demo credentials for testing.
  7. "Getting this error - Error processing fact-check..." - User reports an error during image processing.
  8. "Read Document.md and understand how to handle this issue then fix it." - User requests a review of documentation to resolve an issue.
  9. "I have installed google-genai. Now implement gemini call with google search grounding." - User wants to implement a specific API call and format the output.]

[Technical Inventory:

  • Technologies: React, FastAPI, bcrypt, Google Gemini API.
  • Tools: npm (Node Package Manager), GitHub for version control.
  • Frameworks: FastAPI for backend services, React for frontend development.
  • Error Handling: User is dealing with issues related to API calls and authentication.]

[Code Archaeology:

  • Files Discussed:
    • d:\Contest\Fact_Checker\trouble.md: Contains troubleshooting information.
    • d:\Contest\Fact_Checker\Data\users.csv: User mentioned changes made to this file.
    • d:\Contest\Fact_Checker\frontend\src\pages\Login.tsx: User made edits to this file.
  • Functions/Classes:
    • AuthService.authenticate_user: Used for user authentication.
    • AuthService.verify_password: Verifies user passwords using bcrypt.]

[Progress Assessment:

  • Completed Tasks: User has installed google-genai.
  • Partially Complete Work: User is in the process of implementing the Gemini API call and resolving various errors related to image fact-checking and login functionality.]

[Context Validation: All critical information for continuation is captured, including user goals, error messages, and specific requests for implementation and troubleshooting.]

[Recent Commands Analysis:

  • Last Agent Commands: User requested to implement a Gemini call with Google search grounding and format the output.
  • Tool Results Summary: No specific tool results were provided for the last command, but the user is facing issues with API calls and formatting output.
  • Pre-Summary State: The agent was actively working on implementing the Gemini API call and addressing the formatting of the output when the token budget was exceeded.
  • Operation Context: These commands relate to the user's goal of enhancing the functionality of their application by integrating Google search capabilities and ensuring the output is user-friendly.]
1. Conversation Overview: - Primary Objectives: User aims to connect to their GitHub repository, run frontend code, troubleshoot errors, create demo credentials, and implement a Gemini API call with Google search grounding. - Session Context: The conversation has transitioned from repository access to debugging various issues related to running commands, user authentication, and API integration. - User Intent Evolution: The user has shifted focus from basic repository management to more complex issues involving API calls and error handling.
  1. Technical Foundation:
  • React: Frontend framework used for building the user interface.
  • FastAPI: Backend framework for handling API requests.
  • bcrypt: Library for hashing passwords.
  • Google Gemini API: Used for image fact-checking and search functionalities.
  1. Codebase Status:
  • File Name 1: trouble.md
    • Purpose: Contains troubleshooting information for various issues.
    • Current State: User is actively re...

Created from VS Code via the GitHub Pull Request extension.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 18, 2025 11:24
Co-authored-by: DevDaring <46132760+DevDaring@users.noreply.github.com>
Co-authored-by: DevDaring <46132760+DevDaring@users.noreply.github.com>
Co-authored-by: DevDaring <46132760+DevDaring@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement Gemini call with Google search grounding Fix Gemini Google Search grounding API and implement 10-sentence response formatting Nov 18, 2025
Copilot AI requested a review from DevDaring November 18, 2025 11:32
Copilot finished work on behalf of DevDaring November 18, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants