1. Add README, LICENSE (MIT), .gitignore, Makefile, CHANGELOG 2. Add Version constant and User-Agent header to all requests 3. Rename SetStream to EnableStream (narrower API surface) 4. Fix FinishReason in CompletionStreamChoice to use typed *FinishReason 5. Type conversation entry Content as chat.Content instead of json.RawMessage 6. Graceful unknown type handling — UnknownEntry, UnknownEvent, UnknownChunk, UnknownMessage, UnknownAgentTool all return data instead of erroring on unrecognized discriminator values 7. Type agent tools with AgentTool sealed interface + UnmarshalAgentTool 8. Add pagination params to ListConversations and ListLibraries 9. Move openapi.yaml to docs/openapi.yaml
28 lines
904 B
Go
28 lines
904 B
Go
package mistral
|
|
|
|
import (
|
|
"context"
|
|
|
|
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
|
)
|
|
|
|
// ChatComplete sends a chat completion request and returns the full response.
|
|
func (c *Client) ChatComplete(ctx context.Context, req *chat.CompletionRequest) (*chat.CompletionResponse, error) {
|
|
var resp chat.CompletionResponse
|
|
if err := c.doJSON(ctx, "POST", "/v1/chat/completions", req, &resp); err != nil {
|
|
return nil, err
|
|
}
|
|
return &resp, nil
|
|
}
|
|
|
|
// ChatCompleteStream sends a chat completion request and returns a stream
|
|
// of completion chunks. The caller must call Close() on the returned stream.
|
|
func (c *Client) ChatCompleteStream(ctx context.Context, req *chat.CompletionRequest) (*Stream[chat.CompletionChunk], error) {
|
|
req.EnableStream()
|
|
resp, err := c.doStream(ctx, "POST", "/v1/chat/completions", req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return newStream[chat.CompletionChunk](resp.Body), nil
|
|
}
|