New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool using with gemini #160
Comments
It looks to be on the model's side, it returns an empty response like
We can probably raise a ValueError when there are no candidates in the response, wdyt? |
@lkuligin Are we able to rule out the integration? Is it easy to reproduce with the vertex SDK directly? Could it be that we're sending some incorrect data via the integration and the API isn't validating inputs properly and then failing to produce a response? |
@eyurtsev I've reproduced it with the native SDK only and raised an issue internally. |
@lkuligin I've noticed that in the streaming context, we seem to consistently get an IndexError if we try to invoke a tool in a sequence more than two times. Here is an example: import random
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.tools import tool
from langchain_google_vertexai import ChatVertexAI
instructions = (
"You are using a translation machine. "
"You will be given a string. Input the characters one at a "
"time into the machine. The machine will give you output for "
"each character. When finished, provide the final output. "
"For example, if the string is 'abc', you must input the "
"letters 'a', 'b', and 'c' one at a time and in that order. "
"The responses may be, for example, 'z', 'x', 'q'. You will then "
"report the final output as 'zxq'. "
"\n\n {input}"
)
prompt = ChatPromptTemplate.from_messages(
[
("human", instructions),
MessagesPlaceholder("agent_scratchpad"),
]
)
model = ChatVertexAI(model_name="gemini-1.5-pro-preview-0409")
@tool
def type_letter(letter: str) -> str:
"""Type the given letter."""
alphabet = "abcdefghijklmnopqrstuvwxyz"
return alphabet[random.randint(0, 25)]
tools = [type_letter]
agent = create_tool_calling_agent(model, tools, prompt)
executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True,
) res = executor.invoke({"input": "type this: 'ba'"}) # works (agent reports output) res = executor.invoke({"input": "type this: 'bat'"}) # hits IndexError If this is expected, one option is to return a message at this point, e.g., in #162 |
This seems to fail 50% with no completions from the server
The text was updated successfully, but these errors were encountered: