From 1eafdc95c8839d3bd18bd3e2b6ddb403a671e65c Mon Sep 17 00:00:00 2001 From: Yingbei Date: Mon, 1 Apr 2024 18:20:49 -0700 Subject: [PATCH] Using ordered_map instead to make sure the function call observations are in the correct order. --- examples/server/python-parser.hpp | 2 +- examples/server/utils.hpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/server/python-parser.hpp b/examples/server/python-parser.hpp index 4f35e6b9e..7d824f132 100644 --- a/examples/server/python-parser.hpp +++ b/examples/server/python-parser.hpp @@ -103,7 +103,7 @@ static std::vector parsePythonFunctionCalls(std::string source_string) { std::vector calls; std::string delimiter = "<>"; std::string source_code; - printf("Parsing source_string: %s\n", source_string.c_str()); + printf("Parsing source_string::%s\n", source_string.c_str()); size_t startPos = source_string.find(delimiter); if (startPos != std::string::npos) { source_code = source_string.substr(startPos + delimiter.length()); diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index 02545c5c1..d602892ab 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #define DEFAULT_OAICOMPAT_MODEL "gpt-3.5-turbo-0613" @@ -421,7 +420,7 @@ static std::string rubra_format_function_call_str(const std::vector & func for (const auto& def : function_definitions) { final_str += def + "\n"; } - final_str += "Use the following format if using a tool:\n[toolname1(arg1=value1, arg2=value2, ...), toolname2(arg1=value1, arg2=value2, ...)]"; + final_str += "Use the following format if using tools:\n<>[toolname1(arg1=value1, arg2=value2, ...), toolname2(arg1=value1, arg2=value2, ...)]"; return final_str; } @@ -507,7 +506,7 @@ static json oaicompat_completion_params_parse( // temp_vec.push_back(function_call); // } std::vector temp_vec; - std::unordered_map func_observation_map; + nlohmann::ordered_map func_observation_map; for (size_t i = 0; i < body["messages"].size(); ++i) { if (body["messages"][i]["role"] != "tool" and func_observation_map.size() > 0) {