Azure-Samples / azure-search-openai-demo

A sample app for the Retrieval-Augmented Generation pattern running in Azure, using Azure AI Search for retrieval and Azure OpenAI large language models to power ChatGPT-style and Q&A experiences.
https://azure.microsoft.com/products/search
MIT License
5.91k stars 4.05k forks source link

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

Open CarlosPSR opened 1 year ago

CarlosPSR commented 1 year ago

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

vrajroutu commented 1 year ago

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,

jkongWPJK commented 1 year ago

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

mikepaplegend commented 1 year ago

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

vrajroutu commented 1 year ago

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"}

PTTrazavi commented 1 year ago

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!

bijunorderia commented 10 months ago

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'"}

pamelafox commented 10 months ago

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.

bijunorderia commented 10 months ago

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.

pamelafox commented 10 months ago

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.

github-actions[bot] commented 8 months ago

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.