Error - ValueError: Invalid style: None when running with langchain
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.5k
- Forks
- 4.8k
- PR merge metrics
- No merged PRs in 30d
Description
First, thank you for this great library. It is working well and the basic are working.
We are trying now to use it with langchain and replace openai API with the one of fastchat using this document.
However, in langchain when you set the model to gtp-x it changes automatically to chat mode. This will call the endpoint /v1/chat/completions
This will try to extract the prompt parameter for the model using get_gen_params, which will return the ChatGPTAdapter as the model is gpt-x. is set the conversation template for chatgpt. This model set sep_style=None which is the root cause of the error.
I wrote a simple test that show the error
def test_get_gen_params_gpt4():
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"}
]
gen_params = get_gen_params("gpt-4", messages=messages, temperature=0.9, max_tokens=10, top_p=1.0, echo=False, stream=False, stop=["\n"])
assert gen_params["model"] == "gpt-4"
Question ?
In the mode we are using for langchain we are simulating gpt model using the model name; however, in the backend, the model can be anything. This is why I'm thinking the openai server should not query the model worker to ask for which real model they are using.
At the moment, you only replace the model name, however you should have a notion of model name and real model.
If you are happy with that I could have a look at it
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported test_get_gen_params_gpt4 case and trace the /v1/chat/completions flow in fastchat/serve/openai_api_server.py. Read get_gen_params, the ChatGPTAdapter in fastchat/model/model_adapter.py, and the chatgpt template in fastchat/conversation.py. Done should include a defined handling for the simulated model name and real backend model without the Invalid style: None error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100