Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/appleboy/CodeGPT

go 1.25.11
go 1.26.8

require (
github.com/appleboy/com v1.2.0
Expand Down
15 changes: 6 additions & 9 deletions provider/anthropic/anthropic.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/appleboy/CodeGPT/proxy"
"github.com/appleboy/CodeGPT/version"

"github.com/appleboy/com/convert"
"github.com/liushuangls/go-anthropic/v2"
"github.com/sashabaranov/go-openai"
)
Expand All @@ -36,12 +35,11 @@ func (c *Client) Completion(ctx context.Context, content string) (*core.Response
anthropic.NewUserTextMessage(content),
},
MaxTokens: c.maxTokens,
Temperature: convert.ToPtr(c.temperature),
TopP: convert.ToPtr(c.topP),
Temperature: new(c.temperature),
TopP: new(c.topP),
})
if err != nil {
var e *anthropic.APIError
if errors.As(err, &e) {
if e, ok := errors.AsType[*anthropic.APIError](err); ok {
return nil, fmt.Errorf(
"messages error, type: %s, message: %s: %w",
e.Type,
Expand Down Expand Up @@ -85,8 +83,8 @@ func (c *Client) CompletionStream(
anthropic.NewUserTextMessage(content),
},
MaxTokens: c.maxTokens,
Temperature: convert.ToPtr(c.temperature),
TopP: convert.ToPtr(c.topP),
Temperature: new(c.temperature),
TopP: new(c.topP),
},
OnContentBlockDelta: func(data anthropic.MessagesEventContentBlockDeltaData) {
if data.Delta.Text != nil && writeErr == nil {
Expand All @@ -98,8 +96,7 @@ func (c *Client) CompletionStream(
},
})
if err != nil {
var e *anthropic.APIError
if errors.As(err, &e) {
if e, ok := errors.AsType[*anthropic.APIError](err); ok {
return nil, fmt.Errorf(
"messages error, type: %s, message: %s: %w",
e.Type,
Expand Down
13 changes: 6 additions & 7 deletions provider/gemini/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/appleboy/CodeGPT/core/transport"
"github.com/appleboy/CodeGPT/version"

"github.com/appleboy/com/convert"
"github.com/sashabaranov/go-openai"
"github.com/yassinebenaid/godump"
"google.golang.org/genai"
Expand All @@ -30,8 +29,8 @@ type Client struct {
// Completion is a method on the Client struct that takes a context.Context and a string argument
func (c *Client) Completion(ctx context.Context, content string) (*core.Response, error) {
cfg := &genai.GenerateContentConfig{
TopP: convert.ToPtr(c.topP),
Temperature: convert.ToPtr(c.temperature),
TopP: new(c.topP),
Temperature: new(c.temperature),
MaxOutputTokens: c.maxTokens,
}
data := []*genai.Content{
Expand Down Expand Up @@ -75,8 +74,8 @@ func (c *Client) CompletionStream(
w io.Writer,
) (*core.Response, error) {
cfg := &genai.GenerateContentConfig{
TopP: convert.ToPtr(c.topP),
Temperature: convert.ToPtr(c.temperature),
TopP: new(c.topP),
Temperature: new(c.temperature),
MaxOutputTokens: c.maxTokens,
}
data := []*genai.Content{
Expand Down Expand Up @@ -137,8 +136,8 @@ func (c *Client) CompletionStream(
func (c *Client) GetSummaryPrefix(ctx context.Context, content string) (*core.Response, error) {
cfg := &genai.GenerateContentConfig{
MaxOutputTokens: c.maxTokens,
TopP: convert.ToPtr(c.topP),
Temperature: convert.ToPtr(c.temperature),
TopP: new(c.topP),
Temperature: new(c.temperature),
Tools: []*genai.Tool{summaryPrefixFunc},
ToolConfig: &genai.ToolConfig{
FunctionCallingConfig: &genai.FunctionCallingConfig{
Expand Down
Loading