azure-search-openai-demo
azure-search-openai-demo copied to clipboard
Incorrect API called in chatreadretrieveread.py
Please provide us with the following information:
This issue is for a: (mark with an x)
- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
Minimal steps to reproduce
In the backend, the code attempts to call the "Completion" API using a chat model.
"/app/backend/approaches/chatreadretrieveread.py" at line 98:
completion = **openai.Completion.create**(
engine=**self.chatgpt_deployment**,
prompt=prompt,
temperature=overrides.get("temperature") or 0.7,
max_tokens=1024,
n=1,
stop=["<|im_end|>", "<|im_start|>"])
Mention any other details that might be useful
Code to call the correct API:
completion = **openai.ChatCompletion.create**(
engine=self.chatgpt_deployment,
**messages=[{"role": "user", "content": prompt}],**
temperature=overrides.get("temperature") or 0.7,
max_tokens=1024,
n=1,
stop=["<|im_end|>", "<|im_start|>"])
Thanks! We'll be in touch soon.
I think we are on our own to rewrite the chatcompletion part. I personally tested my gpt3.5 deployment and the chatcompletion is working, but the demo code seems to be developed using gpt3 to mimic gpt3.5 behavior at the beginning, and then switch to gpt3.5 but using it in the old fashion. My general thought is using the chatcompletion shall yield a better result.
Your code does not work for me. I get "Error: module 'openai' has no attribute 'ChatCompletion'" because the openai version was not recent enough. I changed it to openai==0.27.0, but now I get "openai.error.InvalidRequestError: Resource not found", and I can't seem to solve it.
Does someone have a working version? Thanks
@tickx-cegeka Did you solve this problem? I am stuck on it.
See PR #385 where this is being worked on.
Thank you @pamelafox !! It is working now!!
Closing as this was resolved a while ago.