Skip to content

Commit cc23893

Browse files
committed
fix
1 parent cb6d213 commit cc23893

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/agentlab/agents/react_toolcall_agent.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import json
22
import logging
33
import pprint
4-
import time
54
from dataclasses import dataclass
65
from functools import partial
76
from typing import Callable, Literal
87

98
from litellm import completion
10-
from litellm.types.utils import ChatCompletionMessageToolCall, Message, ModelResponse
9+
from litellm.types.utils import Message, ModelResponse
1110
from PIL import Image
1211
from termcolor import colored
1312

@@ -160,15 +159,8 @@ def action_from_message(self, message) -> ToolCallAction:
160159
if message.tool_calls:
161160
if len(message.tool_calls) > 1:
162161
logger.warning("Multiple tool calls found in LLM response, using the first one.")
163-
tool_call: ChatCompletionMessageToolCall = message.tool_calls[0]
164-
assert isinstance(tool_call.function.name, str)
165-
try:
166-
args = json.loads(tool_call.function.arguments)
167-
except json.JSONDecodeError as e:
168-
logger.exception(
169-
f"Error in json parsing of tool call arguments, {e}: {tool_call.function.arguments}"
170-
)
171-
raise e
162+
tool_call = message.tool_calls[0]
163+
args = json.loads(tool_call.function.arguments)
172164
action = ToolCallAction(
173165
id=tool_call.id, function=FunctionCall(name=tool_call.function.name, arguments=args)
174166
)

0 commit comments

Comments
 (0)