Open duccdev opened 4 days ago
Hi @duccdev
You need to set enable_automatic_function_calling
to True
to make it work.
def set_brightness(value: float) -> None:
"""Controls the brightness of all house lights. `value` is a `float` between 0 (off) and 1 (max)."""
print("Brightness changed:", value)
model = genai.GenerativeModel(
"gemini-1.5-flash-002",
tools=[set_brightness],
)
chat = model.start_chat(enable_automatic_function_calling=True)
while True:
stream = chat.send_message(input("User: "))
print("Model: ", end="", flush=True)
print(stream.text, end="", flush=True)
print()
Yes. Thanks for reporting!
Description of the bug:
I was playing around with tool use and streaming, this was my code:
I got this peculiar error when I prompted it like this:
I am currently using Python 3.13, latest version of the SDK. This is not an issue on my part as this seems to be a typo in the library.
Actual vs expected behavior:
Actual:
Expected (roughly):
Any other information you'd like to share?
Simply change the typo at
types/generation_types.py
, line 536, from.whichOneof
to.WhichOneof
.