Skip to content

Conversation

@scotbrew
Copy link

@scotbrew scotbrew commented Dec 9, 2025

Description of changes

Create new Gemini google.genai example (examples/gemini-genai)
This is a new example script that uses the newer google.genai API, based on the existing examples/gemini example that uses the older google.generativeai API. Full change history of the modifications retained.

  • Improvements & Bug fixes
    • Update from google.generativeai to google.genai
    • Use env variable GOOGLE_API_KEY for the api_key
    • Fix document loading logic issues, if interrupted.
    • Add single and batch document loading methods
    • Make document loading batch processing more flexible and robust
    • Separate out the embed model from the query model
    • Reduce the batch size so it will better work with Google Free Tier.
    • Revise output to more explicitly separate the collection closest documents from the LLM query.

Fixes: #5998

Test plan

Example scripts tested locally.

pip install -r requirements.txt
python load_data.py
python main.py

Migration plan

N/A

Observability plan

N/A

Documentation Changes

No

Clone examples/gemini/ -> examples/gemini-genai/ as a starting point for modifying the code to use newer google.genai instead of older google.generativeai
* Update from google.generativeai to google.genai
* Use env variable GOOGLE_API_KEY for the api_key
* Fix document loading logic issues, if interrupted.
* Add single and batch document loading methods
* Make document loading batch processing more flexible and robust
* Separate out the embed model from the query model
* Reduce the batch size so it will better work with Google Free Tier.
* Revise output to more explicitly separate the collection closest documents from the LLM query.
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Dec 9, 2025

Add google.genai-based Gemini example with robust data loader

Adds a new examples/gemini-genai sample that mirrors the existing Gemini demo but targets the google.genai client. The scripts load the bundled 2022/2023 U.S. State of the Union texts into Chroma, then run conversational retrieval with separate embedding and generative models, updated batching/resume logic, and clearer console output. Supporting updates include a dedicated requirements file, README walkthrough, and a .gitignore rule for persisted collections.

Key Changes

• Introduce examples/gemini-genai with updated main.py that queries google.genai, separates embed/query models, and improves console diagnostics.
• Rewrite load_data.py to batch inserts, resume interrupted loads safely, and prompt for GOOGLE_API_KEY when absent.
• Document usage in examples/gemini-genai/README.md, add Python dependencies in examples/gemini-genai/requirements.txt, and ignore generated chroma_storage/ directories.

Affected Areas

• examples/gemini-genai/main.py
• examples/gemini-genai/load_data.py
• examples/gemini-genai/README.md
• examples/gemini-genai/requirements.txt
• .gitignore

This summary was automatically generated by @propel-code-bot

@scotbrew scotbrew changed the title Add examples/gemini-genai script example [DOC] Add examples/gemini-genai script example Dec 10, 2025
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.

[Feature Request]: Create google.genai example

1 participant