File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,33 @@ namespace SourceGit.Models
1313 public class OpenAIChatMessage
1414 {
1515 [ JsonPropertyName ( "role" ) ]
16- public string Role
17- {
18- get ;
19- set ;
20- }
16+ public string Role { get ; set ; }
2117
2218 [ JsonPropertyName ( "content" ) ]
2319 public string Content
2420 {
25- get ;
26- set ;
21+ get => _content ;
22+ set
23+ {
24+ // Trim leading newline characters
25+ value = value . TrimStart ( '\n ' ) ;
26+
27+ // Ignore the Chain-of-Thought
28+ var thinkTag = "<think>" ;
29+ var thinkEndTag = "</think>" ;
30+ var thinkStartIndex = value . IndexOf ( thinkTag , StringComparison . OrdinalIgnoreCase ) ;
31+ var thinkEndIndex = value . IndexOf ( thinkEndTag , StringComparison . OrdinalIgnoreCase ) ;
32+
33+ if ( thinkStartIndex >= 0 && thinkEndIndex > thinkStartIndex )
34+ {
35+ value = value . Substring ( thinkEndIndex + thinkEndTag . Length ) . Trim ( ) ;
36+ }
37+
38+ _content = value ;
39+ }
2740 }
41+
42+ private string _content ;
2843 }
2944
3045 public class OpenAIChatChoice
You can’t perform that action at this time.
0 commit comments