Use json v2
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/json/v2"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
@@ -83,7 +83,7 @@ func (c *Client) completions(
|
||||
ThinkingBudgetTokens: p.ThinkingBudgetTokens,
|
||||
ChatTemplateKWARGS: kwargs,
|
||||
ParallelToolCalls: new(true),
|
||||
})
|
||||
}, json.FormatNilSliceAsNull(true))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(
|
||||
"completions: marshal request body: %w", err,
|
||||
@@ -152,7 +152,7 @@ func (c *Client) completions(
|
||||
}
|
||||
|
||||
var cr = &ChatResponse{}
|
||||
if err := json.NewDecoder(res.Body).Decode(cr); err != nil {
|
||||
if err := json.UnmarshalRead(res.Body, cr); err != nil {
|
||||
return nil, fmt.Errorf("completions: decode response: %w", err)
|
||||
}
|
||||
if len(cr.Choices) == 0 {
|
||||
@@ -283,7 +283,7 @@ func (c *Client) CompletionsStream(
|
||||
StreamOptions: &StreamOptions{IncludeUsage: true},
|
||||
ThinkingBudgetTokens: p.ThinkingBudgetTokens,
|
||||
Tools: p.Tools,
|
||||
})
|
||||
}, json.FormatNilSliceAsNull(true))
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, fmt.Errorf(
|
||||
|
||||
Reference in New Issue
Block a user