code.oscarkilo.com/klex-git

Hash:
f6df59ec2189a833c466a4b566909f1f9790ce19
Author:
Igor Naverniouk <[email protected]>
Date:
Sun Oct 13 15:02:06 2024 -0700
Message:
argh
diff --git a/api/messages.go b/api/messages.go
index dbc05c2..1a52078 100644
--- a/api/messages.go
+++ b/api/messages.go
@@ -62,8 +62,8 @@ type MessagesResponse struct {
Role string `json:"role"`
Content []ContentBlock `json:"content"`
Model string `json:"model"`
- StopReason string `json:"stop_reason"`
- StopSequence bool `json:"stop_sequence"`
+ StopReason *string `json:"stop_reason,omitempty"`
+ StopSequence *string `json:"stop_sequence,omitempty"`
Usage Usage `json:"usage"`
Error *ErrorResponse `json:"error"`
}
a/api/messages.go
b/api/messages.go
1
package api
1
package api
2
2
3
type ChatMessage struct {
3
type ChatMessage struct {
4
Role string `json:"role"`
4
Role string `json:"role"`
5
Content []ContentBlock `json:"content"`
5
Content []ContentBlock `json:"content"`
6
}
6
}
7
7
8
type MessagesRequest struct {
8
type MessagesRequest struct {
9
Model string `json:"model"`
9
Model string `json:"model"`
10
Messages []ChatMessage `json:"messages"`
10
Messages []ChatMessage `json:"messages"`
11
MaxTokens int `json:"max_tokens"`
11
MaxTokens int `json:"max_tokens"`
12
System string `json:"system,omitempty"`
12
System string `json:"system,omitempty"`
13
Temperature float64 `json:"temperature"`
13
Temperature float64 `json:"temperature"`
14
Tools []Tool `json:"tools,omitempty"`
14
Tools []Tool `json:"tools,omitempty"`
15
}
15
}
16
16
17
type ContentBlock struct {
17
type ContentBlock struct {
18
// Type is "text", "image", "tool_use", or "tool_result".
18
// Type is "text", "image", "tool_use", or "tool_result".
19
Type string `json:"type"`
19
Type string `json:"type"`
20
20
21
// Text is for Type="text"
21
// Text is for Type="text"
22
Text string `json:"text"`
22
Text string `json:"text"`
23
23
24
// Source is for Type="image"
24
// Source is for Type="image"
25
Source *ContentSource `json:"source"`
25
Source *ContentSource `json:"source"`
26
26
27
// Id, Name, and Input are for Type="tool_use".
27
// Id, Name, and Input are for Type="tool_use".
28
ID string `json:"id"`
28
ID string `json:"id"`
29
Name string `json:"name"`
29
Name string `json:"name"`
30
Input interface{} `json:"input"`
30
Input interface{} `json:"input"`
31
}
31
}
32
32
33
type ContentSource struct {
33
type ContentSource struct {
34
// Type can only be "base64".
34
// Type can only be "base64".
35
Type string `json:"type"`
35
Type string `json:"type"`
36
36
37
// MediaType can be one of:
37
// MediaType can be one of:
38
// - "image/jpeg",
38
// - "image/jpeg",
39
// - "image/png",
39
// - "image/png",
40
// - "image/gif", or
40
// - "image/gif", or
41
// - "image/webp".
41
// - "image/webp".
42
MediaType string `json:"media_type,omitempty"`
42
MediaType string `json:"media_type,omitempty"`
43
43
44
Data string `json:"data,omitempty"`
44
Data string `json:"data,omitempty"`
45
}
45
}
46
46
47
type Usage struct {
47
type Usage struct {
48
InputTokens int `json:"input_tokens"`
48
InputTokens int `json:"input_tokens"`
49
CacheCreationInputTokens *int `json:"cache_creation_input_tokens"`
49
CacheCreationInputTokens *int `json:"cache_creation_input_tokens"`
50
CacheReadInputTokens *int `json:"cache_read_input_tokens"`
50
CacheReadInputTokens *int `json:"cache_read_input_tokens"`
51
OutputTokens int `json:"output_tokens"`
51
OutputTokens int `json:"output_tokens"`
52
}
52
}
53
53
54
type ErrorResponse struct {
54
type ErrorResponse struct {
55
Type string `json:"type"`
55
Type string `json:"type"`
56
Message string `json:"message"`
56
Message string `json:"message"`
57
}
57
}
58
58
59
type MessagesResponse struct {
59
type MessagesResponse struct {
60
Id string `json:"id"`
60
Id string `json:"id"`
61
Type string `json:"type"`
61
Type string `json:"type"`
62
Role string `json:"role"`
62
Role string `json:"role"`
63
Content []ContentBlock `json:"content"`
63
Content []ContentBlock `json:"content"`
64
Model string `json:"model"`
64
Model string `json:"model"`
65
StopReason string `json:"stop_reason"`
65
StopReason *string `json:"stop_reason,omitempty"`
66
StopSequence bool `json:"stop_sequence"`
66
StopSequence *string `json:"stop_sequence,omitempty"`
67
Usage Usage `json:"usage"`
67
Usage Usage `json:"usage"`
68
Error *ErrorResponse `json:"error"`
68
Error *ErrorResponse `json:"error"`
69
}
69
}
70
70
71
type Tool struct {
71
type Tool struct {
72
Type string `json:"type"`
72
Type string `json:"type"`
73
Function *ToolFunction `json:"function"`
73
Function *ToolFunction `json:"function"`
74
}
74
}
75
75
76
type ToolFunction struct {
76
type ToolFunction struct {
77
Name string `json:"name"`
77
Name string `json:"name"`
78
Description string `json:"description"`
78
Description string `json:"description"`
79
InputSchema interface{} `json:"input_schema"`
79
InputSchema interface{} `json:"input_schema"`
80
}
80
}