From 18b8956bd9bc18f5126790086cb9f30cc8010c6b Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 7 Dec 2025 19:25:41 +0100 Subject: [PATCH] chore(gallery agent): strip thinking tags (#7464) Signed-off-by: Ettore Di Giacinto --- .github/gallery-agent/agent.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/gallery-agent/agent.go b/.github/gallery-agent/agent.go index 687b5a1eb..a1a481c07 100644 --- a/.github/gallery-agent/agent.go +++ b/.github/gallery-agent/agent.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "regexp" "slices" "strings" @@ -45,7 +46,7 @@ func cleanTextContent(text string) string { } // Remove trailing empty lines from the result result := strings.Join(cleanedLines, "\n") - return strings.TrimRight(result, "\n") + return stripThinkingTags(strings.TrimRight(result, "\n")) } // isModelExisting checks if a specific model ID exists in the gallery using text search @@ -92,6 +93,16 @@ func getGalleryIndexPath() string { return "gallery/index.yaml" } +func stripThinkingTags(content string) string { + // Remove content between and (including multi-line) + content = regexp.MustCompile(`(?s).*?`).ReplaceAllString(content, "") + // Remove content between and (including multi-line) + content = regexp.MustCompile(`(?s).*?`).ReplaceAllString(content, "") + // Clean up any extra whitespace + content = strings.TrimSpace(content) + return content +} + func getRealReadme(ctx context.Context, repository string) (string, error) { // Create a conversation fragment fragment := cogito.NewEmptyFragment().