]> git.giacomolli.uk - onechat/blobdiff - chain.go
Check the width of comment lines
[onechat] / chain.go
index c4a4302472d030ee944af5d7bc33f1e96ed7d9f1..23c7dec14a6053d8ec38d5201a06f6dc916b4532 100644 (file)
--- a/chain.go
+++ b/chain.go
@@ -32,6 +32,7 @@ type Chain struct {
        tools   *Toolbox
        request ModelRequest
        take    func() []Message
+       images  *ImageStore
 }
 
 // Run runs the chain from input, the input of its first request, and returns
@@ -122,7 +123,12 @@ func (c *Chain) handle(ctx context.Context, input []any, response ModelResponse)
 
        input = append(input, outputs...)
        for _, message := range c.take() {
-               input = append(input, modelUserMessage(message.Text))
+               item, err := imageUserMessage(c.images, message.Text)
+               if err != nil {
+                       return nil, "", fmt.Errorf("read queued images: %w", err)
+               }
+
+               input = append(input, item)
        }
 
        return input, "", nil
@@ -141,7 +147,7 @@ type ChainFunctionCall struct {
 type ChainFunctionCallOutput struct {
        Type   string `json:"type"`
        CallID string `json:"call_id"`
-       Output string `json:"output"`
+       Output any    `json:"output"`
 }
 
 // chainInputItem returns an output item as an input item for the next request.