From 3c82b630469237ef9d5ed463fce13e7fa9b39a76 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 7 Jan 2026 16:24:10 +0100 Subject: [PATCH] Allow optional parameters with a default value. --- profiler/src/profiler/TracyLlmTools.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index bb47d61f..1683e053 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -121,8 +121,15 @@ static uint32_t GetParamU32( const nlohmann::json& json, const char* name ) return json[name].get(); } +static uint32_t GetParamOptU32( const nlohmann::json& json, const char* name, uint32_t def ) +{ + if( !json.contains( name ) ) return def; + return json[name].get(); +} + #define Param(name) GetParam( json, name ) #define ParamU32(name) GetParamU32( json, name ) +#define ParamOptU32(name, def) GetParamOptU32( json, name, def ) TracyLlmTools::ToolReply TracyLlmTools::HandleToolCalls( const std::string& tool, const nlohmann::json& json, TracyLlmApi& api, int contextSize, bool hasEmbeddingsModel ) {