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

Support other vendors compatible with OpenAI chat completions API #428

Open
pasilastbot opened this issue Jan 28, 2024 · 6 comments
Open

Comments

@pasilastbot
Copy link

pasilastbot commented Jan 28, 2024

There are a lot of other AI vendors that have provided OpenAI compatible chat completions API. It would be nice if we could utilise this library to use them as well. Vendors include e.g.:

Anthropic claude: https://docs.anthropic.com/claude/reference/messages_post
Mistral AI: https://docs.mistral.ai/api/
Perplexity AI: https://docs.perplexity.ai/reference/post_chat_completions
Only thing we would need to change is to add custom_path parameter to configuration, that would allow setting custom API path not /v1/chat/completions.

I have implemented and tested this change in our own fork, can create a pull request if this fits the scope of this Gem.

https://github.com/LastBotInc/ruby-openai?tab=readme-ov-file#other-chat-completion-apis

@eichert12
Copy link

+1 to this idea!

@atestu
Copy link

atestu commented Mar 4, 2024

This would be great, especially following today's announcement https://www.anthropic.com/news/claude-3-family

@alexrudall
Copy link
Owner

Thanks @pasilastbot - this would be really cool - definitely welcome your PR

@etewiah
Copy link

etewiah commented Apr 7, 2024

My 2 cents:

I just found out today that the awesome @obie has created this:

https://github.com/OlympiaAI/open_router

It makes use of the OpenRouter API which is a single unified interface for all LLMs

Perhaps incorporating open_router with ruby-openai would be a good way forward...

@pasilastbot
Copy link
Author

@etewiah I think these are separate needs. OpenRouter is an excellent service, suitable for smaller personal usage. For larger scale production and enterprise data, I (and my clients) prefer that data would not flow via 3rd party web service or use somebody elses AI instances. And to my understanding, ruby-openai would already work with OpenRouter by setting custom domain?

I have also developed a ruby service class on top of ruby-openai, which actually does mapping of system and user messages, function calls, rag documents and images for various AI services. It also calculates the prices and handles rate-limits. It allows me to switch models between OpenAI, Anthropic, Cohere, Google Gemini, Mistral and many others. Right now has some proprietary stuff, but I could think of making it more generic and opensource.

@alexrudall I will make a PR later this week, once have some time for coding.

@mgomes
Copy link
Sponsor

mgomes commented May 16, 2024

@alexrudall would you be open to a PR that adds support for the Claude models? I have a standalone implementation that handles streaming and non-streaming requests. I would need to port it over.

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

No branches or pull requests

6 participants