From ce9a9a30e0c475f43034766caa391e87c0245a63 Mon Sep 17 00:00:00 2001 From: leopardracer <136604165+leopardracer@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:46:53 +0300 Subject: [PATCH] Improve Comments and Documentation for MixedMode and ParseJSON Functions (#5626) Update parse.go Signed-off-by: leopardracer <136604165+leopardracer@users.noreply.github.com> --- pkg/functions/parse.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/functions/parse.go b/pkg/functions/parse.go index a9d7b8bd..48efb819 100644 --- a/pkg/functions/parse.go +++ b/pkg/functions/parse.go @@ -20,11 +20,11 @@ type GrammarConfig struct { DisableParallelNewLines bool `yaml:"disable_parallel_new_lines"` // MixedMode enables the LLM to return strings and not only JSON objects - // This is useful for models to not constraing returning only JSON and also messages back to the user + // This is useful for models to not constraining returning only JSON and also messages back to the user MixedMode bool `yaml:"mixed_mode"` // NoMixedFreeString disables the mixed mode for free strings - // In this way if the LLM selects a free string, it won't be mixed necessarly with JSON objects. + // In this way if the LLM selects a free string, it won't be mixed necessarily with JSON objects. // For example, if enabled the LLM or returns a JSON object or a free string, but not a mix of both // If disabled(default): the LLM can return a JSON object surrounded by free strings (e.g. `this is the JSON result: { "bar": "baz" } for your question`). This forces the LLM to return at least a JSON object, but its not going to be strict NoMixedFreeString bool `yaml:"no_mixed_free_string"` @@ -184,7 +184,7 @@ func ParseTextContent(llmresult string, functionConfig FunctionsConfig) string { // into // [ { "foo": "bar" }, { "baz": "qux" } ] // Credits to Michael Yang (https://github.com/mxyng) for the original implementation -// This is a slighly reworked version, improved for readability and error handling +// This is a slightly reworked version, improved for readability and error handling func ParseJSON(s string) ([]map[string]any, error) { var objs []map[string]any offset := 0