X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/496569ab5b179932c60b2924bf4c61176c8be004..9301f77a5709fe7daea3a71f8dd072c6cd7df4fe:/chain.go?ds=inline diff --git a/chain.go b/chain.go index f201812..c85b2a2 100644 --- a/chain.go +++ b/chain.go @@ -65,7 +65,7 @@ func (c *Chain) Run(ctx context.Context, input []any) (string, error) { input, text, err = c.handle(ctx, input, response) if err != nil { - return "", err + return "", fmt.Errorf("handle model response: %w", err) } if len(input) == 0 { @@ -87,7 +87,7 @@ func (c *Chain) handle(ctx context.Context, input []any, response ModelResponse) for _, raw := range response.Output { item, err := chainInputItem(raw) if err != nil { - return nil, "", err + return nil, "", fmt.Errorf("decode chain input: %w", err) } input = append(input, item) @@ -103,7 +103,7 @@ func (c *Chain) handle(ctx context.Context, input []any, response ModelResponse) case "message": text, err := modelOutputText([]json.RawMessage{raw}) if err != nil { - return nil, "", err + return nil, "", fmt.Errorf("read response text: %w", err) } text = strings.TrimSpace(text)