mirror of
https://github.com/ollama/ollama-python.git
synced 2026-07-21 09:05:23 -04:00
Tool call doesn't honor the function definition when responding #194
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @2b3pro on GitHub (Dec 30, 2024).
Given this parameter definition in the function def:
'parameters': {'type': 'object', 'properties': {'weight_kg': {'type': 'number', 'description': 'Weight in kilograms'}, 'height_m': {'type': 'number', 'description': 'Height in meters'}}…The result is:
tool_call=Function(name='calculate_bmi', arguments={'height_m': '1.78', 'weight_kg': '78'})…where the numbers are converted to strings. They should be numbers (floats).
@ParthSareen commented on GitHub (Jan 2, 2025):
This is a common issue that I've seen occur - especially with smaller models. We are possibly looking to do sampling with grammars to get structured tools back, however for now I'd recommend either using a larger model or adding type safety + retries. So you could do just do
float(value)before passing it into the function