feat(chat): support function call api#369
Conversation
Codecov Report
@@ Coverage Diff @@
## master #369 +/- ##
=======================================
Coverage 95.22% 95.22%
=======================================
Files 17 17
Lines 670 670
=======================================
Hits 638 638
Misses 22 22
Partials 10 10
|
|
Looks Good 👍 |
sashabaranov
left a comment
There was a problem hiding this comment.
Folks, thank you for all your work poured into this! 🙌🏻
| LogitBias map[string]int `json:"logit_bias,omitempty"` | ||
| User string `json:"user,omitempty"` | ||
| Functions []*FunctionDefine `json:"functions,omitempty"` | ||
| FunctionCall string `json:"function_call,omitempty"` |
There was a problem hiding this comment.
function_call can be a string or an object: https://platform.openai.com/docs/api-reference/chat/create#chat/create-function_call
There was a problem hiding this comment.
+1 to this -- this is crucial functionality because you can use it to force the model to use a particular function, but only as an object.
| // - https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb | ||
| Name string `json:"name,omitempty"` | ||
|
|
||
| FunctionCall *FunctionCall `json:"function_call,omitempty"` |
There was a problem hiding this comment.
FunctionCall should be added to ChatCompletionStreamChoiceDelta too.
| FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` | ||
| LogitBias map[string]int `json:"logit_bias,omitempty"` | ||
| User string `json:"user,omitempty"` | ||
| Functions []*FunctionDefine `json:"functions,omitempty"` |
There was a problem hiding this comment.
any reason to make Functions a slice of pointer? It makes constructing request much harder. Why not []FunctionDefine?
| Name string `json:"name"` | ||
| Description string `json:"description,omitempty"` | ||
| // it's required in function call | ||
| Parameters *FunctionParams `json:"parameters"` |
| @@ -27,6 +30,14 @@ type ChatCompletionMessage struct { | |||
| // - https://github.com/openai/openai-python/blob/main/chatml.md | |||
| // - https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb | |||
| Name string `json:"name,omitempty"` | |||
There was a problem hiding this comment.
name is documented now, this document should be updated.
| // Enum is a enum of JSON Schema. It used if Type is JSONSchemaTypeString. | ||
| Enum []string `json:"enum,omitempty"` | ||
| // Properties is a properties of JSON Schema. It used if Type is JSONSchemaTypeObject. | ||
| Properties map[string]*JSONSchemaDefine `json:"properties,omitempty"` |
There was a problem hiding this comment.
Similar to those pointed out by @j178 , this is also an unnecessary use of pointers.
No description provided.