|
781 | 781 | "def _extract_tool(text:str)->tuple[dict,dict]:\n", |
782 | 782 | " \"Extract tool call and results from <details> block\"\n", |
783 | 783 | " d = json.loads(text.strip())\n", |
784 | | - " tc = ChatCompletionMessageToolCall(Function(dumps(d['call']['arguments']),d['call']['function']), d['id'],type='function')\n", |
785 | | - " tr = {'role': 'tool','tool_call_id': d['id'],'name': d['call']['function'], 'content': d['result']}\n", |
| 784 | + " call = d['call']\n", |
| 785 | + " func = call['function']\n", |
| 786 | + " tc = ChatCompletionMessageToolCall(Function(dumps(call['arguments']),func), d['id'])\n", |
| 787 | + " tr = {'role': 'tool','tool_call_id': d['id'],'name': func, 'content': d['result']}\n", |
786 | 788 | " return tc,tr\n", |
787 | 789 | "\n", |
788 | 790 | "def fmt2hist(outp:str)->list:\n", |
789 | 791 | " \"Transform a formatted output into a LiteLLM compatible history\"\n", |
790 | 792 | " lm,hist = Message(),[]\n", |
791 | 793 | " spt = re_tools.split(outp)\n", |
792 | | - " for txt,_,tooljson in list(chunked(spt, 3, pad=True)):\n", |
| 794 | + " for txt,_,tooljson in chunked(spt, 3, pad=True):\n", |
793 | 795 | " if txt.strip(): hist.append(lm:=Message(txt.strip()))\n", |
794 | 796 | " if tooljson:\n", |
795 | 797 | " tcr = _extract_tool(tooljson)\n", |
|
0 commit comments