Closed shauryr closed 10 months ago
🤖
Thank you for your feature request and for providing a detailed description of the issue you're facing. I understand that you're looking to integrate DeepInfra with LlamaIndex due to its cost-effectiveness and similar performance to gpt-4.
Based on the error message you're receiving, it seems that LlamaIndex currently does not recognize the model name meta-llama/Llama-2-70b-chat-hf
as it's not in the list of known models. This is likely because LlamaIndex has not been updated to support DeepInfra yet.
To add support for DeepInfra, we would need to extend the current implementation of LlamaIndex. This would involve creating a new class, similar to how we have classes for other APIs like OpenAI. This new class would handle the interaction with the DeepInfra API.
Here's a high-level overview of the steps:
Import the necessary DeepInfra libraries.
Create a new class, say DeepInfraLLM
, that inherits from the LLM
base class. This class will implement the methods required to interact with the DeepInfra API.
In the __init__
method of this class, initialize the connection to the DeepInfra API.
Implement the chat
, stream_chat
, complete
, and stream_complete
methods to interact with the DeepInfra API. These methods will be similar to the ones in the OpenAI
class but will use DeepInfra's API.
Please note that the exact implementation will depend on the specifics of the DeepInfra API, which is not provided in the context. Therefore, the above steps are a general guide and may need to be adjusted based on the actual API.
As for the error you're encountering, it's happening because the model name you're trying to use is not recognized by LlamaIndex. To fix this, we would need to add the model name meta-llama/Llama-2-70b-chat-hf
to the list of known models in the openai_utils.py
file.
I hope this gives you a good starting point for integrating DeepInfra with LlamaIndex. If you have any further questions or need more clarification, please let me know.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
@shauryr you maybe need to change the api_base parameter to point to deepinfra?
yup I did that above this.
I am interested in this as well, llama_index with deepInfra - llama 2 model...
The following code snippet from deepInfra working fine but want the integration from llama_index. Can we get this feature ASAP?
`
import openai import os
openai.api_key = "#" openai.api_base = "https://api.deepinfra.com/v1/openai"
chat_completion = openai.ChatCompletion.create( model="meta-llama/Llama-2-70b-chat-hf", messages=[{"role": "user", "content": "Hello"}], )
print(chat_completion.choices[0].message.content) `
Closing this as I believe this can be implemented using OpenAILike
https://github.com/run-llama/llama_index/blob/main/llama_index/llms/openai_like.py
Feature Description
DeepInfra is pay per use service like OpenAI but way cheaper - 50% cheaper than gpt3.5-turbo for llama 2
Right now they support openai python api.
So I tried to test my luck, what happens if you use it with llama-index.
You get this trace of error -
Reason
DeepInfra seems like it is fairly new to the game.
Value of Feature
Their product is great! and it is much cheaper than gpt-4 with similar performance. As they add more models to their endpoints I imagine more and more people start using them as a better and cheaper alternative to OAI's GPT.