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

Interacting with my chatbot backend from an external app - Need Help with Endpoints

Open CarlosPSR opened this issue 2 years ago • 5 comments

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

I want to send POST requests from an external app in order to interact with this implementation.

OS and Version?

Linux (ubuntu)

azd version?

run azd version and copy paste here.

Versions

Mention any other details that might be useful


Hello everyone,

I recently deployed the app on Azure. However, as a newcomer to this domain, I still have some questions regarding how to interact with my chatbot from an external chat client.

I kind of understand that, in the repository, some POST request are being made to /chat or /ask endpoints, but I'm not entirely sure about the endpoint I should be using to communicate with my chatbot from an external app instead of using the provided frontend. I have gone through the documentation and explored the Azure portal, but I couldn't find the exact resource or endpoint I need to connect to.

I would greatly appreciate it if anyone could provide guidance.

Thanks in advance, Carlos

CarlosPSR avatar Jun 07 '23 15:06 CarlosPSR

you can use https://webapp-url/chat to make api calls to the backend.

Make sure you add the below values in the body

self, retrieval_mode: str = "hybrid", semantic_ranker: bool = True, semantic_captions: bool = True, top: int = 20, suggest_followup_questions: bool = False,

vrajroutu avatar Jun 10 '23 23:06 vrajroutu

Hi @kishorerv93, would it be possible for you to elaborate a little more in detailed on the approach.

jkongWPJK avatar Jun 14 '23 15:06 jkongWPJK

Hi @kishorerv93 , i tried to make a post request to https://webapp-url/chat with the below values in JSON body { "retrieval_mode": "hybrid", "semantic_ranker": true, "semantic_captions": true, "top": 20, "suggest_followup_questions": false, "use_summaries": true }, Do i miss something?I 'm getting a method not allowed error. @CarlosPSR

mikepaplegend avatar Jun 15 '23 10:06 mikepaplegend

Here is the corrected version @mikepaplegend @jkongWPJK @CarlosPSR

POST https://app-backend-exexexex.azurewebsites.net/chat

BODY:

{ "history": [ { "user": "Tell me about Quantum Computing" } ], "approach": "rrr", "overrides": { "retrieval_mode": "hybrid", "semantic_ranker": true, "semantic_captions": true, "top": 5, "temperature": 1, "prompt_template": "example_template", "prompt_template_prefix": "example_prefix", "prompt_template_suffix": "example_suffix", "exclude_category": "example_category", "suggest_followup_questions": true } }

Headers:

{"Content-Type": "application/json"}

vrajroutu avatar Jun 15 '23 17:06 vrajroutu

Can you explain what does "semantic_captions" mean? Also I don't see "retrieval_mode": "hybrid" in the code, could you mention where it is in the code? Thanks!

PTTrazavi avatar Jun 19 '23 03:06 PTTrazavi

Hi @vrajroutu kindly help check why my api call is returning HTTP error 500

curl -v -v -X POST "https://app-backend-xxxxxxxx.azurewebsites.net/chat" \ -H "Content-Type: application/json" \ -d '{ "history": [ { "user": "Tell me about Quantum Computing" } ], "approach": "rrr", "overrides": { "retrieval_mode": "hybrid", "semantic_ranker": true, "semantic_captions": true, "top": 5, "temperature": 1, "prompt_template": "example_template", "prompt_template_prefix": "example_prefix", "prompt_template_suffix": "example_suffix", "exclude_category": "example_category", "suggest_followup_questions": true } }'

User-Agent: curl/7.88.1 Accept: / Content-Type: application/json Content-Length: 449

< HTTP/1.1 500 Internal Server Error < Content-Length: 23 < Content-Type: application/json < Date: Mon, 30 Oct 2023 14:53:25 GMT < Server: uvicorn < {"error":"'messages'"}

bijunorderia avatar Oct 30 '23 14:10 bijunorderia

The best way to debug a 500 is to look at the App Service logs, specifically the default_docker logs. The README has info on doing that, both at the bottom of troubleshooting section and in FAQ about looking at logs.

pamelafox avatar Oct 30 '23 16:10 pamelafox

Thanks Pamela, it seems like the chat route does not accept requests in the format Vraj had suggested earlier. I did get it to work with azure openai format. But how do I get it to stop giving citations? This body payload that works is as follows { "messages": [ { "role": "system", "content": "XXXXXX system prompt here XXXXXXXXX" }, { "role": "user", "content": "XXXXXXXXXXXXXXXX my prompt here XXXXXXXX" } ], "temperature": 1 }

The output is perfect for my needs except that it cites sources which I don't need.

Sources: [ABC.pdf#page=1] [DEF.pdf#page=1] [GHK.pdf#page=1]

I would like the API endpoint not to output sources. Any advice in this regard would be appreciated.

bijunorderia avatar Oct 30 '23 17:10 bijunorderia

If you do not want those sources, you should modify the prompt in https://github.com/Azure-Samples/azure-search-openai-demo/blob/36478266c221930257a7a4888c097ba1b58b4926/app/backend/approaches/chatreadretrieveread.py#L30 and re-deploy the backend.

And yes, we changed the request format to be a closer match to the openAI format, we are trying to standardize the request/response protocol across Chat apps.

pamelafox avatar Oct 30 '23 18:10 pamelafox

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this issue will be closed.

github-actions[bot] avatar Jan 14 '24 01:01 github-actions[bot]