Compare commits

...

7 Commits

Author SHA1 Message Date
Anmol Shukla
b58d959de1 Merge branch 'main' into fix-922 2025-09-02 15:49:27 +05:30
Anmol Shukla
8c532476e0 Merge branch 'main' into fix-922 2025-08-28 15:07:19 +05:30
Anmol Shukla
b8b59f0a4d Merge branch 'main' into fix-922 2025-08-25 11:03:02 +05:30
Anmol Shukla
ec6942c94b Merge branch 'main' into fix-922 2025-08-20 15:08:25 +05:30
Anmol Shukla
c92e84f869 Merge branch 'main' into fix-922 2025-08-19 14:27:32 +05:30
Anmol Shukla
0f30709050 improve parameter substitution 2025-08-18 10:50:21 +05:30
Anmol Shukla
175277fcad fix: FT.SEARCH command fails with "Syntax error" on a parameterized query for Redis DB [Docker image]. 2025-08-18 10:50:21 +05:30

View File

@@ -16,6 +16,7 @@ package redis
import (
"context"
"fmt"
"strings"
yaml "github.com/goccy/go-yaml"
"github.com/googleapis/genai-toolbox/internal/sources"
@@ -193,21 +194,32 @@ func replaceCommandsParams(commands [][]string, params tools.Parameters, paramVa
for i, cmd := range commands {
newCmd := make([]any, 0)
for _, part := range cmd {
v, ok := paramMap[part]
if !ok {
// Command part is not a Parameter placeholder
newCmd = append(newCmd, part)
continue
replaced := part
isArray := false
var arrayItems []any
if v, ok := paramMap[part]; ok {
if typeMap[part] == "array" {
isArray = true
arrayItems = v.([]any)
} else {
replaced = fmt.Sprintf("%v", v)
}
} else {
for placeholder, v := range paramMap {
replaced = strings.ReplaceAll(replaced, placeholder, fmt.Sprintf("%v", v))
}
}
if typeMap[part] == "array" {
for _, item := range v.([]any) {
if isArray {
for _, item := range arrayItems {
// Nested arrays will only be expanded once
// e.g., [A, [B, C]] --> ["A", "[B C]"]
newCmd = append(newCmd, fmt.Sprintf("%s", item))
}
continue
}
newCmd = append(newCmd, fmt.Sprintf("%s", v))
newCmd = append(newCmd, replaced)
}
newCommands[i] = newCmd
}