64bit / async-openai

Rust library for OpenAI
https://docs.rs/async-openai
MIT License
1.09k stars 161 forks source link

[suggestion] Let list methods take an Option argument #243

Open vrurg opened 1 month ago

vrurg commented 1 month ago

Maybe this is my lack of experience, but when I'm requesting just a full list of objects like files I have to write something like:

    let file_list = files.list::<[&str; 0]>(&[]).await?;

Wouldn't it be better to let it be just files.list(None).await??

64bit commented 1 month ago

Thanks for suggestion, it can be improved, how about having two functions

  1. files.list() with no parameters, which calls another public function below
  2. files.list_with_query(query: Q)

I think files.list() has better ergonomics than files.list(None).

vrurg commented 1 month ago

I think files.list() has better ergonomics than files.list(None).

I agree. I just followed #167 and tried to figure out a good compromise.

BTW, a side note here. The query arguments are currently undocumented (vector store list method uses the same design). Perhaps it worth pointing out at reqwest crate for those looking for understanding without digging into the sources, like I did.

64bit commented 1 month ago

That's a good observation too about lack of documentation on query parameter - any contribution to help improve it is most welcome! (I think one of examples have a usage but that's not very visible/searchable on docs.rs)

Discussion in #167 was in context of missing the call for Files api group. It does seem like it needs to be addressed across the whole crate, that does sound like a breaking change where existing list becomes list_with_query

Its a small breaking-change and and an improvement so why not? Can be released in a version bump.

In addition, breaking change is ok too because list would wrap list_with_query so easy to maintain and implement.

vrurg commented 1 month ago

That's a good observation too about lack of documentation on query parameter - any contribution to help improve it is most welcome! (I think one of examples have a usage but that's not very visible/searchable on docs.rs)

Oh, I know this tone... :) Unfortunately, as you can see, I barely find time on side-projects now. Had to even quit Raku development. Otherwise it'd be my pleasure!

64bit commented 1 month ago

No obligations, thank you for your contributions, the issue is going to be here if you wanna give it a shot.