Open arthberman opened 1 week ago
@arthberman
I believe the problem seems to be that trustcall
is sending the tool
in the open ai function format (with type=function, and function keys), not directly as the base model, which fails the validation in convert_to_openai_function
. Here is the relevant trustcall
code.
Here is a small change to _format_tools
in ChatBedrockConverse
, that should fix the error. I still see some keys with 'UNKNOWN' values in response, so we might need to look at this more deeply.
def _format_tools(
tools: Sequence[Union[Dict[str, Any], TypeBaseModel, Callable, BaseTool],],
) -> List[Dict[Literal["toolSpec"], Dict[str, Union[Dict[str, Any], str]]]]:
formatted_tools: List = []
for tool in tools:
if isinstance(tool, dict) and "toolSpec" in tool:
formatted_tools.append(tool)
else:
if isinstance(tool, dict) and "function" in tool:
tool = tool["function"]
spec = convert_to_openai_function(tool)
if not spec["description"]:
spec["description"] = spec["name"]
spec["inputSchema"] = {"json": spec.pop("parameters")}
formatted_tools.append({"toolSpec": spec})
return formatted_tools
Here is the output after the change.
{
"pertinent_user_preferences": {
"communication_preferences": {
"telegram": {
"preferred_encoding": [
{
"preference": "Morse code",
"sentence_preference_revealed": "Customer prefers Morse code for encoding the telegram."
}
],
"favorite_telegram_operators": [
{
"preference": "<UNKNOWN>",
"sentence_preference_revealed": "No specific favorite telegram operator mentioned."
}
],
"preferred_telegram_paper": [
{
"preference": "Daredevil",
"sentence_preference_revealed": "Customer agrees to use 'Daredevil' paper for the telegram."
}
]
},
"morse_code": {
"preferred_key_type": [
{
"preference": "straight key",
"sentence_preference_revealed": "Customer expresses love for using a straight key for Morse code."
}
],
"favorite_morse_abbreviations": [
{
"preference": "<UNKNOWN>",
"sentence_preference_revealed": "No specific favorite Morse abbreviations mentioned."
}
]
},
"semaphore": {
"preferred_flag_color": [
{
"preference": "<UNKNOWN>",
"sentence_preference_revealed": "No information provided about semaphore flag color preferences."
}
],
"semaphore_skill_level": [
{
"preference": "<UNKNOWN>",
"sentence_preference_revealed": "No information provided about semaphore skill level."
}
]
}
},
"trust_fall_preferences": {
"preferred_fall_height": [
{
"preference": "higher",
"sentence_preference_revealed": "Customer expresses readiness for a higher fall in the trust fall exercise."
}
],
"trust_level": [
{
"preference": "high",
"sentence_preference_revealed": "Customer shows a high level of trust by being ready for a higher fall."
}
],
"preferred_catching_technique": [
{
"preference": "diamond formation",
"sentence_preference_revealed": "Customer prefers the diamond formation for catching during the trust fall."
}
]
}
}
}
It's working fine with ChatOpenAI but it seems not compatible with ChatBedrockConverse, any help on that ?
Many thks, really appreciate this lib :)