cyberchitta / openai_ex

Community maintained Elixir library for OpenAI API
https://hexdocs.pm/openai_ex
Apache License 2.0
140 stars 19 forks source link

Restore completions API #103

Closed kalocide closed 2 months ago

kalocide commented 2 months ago

Restores OpenaiEx.Completions API as outlined in #102, and the corresponding livebook.

The code here is just what was in the original module prior to its removal. I tested with meta-llama/llama-3.1-405b on OpenRouter. Both normal and streaming completions work, and the module has feature parity with the Python library, so I think rewriting it is unnecessary.

Anyways, thanks so much ^^ your code is a pleasure to work with.

restlessronin commented 2 months ago

@kalocide thank you for the kind words and the PR.

I made one small change. In v0.8.0, I split the API call "create" into "create!" and "create" - for exception throwing and [:ok, :error] returning versions. This was done throughout the API, to bring it in line with eclipse conventions.

I just did this for completions as well (which was left out of the v0.8.0 release)

Unfortunately, the original use of create was more like create!, so I have updated the notebook to use create! instead of create (to minimize other changes). It should work as is, but it would be great if you could test that as well.

Will get this merged as soon as you confirm that the changes work.

kalocide commented 2 months ago

Makes sense, I'm a fan of the ! methods. And yep, the changes work great :)

restlessronin commented 2 months ago

@kalocide published to hex.pm as v0.8.3.

restlessronin commented 1 month ago

@kalocide, I just realized that somehow your account has not been added to the contributors for this repo. I'm not sure why. I'm guessing it may be due to the fact that I added the last commit to your PR when I modified it.

In any case, in the interest of acknowledging contributions, I would like to make sure that your account appears in the contributor list. If you could add a PR that makes a small improvement to the continuations notebook, I would accept it.

Alternatively, and this would be better in some ways, if you have an anonymous github email address, I can add you as a co-author on a suitable commit.

Either of these should get your account into the contributor list.