-
Notifications
You must be signed in to change notification settings - Fork 58
/
anthropic.go
101 lines (85 loc) · 2.81 KB
/
anthropic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package anthropic
type Metadata struct {
UserId string `json:"user_id"`
}
type CompletionRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
MaxTokensToSample int `json:"max_tokens_to_sample"`
StopSequences []string `json:"stop_sequences,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP int `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Stream bool `json:"stream,omitempty"`
}
type Message struct {
Content string `json:"content"`
Role string `json:"role"`
}
type MessagesRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
StopSequences []string `json:"stop_sequences,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
TopP int `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Stream bool `json:"stream,omitempty"`
}
type CompletionResponse struct {
Completion string `json:"completion"`
StopReason string `json:"stop_reason"`
Model string `json:"model"`
}
type MessageResponseContent struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
}
type MessagesResponse struct {
Id string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []MessageResponseContent `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"`
StopSequence string `json:"stop_sequence,omitempty"`
Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
}
type MessagesStreamMessageStart struct {
Message MessagesResponse `json:"message"`
}
type MessagesStreamMessageDelta struct {
Delta struct {
StopReason string `json:"stop_reason"`
StopSequence string `json:"stop_sequence,omitempty"`
} `json:"delta"`
Usage struct {
OutputTokens int `json:"output_tokens"`
} `json:"usage"`
}
type MessagesStreamMessageStop struct {
Type string `json:"type"`
}
type MessagesStreamBlockStart struct {
Index int `json:"index"`
ContentBlock MessageResponseContent `json:"content_block"`
}
type MessagesStreamBlockDelta struct {
Index int `json:"index"`
Delta MessageResponseContent `json:"delta"`
}
type MessagesStreamBlockStop struct {
Index int `json:"index"`
}
type Error struct {
Type string `json:"type"`
Message string `json:"message"`
}
type ErrorResponse struct {
Error *Error `json:"error"`
}