phidatahq / phidata

Build AI Assistants with memory, knowledge and tools.
https://docs.phidata.com
Mozilla Public License 2.0
10.47k stars 1.51k forks source link

Using Gemini from Google AI Studio #952

Open LuciAkirami opened 1 month ago

LuciAkirami commented 1 month ago

I wish to use the Gemini model through the free API Key provided by the Google AI Studio. But I could not find a way to do so in phidata. The existing Gemini Integration requires me go through the GCP Vertex AI process. So is there such a way, where I could work with Gemini with the free API key in the existing phidata library?

jacobweiss2305 commented 1 month ago

Taking a look!

sigren commented 1 month ago

Please!

FriendlyUser commented 4 weeks ago

Also interested in this.

alvinchiang1121 commented 3 weeks ago

Do we have an answer yet?

ysolanky commented 3 weeks ago

Really sorry about the delay on this. Will have an update by the next of next week at the latest

ysolanky commented 1 day ago

A PR for Gemini using Google AI studio is out. Everyone is welcome to test: https://github.com/phidatahq/phidata/pull/1044

sigren commented 1 day ago

gemini-1.5-pro returns JSON with control characters; should deal with this in a way that's similar to Anthropic models by being less strict in JSON parsing:

WARNING Failed to validate response: 1 validation error for ExplainAnswer Invalid JSON: control character (\u0000-\u001F) found while parsing a string at line 4 column 0 [type=json_invalid, input_value='{\n "answer": "C",\n "..."string"\n }\n }\n}', input_type=str]

ysolanky commented 18 hours ago

@sigren can you please share the steps to recreate this warning?

sigren commented 4 hours ago

@ysolanky my particular example is very complicated with tool use, RAG and chain of thoughts. Quite often structured (JSON) response from models by Anthropic and Gemini contain control characters. This issue was fixed in "instructor" library by parsing JSON string in non-strict mode.