1
package api
1
package api
2
2
3
type NewFuncRequest struct {
3
type NewFuncRequest struct {
4
Name string `json:"name"` // no need to be unique
4
Name string `json:"name"` // no need to be unique
5
JsCode string `json:"js_code,omitempty"` // LLM2 must be nil
5
JsCode string `json:"js_code,omitempty"` // LLM2 must be nil
6
LLM2 *LLMFunc `json:"llm2,omitempty"` // JSCode must be ""
6
LLM2 *LLMFunc `json:"llm2,omitempty"` // JSCode must be ""
7
}
7
}
8
8
9
type NewFuncResponse struct {
9
type NewFuncResponse struct {
10
Name string `json:"name"`
10
Name string `json:"name"`
11
DateCreated string `json:"date_created"` // RFC8601 with millis
11
DateCreated string `json:"date_created"` // RFC8601 with millis
12
}
12
}
13
13
14
type DeleteFuncRequest struct {
14
type DeleteFuncRequest struct {
15
Name string `json:"name"`
15
Name string `json:"name"`
16
}
16
}
17
17
18
type DeleteFuncResponse struct {
18
type DeleteFuncResponse struct {
19
}
19
}
20
20
21
type FuncVersion struct {
21
type FuncVersion struct {
22
// Hash is the globally unique ID of this immutable object.
22
// Hash is the globally unique ID of this immutable object.
23
Hash string `json:"hash"`
23
Hash string `json:"hash"`
24
24
25
// Date is the time of creation, according to the server's clock.
25
// Date is the time of creation, according to the server's clock.
26
Date string `json:"date"`
26
Date string `json:"date"`
27
27
28
// JS is JavaScript code that implements this function.
28
// JS is JavaScript code that implements this function.
29
JS string `json:"js,omitempty"`
29
JS string `json:"js,omitempty"`
30
30
31
// LLM is the old "provider:model" string. Deprecated.
31
// LLM is the old "provider:model" string. Deprecated.
32
LLM string `json:"llm,omitempty"`
32
LLM string `json:"llm,omitempty"`
33
33
34
// LLM2 confugures where an how the LLM is run.
34
// LLM2 confugures where an how the LLM is run.
35
LLM2 *LLMFunc `json:"llm2,omitempty"`
35
LLM2 *LLMFunc `json:"llm2,omitempty"`
36
}
36
}
37
37
38
type LLMFunc struct {
38
type LLMFunc struct {
39
// Provider is "openai", "anthropic", "fireworks", etc.
39
// Provider is "openai", "anthropic", "fireworks", etc.
40
Provider string `json:"provider"`
40
Provider string `json:"provider"`
41
41
42
// Model is the provider-assigned name of the LLM.
42
// Model is the provider-assigned name of the LLM.
43
Model string `json:"model"`
43
Model string `json:"model"`
44
44
45
CanSeeImages bool `json:"can_see_images"`
45
CanSeeImages bool `json:"can_see_images"`
46
CanHaveSystemPromps bool `json:"can_have_system_prompts"`
46
CanHaveSystemPromps bool `json:"can_have_system_prompts"`
47
CanUseTools bool `json:"can_use_tools"`
47
CanUseTools bool `json:"can_use_tools"`
48
CanStream bool `json:"can_stream"`
48
}
49
}
49
50
50
type Func struct {
51
type Func struct {
51
Name string `json:"name"`
52
Name string `json:"name"`
52
Versions []FuncVersion `json:"versions"`
53
Versions []FuncVersion `json:"versions"`
53
}
54
}
54
55
55
type ListFuncsResponse struct {
56
type ListFuncsResponse struct {
56
Funcs []Func `json:"funcs"`
57
Funcs []Func `json:"funcs"`
57
}
58
}
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
// MessageRequest is generalizes across OpenAI, Anthropic, etc.
8
// MessageRequest is generalizes across OpenAI, Anthropic, etc.
9
type MessagesRequest struct {
9
type MessagesRequest struct {
10
Model string `json:"model"`
10
Model string `json:"model"`
11
Messages []ChatMessage `json:"messages"`
11
Messages []ChatMessage `json:"messages"`
12
MaxTokens int `json:"max_tokens"`
12
MaxTokens int `json:"max_tokens"`
13
System string `json:"system,omitempty"`
13
System string `json:"system,omitempty"`
14
Temperature float64 `json:"temperature"`
14
Temperature float64 `json:"temperature"`
15
Tools []Tool `json:"tools,omitempty"`
15
Tools []Tool `json:"tools,omitempty"`
16
}
16
}
17
17
18
type ContentBlock struct {
18
type ContentBlock struct {
19
// Type is "text", "image", "tool_use", or "tool_result".
19
// Type is "text", "image", "tool_use", or "tool_result".
20
Type string `json:"type"`
20
Type string `json:"type"`
21
21
22
// Text is for Type="text"
22
// Text is for Type="text"
23
Text string `json:"text,omitempty"`
23
Text string `json:"text,omitempty"`
24
24
25
// Source is for Type="image"
25
// Source is for Type="image"
26
Source *ContentSource `json:"source,omitempty"`
26
Source *ContentSource `json:"source,omitempty"`
27
27
28
// I, Name, and Input are for Type="tool_use".
28
// I, Name, and Input are for Type="tool_use".
29
ID string `json:"id,omitempty"`
29
ID string `json:"id,omitempty"`
30
Name string `json:"name,omitempty"`
30
Name string `json:"name,omitempty"`
31
Input interface{} `json:"input,omitempty"`
31
Input interface{} `json:"input,omitempty"`
32
32
33
// ToolUseID, Content, and Output are for
34
// Type="tool_result".
35
ToolUseID string `json:"tool_use_id,omitempty"`
36
Content string `json:"content,omitempty"`
37
Output string `json:"output,omitempty"`
33
}
38
}
34
39
35
type ContentSource struct {
40
type ContentSource struct {
36
// Type can only be "base64".
41
// Type can only be "base64".
37
Type string `json:"type"`
42
Type string `json:"type"`
38
43
39
// MediaType can be one of:
44
// MediaType can be one of:
40
// - "image/jpeg",
45
// - "image/jpeg",
41
// - "image/png",
46
// - "image/png",
42
// - "image/gif", or
47
// - "image/gif", or
43
// - "image/webp".
48
// - "image/webp".
44
MediaType string `json:"media_type,omitempty"`
49
MediaType string `json:"media_type,omitempty"`
45
50
46
Data string `json:"data,omitempty"`
51
Data string `json:"data,omitempty"`
47
}
52
}
48
53
49
type Usage struct {
54
type Usage struct {
50
InputTokens int `json:"input_tokens,omitempty"`
55
InputTokens int `json:"input_tokens,omitempty"`
51
CacheCreationInputTokens *int `json:"cache_creation_input_tokens,omitempty"`
56
CacheCreationInputTokens *int `json:"cache_creation_input_tokens,omitempty"`
52
CacheReadInputTokens *int `json:"cache_read_input_tokens,omitempty"`
57
CacheReadInputTokens *int `json:"cache_read_input_tokens,omitempty"`
53
OutputTokens int `json:"output_tokens,omitempty"`
58
OutputTokens int `json:"output_tokens,omitempty"`
54
}
59
}
55
60
56
type ErrorResponse struct {
61
type ErrorResponse struct {
57
Type string `json:"type"`
62
Type string `json:"type"`
58
Message string `json:"message"`
63
Message string `json:"message"`
59
}
64
}
60
65
61
type MessagesResponse struct {
66
type MessagesResponse struct {
62
Id string `json:"id"`
67
Id string `json:"id"`
63
Type string `json:"type"`
68
Type string `json:"type"`
64
Role string `json:"role"`
69
Role string `json:"role"`
65
Content []ContentBlock `json:"content"`
70
Content []ContentBlock `json:"content"`
66
Model string `json:"model"`
71
Model string `json:"model"`
67
StopReason *string `json:"stop_reason,omitempty"`
72
StopReason *string `json:"stop_reason,omitempty"`
68
StopSequence *string `json:"stop_sequence,omitempty"`
73
StopSequence *string `json:"stop_sequence,omitempty"`
69
Usage Usage `json:"usage"`
74
Usage Usage `json:"usage"`
70
Error *ErrorResponse `json:"error,omitempty"`
75
Error *ErrorResponse `json:"error,omitempty"`
71
}
76
}
72
77
73
type Tool struct {
78
type Tool struct {
74
Type string `json:"type"`
79
Type string `json:"type"`
75
Function *ToolFunction `json:"function"`
80
Function *ToolFunction `json:"function"`
76
}
81
}
77
82
78
type ToolFunction struct {
83
type ToolFunction struct {
79
Name string `json:"name"`
84
Name string `json:"name"`
80
Description string `json:"description"`
85
Description string `json:"description"`
81
InputSchema interface{} `json:"input_schema"`
86
InputSchema interface{} `json:"input_schema"`
82
}
87
}