DEV Community

Ayaka Hara
Ayaka Hara

Posted on

How to Deploy a PDF Chatbot as a REST Endpoint and Test with Postman

Utilizing Azure AI Studio's Prompt Flow, we were able to easily implement a chatbot that answers questions about PDF documents. Furthermore, we conducted an evaluation of this chatbot to verify its accuracy. In this blog post, we will take you through the next step: moving beyond just testing the chatbot within Azure AI Studio's chat feature. We will demonstrate how to deploy this chatbot as a REST endpoint and test it using Postman, a popular tool for API development and testing by developers and test engineers.


This post is a part of a series that serves as a step-by-step guide to developing a chatbot with RAG:


Table of Contents

Prerequisites

1. Modify a flow

1-1. Replace with vector db lookup

Need to replace the "index lookup tool" with "vector db lookup".
Add "Vector DB Lookup" from More tools.
Image description

Then, enter a node name (e.g. search) and add it to the flow
Image description

Finally, input values for the node and Save the change.

Image description

If you want to know where these information come from, you can check them in Azure AI Search on Azure portal and navigate to indexes as below.

Image description
Image description

After creating the "Vector DB Lookup" node your graph will look like the screenshot below.

Image description

1-2. Delete an unnecessary node

Delete the "Vector Index Lookup - search_question_from_indexed_docs" and Save the change
Image description

1-3. Change the value of search result node

Change the value of search_result to "$(search.output)" in generate_prompt_context node and Save the change

Image description

After completing all the steps to replace the "index lookup tool" with "vector db lookup" your graph will look like the screenshot below.

Image description

1-4. Try chat

Try the chat with your PDFs to make sure if it works as expected.

Image description

2. Deploy a flow

2-1. Deploy a flow from Prompt Flow tab

Click "Deploy",
Image description

and change basic settings if you wish.
Image description

Review the deployment settings and Create it.
Image description

It will take around 10 minutes to complete the deployment.

2-2. Test the deployed endpoint

Move to Deployments tab and select the deployed endpoint,
Image description

then test the endpoint.
Image description

3. Test the endpoint with Postman

3-1. Copy Rest endpoint and Primary key

Copy REST endpoint and Primary key from Consume tab

Image description

3-2. Configure on Postman

  • POST : REST endpoint
  • Headers
KEY VALUE
Authorization Bearer {Primary key}
Content-Type application/json
  • Body : raw (json)
{"question":"who are you","chat_history":[]}
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

3-3. Test the endpoint

Click "Send" and get the response!

Image description

Conclusion

In this blog, we have explored how to deploy the chatbot, implemented using Azure AI Studio's Prompt Flow, as a REST endpoint and how to test it using Postman. Next, we plan to introduce a method for implementing a simple application that utilizes the REST endpoint we've just deployed.

Top comments (0)