Skip to content
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

Better ChatCompletionFunctionCall interface #118

Merged
merged 8 commits into from
Oct 30, 2023
Merged

Conversation

m1guelpf
Copy link
Contributor

@m1guelpf m1guelpf commented Oct 10, 2023

According to OpenAI's docs, the function_call parameter can only be either none, auto, or { "name": function_name }.

The current interface in this library feels counter-intuitive, and I've often tried to call a custom function using ChatCompletionFunctionCall::String(function_name) instead of ChatCompletionFunctionCall::Object(json!({ "name": custom_function })).

This change proposes a more intuitive interface for this (as a breaking change unfortunately).

@64bit
Copy link
Owner

64bit commented Oct 11, 2023

Actually previous From conversion trait implemented lets you provide function_call parameter without even using ChatCompletionFunctionCall:

CreateChatCompletionRequestArgs::default()
    .function_call("auto") //  or "none" 

OR

CreateChatCompletionRequestArgs::default()
    .function_call(json!({ "name" : "hello_world" })

But yes enum updated in this PR does offer better API.

No worries about breaking changes, because next release v0.15.0 will have other breaking change (already in main) and possible breaking updates from latest openapi spec.

I'll merge this PR once spec sync is addressed too for v0.15.0.

@64bit
Copy link
Owner

64bit commented Oct 30, 2023

Hello @m1guelpf ,

I took liberty to make some changes and kept your idea intact. Essentially use serde instead custom serialization implementation.

Thank you for your patience on this PR!

@64bit 64bit merged commit 2895102 into 64bit:main Oct 30, 2023
@m1guelpf m1guelpf deleted the function-call branch October 30, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants