top of page


  • Writer's pictureRoman Guoussev-Donskoi

Simple Web App with Azure OpenAI and Azure Cognitive Search


This post provides super-easy end-to-end example to build ChatGPT-like web app to provide responses based context your PDF documents.

To load PDF into Azure Cognitive Vector Search you can refer to previous post Langchain + OpenAI + Azure Search (

Complete code for this post is in in GitHub . And walkthrough is provided below.

Chainlit is an open-source Python package that makes it incredibly fast to build Chat GPT like applications with your own business logic and data. Overview - Chainlit

first install chainlit

pip install chainlit

Then create python file and add code below

on_chat_start - Chainlit hook is called when user starts session. We will initialize environment and prepare embedding function (chailnlit kindly loads environment from .env file).

now add code to initialize Azure Search and prompt template

Still within start_chat() function add a chain and store it with user session. (We use LangChain Expression Language (LCEL) | 🦜️🔗 Langchain )

Now moving to on_message - Chainlit hook, which is called every time user asks a new question. msg.send() send response to UI.

assuming you have placed code in file run below to start chainlit

chainlit run -w

Screenshot below shows the result

  1. User asked question

  2. Step to retrieve related data using Azure Search vector index

  3. Step to finalize response using Azure Open AI ChatGPT model

  4. Response provided to user

Happy coding!

153 views0 comments

Recent Posts

See All

Query SQL using OpenAI and Langchain

LLMs (such as OpenAI) are good for reasoning but they lack capability interface with outside world. This is where Langchain agents step in: agents provide LLMs with tools to perform actions (for examp

Langchain + OpenAI + Azure Search

Summary Langchain framework makes building of LLM applications much easier, extends capabilities of LLM applications, and introduces structured approach, which facilitates supporting and managing app


Home: Blog2


Home: GetSubscribers_Widget


Your details were sent successfully!

Home: Contact
bottom of page