PrefectHQ / ControlFlow

🦾 Take control of your AI agents
https://controlflow.ai
Apache License 2.0
746 stars 53 forks source link

Gemini-flash-1.5 input format error #253

Closed candlep closed 1 month ago

candlep commented 3 months ago

Description

It looks like the format the Gemini model expects has changed and this causes an error.

site-packages/langchain_google_genai/chat_models.py", line 188, in _chat_with_retry
    raise ChatGoogleGenerativeAIError(
langchain_google_genai.chat_models.ChatGoogleGenerativeAIError: Invalid argument provided to Gemini: 400 * GenerateContentRequest.contents: contents is not specified
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[1].parameters.properties[message].type: must be specified

Example Code

from dotenv import load_dotenv
import os
from langchain_google_genai import ChatGoogleGenerativeAI

import controlflow as cf

load_dotenv(verbose=True, override=True)

os.environ["GOOGLE_API_KEY"] = os.environ.get('GOOGLE_API_KEY')

cf.default_model = ChatGoogleGenerativeAI(
    model="gemini-1.5-flash",
    temperature=0,
    max_tokens=None,
    timeout=None,
    max_retries=2,
)

# provide the model to an agent
agent = cf.Agent(name="writer")

# assign the agent to a task
task = cf.Task('Write a short poem about LLMs', agents=[agent])

# (optional) run the task
task.run()

### Version Information

```Text
controlflow==0.8.2

Additional Context

No response

jlowin commented 1 month ago

I believe this was solved in the 0.9x versions, as the example code works now, but please let me know if not! 0.9x included a new compilation pipeline for per-provider formatting.