-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool.go
35 lines (30 loc) · 805 Bytes
/
tool.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
package deepseek
func NewParameters() *JSONSchema {
return &JSONSchema{
Type: "object",
Properties: make(map[string]JSONSchema),
}
}
// WithProperty(age,deepseek.ToolParamTypeInt,"年龄")
// WithProperty(password,deepseek.ToolParamTypeStr,"用户名")
func (p *JSONSchema) WithProperty(name, paramType, description string) *JSONSchema {
p.Properties[name] = JSONSchema{
Type: paramType,
Description: description,
}
return p
}
func (p *JSONSchema) WithRequired(fields ...string) *JSONSchema {
p.Required = append(p.Required, fields...)
return p
}
func NewTool(name, description string, params *JSONSchema) *Tool {
return &Tool{
Type: ChatCompletionToolTypeFunc,
Function: Function{
Description: description,
Name: name,
Parameters: params,
},
}
}