-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Replace openai to llama2? #1
Comments
There is a no built-in function for that yet, but it should be relatively simple to make it happen. The main place you will need to edit would be: This is where all the actual API calls to OpenAI are made. You will want to edit the functions there to instead call Llama2. (You may have to edit utils.py + a few prompts if they break when using it with Llama) |
llama.cpp has a neat api_like_OAI.py drop in Flask server to mimic all the OpenAI API calls. You should be able to run that, then set ``openai.api_base = `"http://127.0.0.1:8081"```, and llama2 should work. I'll hopefully have time to try this weekend. |
Yeah that works but you can also use textgenwebui with the openai extension, which is likely what many playing with llama based llm have installed already anyway. |
This version runs on GPT4All model which is free and doesn't require a GPU |
Probably you need this, and replace the base URL with your local URL.
The update to the baseUrl |
@hackhy I'm the maintainer of liteLLM https://github.com/BerriAI/litellm/ - we make it easy to switch between models. Here's how you can call llama2 using liteLLM from litellm import completion
## set ENV variables
os.environ["OPENAI_API_KEY"] = "openai key"
messages = [{ "content": "Hello, how are you?","role": "user"}]
# openai call
response = completion(model="gpt-3.5-turbo", messages=messages)
# llama2 call
response = completion(model="meta-llama/Llama-2-7b-hf", messages=messages) |
"Excuse me, if I want to replace it with Azure OpenAI, what should I do?" |
@joonspk-research I have the same requirement and have changed the code in my fork. Would you want me to file a PR or it's already an ongoing feature on your side? I could send out a PR for it early next week if needed. Thanks. |
@comaniac how are you handling inconsistent completion structure? I'm running into issues with implementing llama because prompt responses don't appear to be coming back in json format and/or are inappropriate. 😓 |
I actually commented this to another issue. I did encounter this problem and my feeling is this framework is tightly-coupled with certain OpenAI models in terms of prompts and response formats. We may need some efforts (e.g., prompt engineering) to make other models work seamlessly. Meanwhile, the first step toward to this goal is to refactor the framework so that we can configure the model. Then we could start tweaking. |
@metrics-dawg @comaniac |
I use my own api_base.
|
Yep, I encountered it too. Unfortunately can't remember what the fix was, but you're welcome to head over to the OSGA GitHub and use the code from there (which includes the fix, as well as other fixes) |
did you success? |
Here's a draft that kinda works: https://github.com/joonspk-research/generative_agents/pull/155/files |
How can I replace the OpenAI API with Llama2?
The text was updated successfully, but these errors were encountered: