Skip to content

Commit 88bbe0a

Browse files
committed
Merge branch 'release/v1.5.6'
2 parents bbf2d81 + 89c6fd6 commit 88bbe0a

File tree

4 files changed

+24
-42
lines changed

4 files changed

+24
-42
lines changed

agents/agent.go

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -694,36 +694,31 @@ func (a *Agent[I, O]) Run(ctx context.Context, userInput *I, output *O, apiResp
694694
}
695695
return err
696696
}
697-
mode := a.client.Mode()
698-
if mode == instructor.ModeToolCall || mode == instructor.ModeToolCallStrict {
699-
a.memory.NewMessage(components.FunctionRole, *output)
700-
} else {
701-
msg := components.NewMessage(components.AssistantRole, *output)
702-
msg.SetMode(a.client.Mode())
703-
switch t := apiResp.Details.(type) {
704-
case *openai.ChatCompletionResponse:
705-
if len(t.Choices) > 0 {
706-
msg.SetRaw(t.Choices[0].Message.Content)
707-
}
708-
case *anthropic.CompleteResponse:
709-
msg.SetRaw(t.Completion)
710-
case *cohere.NonStreamedChatResponse:
711-
msg.SetRaw(t.Text)
712-
case *geminiAPI.GenerateContentResponse:
713-
for _, candidate := range t.Candidates {
714-
if candidate == nil {
715-
continue
716-
}
717-
for _, part := range candidate.Content.Parts {
718-
if txt := part.Text; txt != "" {
719-
msg.SetRaw(txt)
720-
break
721-
}
697+
msg := components.NewMessage(components.AssistantRole, *output)
698+
msg.SetMode(a.client.Mode())
699+
switch t := apiResp.Details.(type) {
700+
case *openai.ChatCompletionResponse:
701+
if len(t.Choices) > 0 {
702+
msg.SetRaw(t.Choices[0].Message.Content)
703+
}
704+
case *anthropic.CompleteResponse:
705+
msg.SetRaw(t.Completion)
706+
case *cohere.NonStreamedChatResponse:
707+
msg.SetRaw(t.Text)
708+
case *geminiAPI.GenerateContentResponse:
709+
for _, candidate := range t.Candidates {
710+
if candidate == nil {
711+
continue
712+
}
713+
for _, part := range candidate.Content.Parts {
714+
if txt := part.Text; txt != "" {
715+
msg.SetRaw(txt)
716+
break
722717
}
723718
}
724719
}
725-
a.memory.AddMessage(msg)
726720
}
721+
a.memory.AddMessage(msg)
727722
if fn := a.endHook; fn != nil {
728723
fn(ctx, a, userInput, output, apiResp)
729724
}

components/message.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package components
33
import (
44
"bytes"
55
"encoding/base64"
6-
"encoding/json"
76
"errors"
87
"fmt"
98
"image"
@@ -448,18 +447,6 @@ func (m Message) toGemini(dist *gemini.Content, idx int) error {
448447
}
449448
}
450449
dist.Role = src.role
451-
if dist.Role == FunctionRole {
452-
bs := schema.ToBytes(src.content)
453-
resp := make(map[string]any)
454-
if err := json.Unmarshal(bs, &resp); err == nil {
455-
dist.Parts = append(dist.Parts, &gemini.Part{
456-
FunctionResponse: &gemini.FunctionResponse{
457-
Response: resp,
458-
},
459-
})
460-
return nil
461-
}
462-
}
463450
txt := m.TryAttachChunkPrompt(idx)
464451
dist.Parts = append(dist.Parts, &gemini.Part{Text: txt})
465452
if attachement := src.Attachement(); attachement != nil && len(attachement.ImageURLs) > 0 {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/PuerkitoBio/goquery v1.10.3
1111
github.com/aws/aws-sdk-go-v2 v1.36.3
1212
github.com/aws/aws-sdk-go-v2/service/s3 v1.79.4
13-
github.com/bububa/instructor-go v1.4.6
13+
github.com/bububa/instructor-go v1.4.7
1414
github.com/bububa/mdencoder v1.0.1
1515
github.com/clipperhouse/uax29 v1.14.3
1616
github.com/cohere-ai/cohere-go/v2 v2.14.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ github.com/brianvoe/gofakeit/v7 v7.2.1 h1:AGojgaaCdgq4Adzrd2uWdbGNDyX6MWNhHdQBra
4747
github.com/brianvoe/gofakeit/v7 v7.2.1/go.mod h1:QXuPeBw164PJCzCUZVmgpgHJ3Llj49jSLVkKPMtxtxA=
4848
github.com/bububa/go-openai v1.0.6 h1:ty+WZWhGJ1/6xfGFzgZOnC3H7jdUlQoRebdnwxDVgGQ=
4949
github.com/bububa/go-openai v1.0.6/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
50-
github.com/bububa/instructor-go v1.4.6 h1:LNN13J5PqBGS9dat7yZRurXEOWdjNIhDbbGyCCzApYA=
51-
github.com/bububa/instructor-go v1.4.6/go.mod h1:R8rAed36bnpI1jTh3pFm/ch97Ndx0ZpOgh8a/ThvRr4=
50+
github.com/bububa/instructor-go v1.4.7 h1:COAiCIc6yJBxEP9ddY2z162uYhmSX8JrE99WYao5t2I=
51+
github.com/bububa/instructor-go v1.4.7/go.mod h1:R8rAed36bnpI1jTh3pFm/ch97Ndx0ZpOgh8a/ThvRr4=
5252
github.com/bububa/ljson v1.0.1 h1:KyymkUrbsKQtd9yDYNQ6BIiupievR/7Ol1MPK3VVLgc=
5353
github.com/bububa/ljson v1.0.1/go.mod h1:V0iyqxoher3R2bQKk7uIpNkbogt8MAqe+hyS8WLlYsc=
5454
github.com/bububa/mdencoder v1.0.1 h1:RN9T4MZlauww1gTzHKcagWtO8p6JVvvUUCRqxqvkhkE=

0 commit comments

Comments
 (0)