Skip to content

Commit

Permalink
fix: update generative-ai-go to fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Dec 18, 2023
1 parent b60cc9b commit 74bfe0a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/generative-ai-go v0.4.0 // indirect
github.com/google/generative-ai-go v0.5.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/generative-ai-go v0.4.0 h1:PXsbTUoAx0jRbed4rbpqtkQ1MH/cPY/YxPmkeOofXVY=
github.com/google/generative-ai-go v0.4.0/go.mod h1:ANivqBXKuwG5Wg94oNsqkuK6k6RIeB4DVwBg5DwrPok=
github.com/google/generative-ai-go v0.5.0 h1:PfzPuSGdsmcSyPG7RIoijcKWZ7/x2kvgyNryvmXMUmA=
github.com/google/generative-ai-go v0.5.0/go.mod h1:8fXQk4w+eyTzFokGGJrBFL0/xwXqm3QNhTqOWyX11zs=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down
7 changes: 4 additions & 3 deletions pkg/protocol/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ func SetGenaiChatByOpenaiRequest(cs *genai.ChatSession, req openai.ChatCompletio

func SetGenaiModelByOpenaiRequest(model *genai.GenerativeModel, req openai.ChatCompletionRequest) {
if req.MaxTokens != 0 {
model.MaxOutputTokens = int32(req.MaxTokens)
maxToken := int32(req.MaxTokens)
model.MaxOutputTokens = &maxToken
}
if req.Temperature != 0 {
model.Temperature = req.Temperature
model.Temperature = &req.Temperature
}
if req.TopP != 0 {
model.TopP = req.TopP
model.TopP = &req.TopP
}
model.SafetySettings = []*genai.SafetySetting{
{
Expand Down

0 comments on commit 74bfe0a

Please sign in to comment.