azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

Incorrect API called in chatreadretrieveread.py

Open tekowalsky opened this issue 2 years ago • 5 comments

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.

tekowalsky avatar May 02 '23 20:05 tekowalsky

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.

zhongshuai-cao avatar May 10 '23 02:05 zhongshuai-cao

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 avatar Jun 01 '23 16:06 tickx-cegeka

@tickx-cegeka Did you solve this problem? I am stuck on it.

marceloricciardi avatar Jul 06 '23 21:07 marceloricciardi

See PR #385 where this is being worked on.

pamelafox avatar Jul 06 '23 21:07 pamelafox

Thank you @pamelafox !! It is working now!!

marceloricciardi avatar Jul 07 '23 17:07 marceloricciardi

Closing as this was resolved a while ago.

pamelafox avatar Sep 08 '23 17:09 pamelafox