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

Generate extensible versions of methods by allowing generic requests and response #287

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sufflope
Copy link

Fixes #280

@Sufflope
Copy link
Author

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 impl Streamable could easily be a derive macro.

@Sufflope Sufflope marked this pull request as draft November 13, 2024 20:03
@@ -72,3 +72,7 @@ impl From<UninitializedFieldError> for OpenAIError {
OpenAIError::InvalidArgument(value.to_string())
}
}

pub trait Streamable {
Copy link
Owner

@64bit 64bit Nov 13, 2024

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(
Copy link
Owner

@64bit 64bit Nov 13, 2024

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

@64bit
Copy link
Owner

64bit commented Nov 13, 2024

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 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).

I guess we should document this mechanism somewhere in the readme too.

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 lib.rs so that visitors of docs.rs/async-openai learn about it too.

My primary motivation to use this feature is that I can escape deserialization errors and just plugin serde_json::Value when I'm experimenting/working with compatible API providers.

Also the impl Streamable could easily be a derive macro.

Its one liner code, not a huge burden, hence not required.

@64bit
Copy link
Owner

64bit commented Nov 13, 2024

Also please do add test, it can be very minimal to just compile on a custom request and response.

@Sufflope
Copy link
Author

Thanks for the review, I should have addressed all remarks. Writing good documentation is hard 😅 Let me know what you think.

@Sufflope
Copy link
Author

Hi, a small ping to know if you had time to check the new version with changes wrt. your comments?

@Sufflope Sufflope marked this pull request as ready for review November 26, 2024 15:05
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.

Support Azure content filters in completion
2 participants