dvcrn / ex_openai

Auto-generated Elixir SDK for OpenAI APIs with full typespecs, docs and streaming support
MIT License
71 stars 27 forks source link

`GET` endpoints aren't autogenerated #15

Closed emcmanus closed 6 months ago

emcmanus commented 7 months ago

Many GET endpoints defined in docs.yaml aren't auto-generated.

For example get_assistant:

  /assistants/{assistant_id}:
    get:
      operationId: getAssistant
      tags:
        - Assistants
      summary: Retrieves an assistant.

ExOpenAI.Assistants.get_assistant is not defined:

iex(5)> ExOpenAI.Assistants.
create_assistant/1         create_assistant/2         create_assistant_file/2    create_assistant_file/3    delete_assistant_file/2
delete_assistant_file/3    modify_assistant/1         modify_assistant/2

A non-exhaustive list of missing functions (maybe it provides some clues)

Some GET endpoints are correctly defined, however. E.g.:

Thank you! If you have any hints I'd be happy to drop in to the generator code and poke around.

dvcrn commented 7 months ago

Oh that's odd, let me take a look...

dvcrn commented 6 months ago

The issue comes from the API now following REST more, so there is a GET and POST key on the same /assistants/{id} map. Previously that wasn't the case, so the parse_path function matches the first thing, which happens to be post, causing get to get ignored

https://github.com/dvcrn/ex_openai/blob/8ff4c3eabd173356b577152c6844b2966ba33b97/lib/ex_openai/codegen.ex#L648

and

https://github.com/dvcrn/ex_openai/blob/8ff4c3eabd173356b577152c6844b2966ba33b97/lib/ex_openai/codegen.ex#L553-L566

So will need to update this to handle cases when multiple keys are defined

dvcrn commented 6 months ago

Submitted a PR in https://github.com/dvcrn/ex_openai/pull/17

Could you give this branch a go? I have not used the assistants APIs yet