-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(chat): support function call api #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #367 +/- ##
==========================================
- Coverage 95.22% 95.16% -0.06%
==========================================
Files 17 18 +1
Lines 670 786 +116
==========================================
+ Hits 638 748 +110
- Misses 22 26 +4
- Partials 10 12 +2
|
|
Looking forward to it |
|
@sashabaranov @Ccheers But go-openai is just a client library for OpenAI API. Should go-openai provide high-level abstraction like It may be difficult to design for abstraction between Azure OpenAI and OpenAI in the future when Azure OpenAI supports "Function calling". I'm a bit concerned about other additional dependent libraries. Perhaps go-openai values maintenance cost and lightweight and dares to have zero dependencies. It might be better to first just add some fields for "Function calling" to the |
I quite agree! The signature of withfunctioncall is not universal enough, so users should decide for themselves. |
|
My 2p: it seems gjson library is only used to extract |
This is too difficult because the parameters of |
It seems that using map[string]interface{} to deconstruct JSON for parameter extraction is also possible at present, but it is relatively more complicated. |
|
I agree with the issues raised here, I think this library should be kept very simple. Although the "function call" information that the API returns is meant to be used to call a function in the client's local environment, that might not be how everyone intends to use it. I would prefer to simply have the ChatCompletionMessage (etc) structs updated to include to support the function call details, and leave it up to the client to decide how they will consume that information. That said, I do think @Ccheers has done some great work which I will use as reference in my own project! |
In the current implementation, JSON deserialization relies on Go Struct. However, the definition of |
I think this is a trade-off. If we consider introducing |
3a153ef to
7e76a68
Compare
|
My vote is to not accept this PR just yet. We already have CreateChatCompletion() as well as CreateChatCompletionStream(), adding CreateChatCompletionWithFunctionCall() is a bit over the top when it's all the same API! I think the new function call feature should be able to fit nicely into the existing ChatCompletion structure (like @vvatanabe said), and I am willing to work on an alternate solution (tomorrow, probably) if no one else gets to it first. |
implement #360