Spaces:
Running
Running
Download src/processor/response/formatter.py from Jakob08/moneychatbot: direct link, hf CLI and curl.
- Browser
- Download file 812 Bytes
-
https://huggingface.co/spaces/Jakob08/moneychatbot/resolve/main/src/processor/response/formatter.py
- Command line
-
hf download hf://spaces/Jakob08/moneychatbot/src/processor/response/formatter.py
-
curl -L -o formatter.py https://huggingface.co/spaces/Jakob08/moneychatbot/resolve/main/src/processor/response/formatter.py
812 Bytes
| # | |
| # SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org> | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # | |
| def assistant_response(response_message): | |
| extracted_tool_calls = [] | |
| if getattr(response_message, "tool_calls", None): | |
| for tool_call in response_message.tool_calls: | |
| extracted_tool_calls.append( | |
| { | |
| "id": tool_call.id, | |
| "type": "function", | |
| "function": { | |
| "name": tool_call.function.name, | |
| "arguments": tool_call.function.arguments | |
| } | |
| } | |
| ) | |
| return { | |
| "role": "assistant", | |
| "content": response_message.content or "", | |
| "tool_calls": extracted_tool_calls if extracted_tool_calls else None | |
| } |