Skip to content

[Feature] Support other model providers besides OpenAI (Anthropic, Gemini, ...) #5

Description

@rmovva

Support other model providers besides OpenAI (Anthropic, Gemini, ...)

Description

This one is pretty self-explanatory. Currently, HypotheSAEs only supports the OpenAI API. We'd like to add support for other model providers.

Proposed Solution

  1. Modify [llm_api.py]:
  • Instead of only looking for OPENAI_KEY_SAE, look for OPENAI_KEY_SAE or ANTHROPIC_KEY_SAE, etc.
  • Change get_client() so that it can produce a client for another provider
  • Create a dictionary mapping from models to providers
  • get_completion() should check what provider is being used and generate a completion accordingly.
  • Assert that the model being requested for a completion has a valid API key (that is, user cannot request gpt-4o if the only API key provided is for Anthropic)
  1. Wherever we check that OPENAI_KEY_SAE is set, instead make sure that any one of the API keys is set.
  2. Wherever we use default models, set the defaults based on what API key is actually present in the environment variable.

Testing

  • [test_workflow.py] Show that the unit tests pass using a different model provider besides OpenAI.

Nice-to-have

  • Add a screenshot of your results on the [quickstart.ipynb] notebook to the PR, using a pair of interpreter/annotator models from whatever additional API(s) you added.

Notes

I am happy to advise on this. If you have an implementation in progress on a fork, feel free to reply asking for a review or any questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions