Pulastya B commited on
Commit
943877f
·
1 Parent(s): 0310ce5

fix: Correct ToolCall object structure for Gemini text parser

Browse files

- Use tool_call.name instead of tool_call.function.name
- Use tool_call.args (dict) instead of tool_call.function.arguments (JSON string)
- Match expected structure at line 1543
- Fixes: AttributeError 'ToolCall' object has no attribute 'name'

Files changed (1) hide show
  1. src/orchestrator.py +4 -5
src/orchestrator.py CHANGED
@@ -1489,14 +1489,13 @@ You are a DOER. Complete workflows based on user intent."""
1489
  # Parse tool calls from text using JSON blocks or function syntax
1490
  parsed_calls = self._parse_text_tool_calls(text_response)
1491
  if parsed_calls:
1492
- # Convert to tool_call objects matching Groq format
1493
  for call in parsed_calls:
 
1494
  tool_call_obj = type('ToolCall', (), {
1495
  'id': call['id'],
1496
- 'function': type('Function', (), {
1497
- 'name': call['function']['name'],
1498
- 'arguments': call['function']['arguments']
1499
- })()
1500
  })()
1501
  tool_calls.append(tool_call_obj)
1502
 
 
1489
  # Parse tool calls from text using JSON blocks or function syntax
1490
  parsed_calls = self._parse_text_tool_calls(text_response)
1491
  if parsed_calls:
1492
+ # Convert to tool_call objects matching Gemini expected format
1493
  for call in parsed_calls:
1494
+ # Create object with attributes matching line 1543: tool_call.name and tool_call.args
1495
  tool_call_obj = type('ToolCall', (), {
1496
  'id': call['id'],
1497
+ 'name': call['function']['name'],
1498
+ 'args': json.loads(call['function']['arguments']) if isinstance(call['function']['arguments'], str) else call['function']['arguments']
 
 
1499
  })()
1500
  tool_calls.append(tool_call_obj)
1501