35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from micro_agents.conversation import Conversation, ReasoningMessage, ToolCallMessage, ToolCallResponseMessage, UserMessage
|
|
|
|
from llm_trade_bot.zai_llm import ZaiLLM
|
|
|
|
|
|
def test_serializes_glm_tool_round_in_chat_completions_format():
|
|
conversation = Conversation(
|
|
[
|
|
UserMessage("analyse BTC"),
|
|
ReasoningMessage("I need market data."),
|
|
ToolCallMessage("call-1", "get_market_data", {"symbol": "BTCUSDT"}),
|
|
ToolCallResponseMessage("call-1", '{"last_price":"100000"}'),
|
|
]
|
|
)
|
|
|
|
messages = ZaiLLM._serialize_conversation(conversation, "Follow the risk limits.")
|
|
|
|
assert messages == [
|
|
{"role": "system", "content": "Follow the risk limits."},
|
|
{"role": "user", "content": "analyse BTC"},
|
|
{
|
|
"role": "assistant",
|
|
"content": None,
|
|
"reasoning_content": "I need market data.",
|
|
"tool_calls": [
|
|
{
|
|
"id": "call-1",
|
|
"type": "function",
|
|
"function": {"name": "get_market_data", "arguments": '{"symbol":"BTCUSDT"}'},
|
|
}
|
|
],
|
|
},
|
|
{"role": "tool", "tool_call_id": "call-1", "content": '{"last_price":"100000"}'},
|
|
]
|