diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-10-25 10:27:49 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-10-25 10:27:49 -0400 |
| commit | 6a79f04abca6ea56bdba6bdf6229d05e0fe9532a (patch) | |
| tree | ce57bea766f21676547ec63894ccfa654fd9ee46 /web | |
| parent | 3d50ab9fed61dd8829ac13f5840aca15ff250cf5 (diff) | |
| download | x-6a79f04abca6ea56bdba6bdf6229d05e0fe9532a.tar.xz x-6a79f04abca6ea56bdba6bdf6229d05e0fe9532a.zip | |
web/openai/chatgpt: fix function calling syntax
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'web')
| -rw-r--r-- | web/openai/chatgpt/chatgpt.go | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/web/openai/chatgpt/chatgpt.go b/web/openai/chatgpt/chatgpt.go index 9fb2d09..9f37524 100644 --- a/web/openai/chatgpt/chatgpt.go +++ b/web/openai/chatgpt/chatgpt.go @@ -19,17 +19,27 @@ type Request struct { } type Function struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` - Parameters []Param `json:"parameters"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + Parameters Param `json:"parameters"` } type Param struct { - Type string `json:"type"` - Description string `json:"description,omitempty"` - Enum []string `json:"enum,omitempty"` - Properties map[string]Param `json:"properties,omitempty"` - Required []string `json:"required,omitempty"` + Type string `json:"type"` + Description string `json:"description,omitempty"` + Enum []string `json:"enum,omitempty"` + Properties Properties `json:"properties"` + Required []string `json:"required,omitempty"` +} + +type Properties map[string]Param + +func (p Properties) MarshalJSON() ([]byte, error) { + if len(p) == 0 { + return []byte("{}"), nil + } + + return json.Marshal(map[string]Param(p)) } type Message struct { @@ -39,8 +49,8 @@ type Message struct { } type Funcall struct { - Name string `json:"name"` - Arguments json.RawMessage `json:"arguments"` + Name string `json:"name"` + Arguments string `json:"arguments"` } func (m Message) ProxyFormat() string { |
