-
Notifications
You must be signed in to change notification settings - Fork 186
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
Generate extensible versions of methods by allowing generic requests and response #287
base: main
Are you sure you want to change the base?
Conversation
For the moment I only used the macro on my use case, would you prefer to add it to all relevant methods in the code, or keep it "on demand" when someone needs an extension for some use case? I guess we should document this mechanism somewhere in the readme too. Also the |
async-openai/src/types/mod.rs
Outdated
@@ -72,3 +72,7 @@ impl From<UninitializedFieldError> for OpenAIError { | |||
OpenAIError::InvalidArgument(value.to_string()) | |||
} | |||
} | |||
|
|||
pub trait Streamable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this will become public API and not just internal to crate, in which case Streamable
is very overloaded word and open to individual interpretation, becauses usually responses are "streamable" and not requests but here we will be using it in context of a request.
I'd suggest renaming it. Some suggestions like: trait RequestForStream
or method to be is_request_for_stream
or something more appropriate where its less open to interpretation.
@@ -20,11 +23,12 @@ impl<'c, C: Config> Chat<'c, C> { | |||
} | |||
|
|||
/// Creates a model response for the given chat conversation. | |||
#[extensible] | |||
pub async fn create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must also add the macro to the companion method Chat::create_stream
I checked both gemini and ollama, so for practical purposes doesn't require to be added on all APIs and we can resort to on-demand additions (must be documented though - more below).
Absolutely, please document it on both async-openai/README.md so Github repo and crates.io visitor knows they can "Bring your own types" and also in My primary motivation to use this feature is that I can escape deserialization errors and just plugin
Its one liner code, not a huge burden, hence not required. |
Also please do add test, it can be very minimal to just compile on a custom request and response. |
…and response Fixes 64bit#280
d0cad81
to
de31d8c
Compare
Thanks for the review, I should have addressed all remarks. Writing good documentation is hard 😅 Let me know what you think. |
Hi, a small ping to know if you had time to check the new version with changes wrt. your comments? |
Fixes #280