File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -134,8 +134,12 @@ func (aiChat *AIChat) fold(prompt *Prompt, input string) error {
134
134
if err != nil {
135
135
return err
136
136
}
137
+ idx := firstAllowedTokens
138
+ for idx > len (encoded ) {
139
+ idx = len (encoded )
140
+ }
137
141
138
- firstEncoded := encoded [:firstAllowedTokens ]
142
+ firstEncoded := encoded [:idx ]
139
143
firstInput := aiChat .encoder .Decode (firstEncoded )
140
144
temperature := firstNonZeroFloat32 (aiChat .options .temperature , prompt .Temperature )
141
145
firstRequest := gogpt.ChatCompletionRequest {
@@ -154,15 +158,14 @@ func (aiChat *AIChat) fold(prompt *Prompt, input string) error {
154
158
return fmt .Errorf ("no choices returned" )
155
159
}
156
160
output := response .Choices [0 ].Message .Content
157
- if firstAllowedTokens >= len (encoded ) {
161
+ if idx >= len (encoded ) {
158
162
fmt .Println (output )
159
163
return nil
160
164
}
161
165
if aiChat .options .verbose {
162
166
log .Printf ("first output: %s" , output )
163
167
}
164
168
165
- idx := firstAllowedTokens
166
169
for idx < len (encoded ) {
167
170
outputTokens , err := aiChat .encoder .Encode (output )
168
171
if err != nil {
You can’t perform that action at this time.
0 commit comments