File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 44 "context"
55 "fmt"
66 "os"
7+ "regexp"
78 "slices"
89 "strings"
910
@@ -45,7 +46,7 @@ func cleanTextContent(text string) string {
4546 }
4647 // Remove trailing empty lines from the result
4748 result := strings .Join (cleanedLines , "\n " )
48- return strings .TrimRight (result , "\n " )
49+ return stripThinkingTags ( strings .TrimRight (result , "\n " ) )
4950}
5051
5152// isModelExisting checks if a specific model ID exists in the gallery using text search
@@ -92,6 +93,16 @@ func getGalleryIndexPath() string {
9293 return "gallery/index.yaml"
9394}
9495
96+ func stripThinkingTags (content string ) string {
97+ // Remove content between <thinking> and </thinking> (including multi-line)
98+ content = regexp .MustCompile (`(?s)<thinking>.*?</thinking>` ).ReplaceAllString (content , "" )
99+ // Remove content between <think> and </think> (including multi-line)
100+ content = regexp .MustCompile (`(?s)<think>.*?</think>` ).ReplaceAllString (content , "" )
101+ // Clean up any extra whitespace
102+ content = strings .TrimSpace (content )
103+ return content
104+ }
105+
95106func getRealReadme (ctx context.Context , repository string ) (string , error ) {
96107 // Create a conversation fragment
97108 fragment := cogito .NewEmptyFragment ().
You can’t perform that action at this time.
0 commit comments