Skip to content

Commit e11029e

Browse files
authored
feat: refactor error handling and output formatting (#158)
- Remove unused "fmt" import from commit.go - Change error handling to display a message in red without exiting the function - Add a condition to set `summaryPrix` based on `msg.Content` if no tool calls are found in the message Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 3ea1edf commit e11029e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/commit.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"fmt"
54
"html"
65
"log"
76
"os"
@@ -218,12 +217,13 @@ var commitCmd = &cobra.Command{
218217

219218
msg := resp.Choices[0].Message
220219
if len(msg.ToolCalls) == 0 {
221-
return fmt.Errorf("current model doesn't support function call")
220+
color.Red("No tool calls found in the message")
221+
summaryPrix = msg.Content
222+
} else {
223+
args := openai.GetSummaryPrefixArgs(msg.ToolCalls[len(msg.ToolCalls)-1].Function.Arguments)
224+
summaryPrix = args.Prefix
222225
}
223226

224-
args := openai.GetSummaryPrefixArgs(msg.ToolCalls[len(msg.ToolCalls)-1].Function.Arguments)
225-
summaryPrix = args.Prefix
226-
227227
color.Magenta("PromptTokens: " + strconv.Itoa(resp.Usage.PromptTokens) +
228228
", CompletionTokens: " + strconv.Itoa(resp.Usage.CompletionTokens) +
229229
", TotalTokens: " + strconv.Itoa(resp.Usage.TotalTokens),

0 commit comments

Comments
 (0)