appleboy / CodeGPT

A CLI written in Go language that writes git commit messages or do a code review brief for you using ChatGPT AI (gpt-4o, gpt-4-turbo, gpt-3.5-turbo model) and automatically installs a git prepare-commit-msg hook.
MIT License
1.15k stars 100 forks source link

`codegpt commit --preview` Command Encounters Runtime Error with local model #150

Closed winterdrive closed 1 month ago

winterdrive commented 3 months ago

Issue Summary:

When attempting to use the codegpt commit --preview command with a local model on Mac Studio, the process encounters a runtime error and fails to output the result message.

Steps to Reproduce:

  1. Configure the .codegpt.yaml file with the provided settings.
  2. Run the command codegpt commit --preview.
  3. Observe the terminal output and error message.

Edited .codegpt.yaml:

git:
    diff_unified: 3
    exclude_list: ""
    template_file: ""
    template_string: ""
openai:
    api_key: lm-studio
    api_version: ""
    base_url: http://localhost:1234/v1
    headers: ""
    max_tokens: 300
    model: gpt-3.5-turbo
    model_name: ""
    org_id: ""
    provider: openai
    proxy: ""
    skip_verify: false
    socks: ""
    temperature: "1"
    timeout: 30s
output:
    file: ""
    lang: en

Error Output:

(base) winstontang@sd214008 PowerPilot % codegpt commit --preview

Summarize the commit message use gpt-3.5-turbo model
We are trying to summarize a git diff
PromptTokens: 77, CompletionTokens: 77, TotalTokens: 154
We are trying to summarize a title for pull request
PromptTokens: 10, CompletionTokens: 10, TotalTokens: 20
We are trying to get conventional commit prefix
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x100a43560]

goroutine 1 [running]:
github.com/appleboy/CodeGPT/cmd.glob..func1(0x100e79760, {0x100a4c398?, 0x1?, 0x1?})
    github.com/appleboy/CodeGPT/cmd/commit.go:214 +0x1450
github.com/spf13/cobra.(*Command).execute(0x100e79760, {0x1400010da30, 0x1, 0x1})
    github.com/spf13/cobra@v1.8.0/command.go:983 +0x7e4
github.com/spf13/cobra.(*Command).ExecuteC(0x100e78620)
    github.com/spf13/cobra@v1.8.0/command.go:1115 +0x380
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
    github.com/spf13/cobra@v1.8.0/command.go:1048
github.com/appleboy/CodeGPT/cmd.Execute({0x100bdca50?, 0x14000100960?})
    github.com/appleboy/CodeGPT/cmd/cmd.go:106 +0x5c
main.main()
    github.com/appleboy/CodeGPT/cmd/codegpt/main.go:11 +0x38
appleboy commented 2 months ago

@winterdrive I will take it.

appleboy commented 2 months ago

@winterdrive Can you help to try the https://github.com/appleboy/CodeGPT/releases/tag/v0.11.0 version?

winterdrive commented 2 months ago

It works now, thank you!