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
4 changes: 2 additions & 2 deletions examples/llmsummarization-chain-example/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/vendasta/langchaingo/examples/llmsummarization-chain-example

go 1.24.3
go 1.24.4

require github.com/vendasta/langchaingo v0.1.14-pre.4

Expand All @@ -14,7 +14,7 @@ require (
cloud.google.com/go/iam v1.2.2 // indirect
cloud.google.com/go/longrunning v0.6.2 // indirect
cloud.google.com/go/vertexai v0.12.0 // indirect
github.com/AssemblyAI/assemblyai-go-sdk v1.3.0 // indirect
github.com/AssemblyAI/assemblyai-go-sdk v1.10.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
Expand Down
1 change: 1 addition & 0 deletions examples/llmsummarization-chain-example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/AssemblyAI/assemblyai-go-sdk v1.3.0 h1:AtOVgGxUycvK4P4ypP+1ZupecvFgnfH+Jsum0o5ILoU=
github.com/AssemblyAI/assemblyai-go-sdk v1.3.0/go.mod h1:H0naZbvpIW49cDA5ZZ/gggeXqi7ojSGB1mqshRk6kNE=
github.com/AssemblyAI/assemblyai-go-sdk v1.10.0/go.mod h1:dwv8jDdg+UKPU9ClZzhQNXIVj3Yw68IaTVRuyKRLigw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand Down
4 changes: 2 additions & 2 deletions examples/mistral-summarization-example/go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/vendasta/langchaingo/examples/mistral-summarization-example

go 1.24.3
go 1.24.4

require github.com/vendasta/langchaingo v0.1.14-pre.4

require (
github.com/AssemblyAI/assemblyai-go-sdk v1.3.0 // indirect
github.com/AssemblyAI/assemblyai-go-sdk v1.10.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
Expand Down
1 change: 1 addition & 0 deletions examples/mistral-summarization-example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/AssemblyAI/assemblyai-go-sdk v1.3.0 h1:AtOVgGxUycvK4P4ypP+1ZupecvFgnfH+Jsum0o5ILoU=
github.com/AssemblyAI/assemblyai-go-sdk v1.3.0/go.mod h1:H0naZbvpIW49cDA5ZZ/gggeXqi7ojSGB1mqshRk6kNE=
github.com/AssemblyAI/assemblyai-go-sdk v1.10.0/go.mod h1:dwv8jDdg+UKPU9ClZzhQNXIVj3Yw68IaTVRuyKRLigw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect

)

// Database drivers - indirect
Expand Down
3 changes: 3 additions & 0 deletions llms/generatecontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type ToolCall struct {
Type string `json:"type"`
// FunctionCall is the function call to be executed.
FunctionCall *FunctionCall `json:"function,omitempty"`
// ThoughtSignature is an opaque signature for Gemini 3+ models that must be
// preserved when echoing back function calls. Required for tool calling to work.
ThoughtSignature []byte `json:"thought_signature,omitempty"`
}

func (ToolCall) isPart() {}
Expand Down
9 changes: 7 additions & 2 deletions llms/googleaiv2/googleai.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func convertCandidates(candidates []*genai.Candidate, usage *genai.GenerateConte
for i, candidate := range candidates {
var textContent string
var toolCalls []llms.ToolCall

// Use the response's Text() method if available (more reliable, handles thoughts correctly)
// For multi-candidate responses, we need to extract text per candidate
if response != nil && i == 0 {
Expand Down Expand Up @@ -349,6 +349,8 @@ func convertCandidates(candidates []*genai.Candidate, usage *genai.GenerateConte
Name: part.FunctionCall.Name,
Arguments: string(b),
},
// Preserve ThoughtSignature for Gemini 3+ models - required for tool calling
ThoughtSignature: part.ThoughtSignature,
}
toolCalls = append(toolCalls, toolCall)
}
Expand Down Expand Up @@ -446,7 +448,10 @@ func convertParts(parts []llms.ContentPart) ([]*genai.Part, error) {
Name: fc.Name,
Args: argsMap,
}
out = &genai.Part{FunctionCall: functionCall}
out = &genai.Part{
FunctionCall: functionCall,
ThoughtSignature: p.ThoughtSignature, // Required for Gemini 3+ tool calling
}
case llms.ToolCallResponse:
functionResponse := &genai.FunctionResponse{
Name: p.Name,
Expand Down