Fix compilation errors and test failures after merge (issue #140)
- Update ollama_client.cpp to use std::expected pattern for parse_json_safely - Add missing 'index' field to tool_calls in add_message_field helper - Add missing 'index' field to test_edit_history_assistant_with_tool_calls test data
This commit is contained in:
@@ -133,12 +133,13 @@ std::expected<Message, std::string> OllamaClient::chat(const std::vector<Message
|
||||
sum = sum.substr(sum.find("\n\n")+2);
|
||||
|
||||
//std::cerr << new_packet << std::endl;
|
||||
auto j = parse_json_safely(new_packet.substr(6));
|
||||
if (j.is_discarded())
|
||||
auto j_result = parse_json_safely(new_packet.substr(6));
|
||||
if (!j_result)
|
||||
{
|
||||
std::cerr << "\nDiscarding: " << new_packet << std::endl;
|
||||
continue;
|
||||
}
|
||||
auto j = j_result.value();
|
||||
|
||||
auto chat_response = json_to<ChatResponse>(j);
|
||||
if (!chat_response.has_value())
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ function add_message_field() {
|
||||
local call_name="$4"
|
||||
local call_args="$5"
|
||||
echo "$msg" | jq --arg id "$call_id" --arg name "$call_name" --arg args "$call_args" \
|
||||
'.tool_calls = ((.tool_calls // []) + [{"id": $id, "type": "function", "function": {"name": $name, "arguments": $args}}])'
|
||||
'.tool_calls = ((.tool_calls // []) + [{"index": 0, "id": $id, "type": "function", "function": {"name": $name, "arguments": $args}}])'
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown field '$field'" >&2
|
||||
|
||||
@@ -24,7 +24,7 @@ cat > chat.json << 'CHATJSON'
|
||||
{
|
||||
"history": [
|
||||
{"role":"user","content":"hello"},
|
||||
{"role":"assistant","content":"calling tool","tool_calls":[{"id":"call_1","type":"function","function":{"name":"test","arguments":"{}"}}]},
|
||||
{"role":"assistant","content":"calling tool","tool_calls":[{"index":0,"id":"call_1","type":"function","function":{"name":"test","arguments":"{}"}}]},
|
||||
{"role":"tool","content":"result","tool_call_id":"call_1"}
|
||||
],
|
||||
"tools": []
|
||||
|
||||
Reference in New Issue
Block a user