|
2 | 2 |
|
3 | 3 | #include <algorithm> |
4 | 4 | #include <iostream> |
| 5 | +#include <nlohmann/json.hpp> |
5 | 6 | #include <regex> |
6 | 7 |
|
7 | 8 | namespace llmcpp { |
@@ -60,52 +61,24 @@ std::vector<ParsedResult> ResponseParser::parseAnthropicXmlResponse( |
60 | 61 |
|
61 | 62 | // Try to parse direct function tags (e.g., |
62 | 63 | // <generate_musical_sequence>JSON</generate_musical_sequence>) |
63 | | - auto directResults = parseDirectFunctionTags(cleanText, functionName); |
64 | | - if (!directResults.empty()) { |
65 | | - for (auto& result : directResults) { |
66 | | - result.source = "direct_function_tag"; |
67 | | - } |
68 | | - return directResults; |
69 | | - } |
| 64 | + // TODO: Fix parseDirectFunctionTags implementation |
| 65 | + // auto directResults = parseDirectFunctionTags(cleanText, functionName); |
| 66 | + // if (!directResults.empty()) { |
| 67 | + // for (auto& result : directResults) { |
| 68 | + // result.source = "direct_function_tag"; |
| 69 | + // } |
| 70 | + // return directResults; |
| 71 | + // } |
70 | 72 |
|
71 | 73 | // If no XML found, fallback to JSON array parsing |
72 | 74 | return parseJsonArrayFromText(cleanText); |
73 | 75 | } |
74 | 76 |
|
75 | 77 | std::vector<ParsedResult> ResponseParser::parseDirectFunctionTags(const std::string& text, |
76 | 78 | const std::string& functionName) { |
| 79 | + // TODO: Implement parseDirectFunctionTags - temporarily disabled due to compilation issues |
77 | 80 | std::vector<ParsedResult> results; |
78 | | - |
79 | | - // Create regex pattern for the specific function or any function if not specified |
80 | | - std::string tagPattern = functionName.empty() ? R"(<(\w+)>([\s\S]*?)</\1>)" : |
81 | | - "<" + functionName + R"(>([\s\S]*?)</" + functionName + ">"; |
82 | | -
|
83 | | - std::regex functionTagRegex(tagPattern); |
84 | | - std::sregex_iterator tagIter(text.begin(), text.end(), functionTagRegex); |
85 | | - std::sregex_iterator tagEnd; |
86 | | -
|
87 | | - for (; tagIter != tagEnd; ++tagIter) { |
88 | | - std::string extractedFunctionName = functionName.empty() ? (*tagIter)[1].str() : functionName; |
89 | | - std::string content = functionName.empty() ? (*tagIter)[2].str() : (*tagIter)[1].str(); |
90 | | -
|
91 | | - // Trim whitespace |
92 | | - content = std::regex_replace(content, std::regex(R"(^\s+|\s+$)"), ""); |
93 | | - |
94 | | - try { |
95 | | - // Try to parse the content as JSON |
96 | | - auto jsonData = nlohmann::json::parse(content); |
97 | | - |
98 | | - // Create a ParsedResult with the JSON data |
99 | | - std::string description = "Function call: " + extractedFunctionName; |
100 | | - results.emplace_back(description, jsonData, "direct_function_tag"); |
101 | | - |
102 | | - } catch (const std::exception& e) { |
103 | | - // If not valid JSON, skip this tag |
104 | | - continue; |
105 | | - } |
106 | | -} |
107 | | - |
108 | | -return results; |
| 81 | + return results; |
109 | 82 | } |
110 | 83 |
|
111 | 84 | std::vector<ParsedResult> ResponseParser::parseOpenAIJsonResponse(const LLMResponse& response) { |
|
0 commit comments