@@ -2,7 +2,6 @@ package main
2
2
3
3
import (
4
4
"bytes"
5
- "encoding/json"
6
5
"errors"
7
6
"fmt"
8
7
"io"
@@ -137,35 +136,13 @@ func run(inv *serpent.Invocation, opts runOptions) error {
137
136
IncludeUsage : true ,
138
137
},
139
138
Messages : msgs ,
140
- ResponseFormat : & openai.ChatCompletionResponseFormat {
141
- Type : openai .ChatCompletionResponseFormatTypeJSONSchema ,
142
- JSONSchema : & openai.ChatCompletionResponseFormatJSONSchema {
143
- Name : "commit_message" ,
144
- Schema : json .RawMessage (`{
145
- "type": "object",
146
- "properties": {
147
- "thought_process": {
148
- "type": "string",
149
- "description": "A chain of thought explaining the reasoning behind the commit message"
150
- },
151
- "commit_message": {
152
- "type": "string",
153
- "description": "The final, concise commit message"
154
- }
155
- },
156
- "additionalProperties": false,
157
- "required": ["thought_process", "commit_message"]
158
- }` ),
159
- Strict : true ,
160
- },
161
- },
162
139
})
163
140
if err != nil {
164
141
return err
165
142
}
166
143
defer stream .Close ()
167
144
168
- jsonMsg := & bytes.Buffer {}
145
+ msg := & bytes.Buffer {}
169
146
170
147
// Sky blue color
171
148
color := pretty .FgColor (colorProfile .Color ("#2FA8FF" ))
@@ -185,22 +162,14 @@ func run(inv *serpent.Invocation, opts runOptions) error {
185
162
break
186
163
}
187
164
c := resp .Choices [0 ].Delta .Content
188
- jsonMsg .WriteString (c )
165
+ msg .WriteString (c )
189
166
pretty .Fprintf (inv .Stdout , color , "%s" , c )
190
167
}
191
168
inv .Stdout .Write ([]byte ("\n " ))
192
169
193
- var parsedMsg struct {
194
- CommitMessage string `json:"commit_message"`
195
- }
196
- err = json .Unmarshal (jsonMsg .Bytes (), & parsedMsg )
197
- if err != nil {
198
- return err
199
- }
200
-
201
- parsedMsg .CommitMessage = cleanAIMessage (parsedMsg .CommitMessage )
170
+ msg = bytes .NewBufferString (cleanAIMessage (msg .String ()))
202
171
203
- cmd := exec .Command ("git" , "commit" , "-m" , parsedMsg . CommitMessage )
172
+ cmd := exec .Command ("git" , "commit" , "-m" , msg . String () )
204
173
if opts .amend {
205
174
cmd .Args = append (cmd .Args , "--amend" )
206
175
}
@@ -304,11 +273,9 @@ func main() {
304
273
Description : "The model to use, e.g. gpt-4o or gpt-4o-mini." ,
305
274
Flag : "model" ,
306
275
FlagShorthand : "m" ,
307
- // Needed for structured output.
308
- // Should update to gpt-4o once gpt-4o-2024-08-06 is the default.
309
- Default : "gpt-4o-2024-08-06" ,
310
- Env : "AICOMMIT_MODEL" ,
311
- Value : serpent .StringOf (& opts .model ),
276
+ Default : "gpt-4o-2024-08-06" ,
277
+ Env : "AICOMMIT_MODEL" ,
278
+ Value : serpent .StringOf (& opts .model ),
312
279
},
313
280
{
314
281
Name : "save-key" ,
0 commit comments