2024-01-14 11:21:03 +00:00
|
|
|
package anthropic
|
|
|
|
|
2024-03-08 17:12:47 +00:00
|
|
|
// https://docs.anthropic.com/claude/reference/messages_post
|
|
|
|
|
2024-01-14 11:21:03 +00:00
|
|
|
type Metadata struct {
|
|
|
|
UserId string `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
2024-03-08 17:12:47 +00:00
|
|
|
type ImageSource struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
MediaType string `json:"media_type"`
|
|
|
|
Data string `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Content struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Text string `json:"text,omitempty"`
|
|
|
|
Source *ImageSource `json:"source,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Message struct {
|
|
|
|
Role string `json:"role"`
|
|
|
|
Content []Content `json:"content"`
|
|
|
|
}
|
|
|
|
|
2024-01-14 11:21:03 +00:00
|
|
|
type Request struct {
|
2024-03-08 17:12:47 +00:00
|
|
|
Model string `json:"model"`
|
|
|
|
Messages []Message `json:"messages"`
|
|
|
|
System string `json:"system,omitempty"`
|
|
|
|
MaxTokens int `json:"max_tokens,omitempty"`
|
|
|
|
StopSequences []string `json:"stop_sequences,omitempty"`
|
|
|
|
Stream bool `json:"stream,omitempty"`
|
|
|
|
Temperature float64 `json:"temperature,omitempty"`
|
|
|
|
TopP float64 `json:"top_p,omitempty"`
|
|
|
|
TopK int `json:"top_k,omitempty"`
|
2024-01-14 11:21:03 +00:00
|
|
|
//Metadata `json:"metadata,omitempty"`
|
2024-03-08 17:12:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Usage struct {
|
|
|
|
InputTokens int `json:"input_tokens"`
|
|
|
|
OutputTokens int `json:"output_tokens"`
|
2024-01-14 11:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Error struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Response struct {
|
2024-03-08 17:12:47 +00:00
|
|
|
Id string `json:"id"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Role string `json:"role"`
|
|
|
|
Content []Content `json:"content"`
|
|
|
|
Model string `json:"model"`
|
|
|
|
StopReason *string `json:"stop_reason"`
|
|
|
|
StopSequence *string `json:"stop_sequence"`
|
|
|
|
Usage Usage `json:"usage"`
|
|
|
|
Error Error `json:"error"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Delta struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Text string `json:"text"`
|
|
|
|
StopReason *string `json:"stop_reason"`
|
|
|
|
StopSequence *string `json:"stop_sequence"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type StreamResponse struct {
|
|
|
|
Type string `json:"type"`
|
|
|
|
Message *Response `json:"message"`
|
|
|
|
Index int `json:"index"`
|
|
|
|
ContentBlock *Content `json:"content_block"`
|
|
|
|
Delta *Delta `json:"delta"`
|
|
|
|
Usage *Usage `json:"usage"`
|
2024-01-14 11:21:03 +00:00
|
|
|
}
|