# Public app: Document searcher, powered by AzureAI

**URL:** <https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103>\
**Category:** Community Inspiration\
**Created:** [22 August 2023 13:37 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103 "2023-08-22T13:37:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jelle](https://community.viktor.ai/user_avatar/community.viktor.ai/jelle/32/620_2.png) [@Jelle](https://community.viktor.ai/u/Jelle)\
**Post date:** [22 August 2023 13:37 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/1 "2023-08-22T13:37:46Z")

</div>

Feel free to ask anything about [Document searcher app](https://demo.viktor.ai/public/document-searcher) in this topic. I will try my best to answer any question. The source code is fully available on our [GitHub page](https://github.com/viktor-platform/document-searcher). Also make sure to check out this [interesting article about this app](https://www.viktor.ai/blog/124/search-engineering-documents-with-viktor-chat-gpt). And also I did a webinar about this application, please check it our on our [YouTube channel](https://www.youtube.com/watch?v=B2r28xSfkig).

A little bit of background information about the app. I spent a couple of days making this app. There are roughly two steps: Extract all the text from the PDF and create the embeddings.  
For the extraction of the PDF I used the library [PyPDF](https://pypi.org/project/pypdf/). Then, I split the text into smaller parts, which AzureAI can handle. For this I used the RecursiveCharacterTextSplitter from Langchain.

```auto
        # Splitter is used to chunk the document, so the chunk size doesn't become too big for AzureAI
        splitter = RecursiveCharacterTextSplitter(chunk_size=1500, chunk_overlap=150, separators=["\n"])
        documents = []
        with pdf_file.open_binary() as pdf_opened:
            reader = PdfReader(pdf_opened)
            for page_number, page in enumerate(reader.pages):
                page_extracted_text = page.extract_text()
                page_extracted_text_split = splitter.split_text(page_extracted_text)
                for split_text in page_extracted_text_split:
                    documents.append(
                        Document(
                            page_content=split_text,
                            metadata={
                                "page_number": page_number + 1,
                                "source": entity_name.split(".")[0],
                            },

```

For the creation of the embeddings the library [Langchain](https://python.langchain.com/docs/get_started/introduction.html) came in handy. It handles a lot of heavy lifting in the chunking, necessary for creating the embeddings. See below for the code:

```auto
        # Embed chunks
        embedded_documents = []
        API_KEY, ENDPOINT = get_API_key()
        client = AzureOpenAI(
            api_key=API_KEY, api_version="2023-10-01-preview", azure_endpoint=ENDPOINT, max_retries=MAX_RETRIES
        )

        for document in documents:
            UserMessage.info(f"Embedding page {document.metadata['page_number']} for " f"{document.metadata['source']}")
            embedding = get_embedding(client, document.page_content)
            embedded_documents.append(
                {
                    "text": document.page_content,
                    "embeddings": embedding,
                    "page_number": document.metadata["page_number"],
                    "source": document.metadata["source"],
                }
            )

```

Finally, the prompt is constructed. This works with the following prompt:

```auto
def get_question_with_context(current_question, context):
    """First create embedding of the question. Then, create the context. Return answer as conversation."""
    prompt = f"""
             Question: {current_question["content"]} \n
             Answer the question based on the context below. When you don't know the answer, say "I don't know the 
             answer, based on the provided context. \n
             Context: {context}\n
             """
    question_with_context = {"role": "user", "content": prompt}
    return question_with_context

```

That’s it! With very little code it is possible to create a very powerful app. Sharing the app is really easy, using VIKTOR.

If you have any questions, please comment in this topic!

---

<div class="post-metadata">

**Author:** ![Daniel](https://community.viktor.ai/user_avatar/community.viktor.ai/daniel/32/233_2.png) [@Daniel](https://community.viktor.ai/u/Daniel)\
**Post date:** [23 August 2023 08:31 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/2 "2023-08-23T08:31:37Z")

</div>

On VIKTOR’s website, an interesting (though admittedly less technical) article is posted regarding this document searcher application!

This may be valuable to explain your colleagues/managers what value apps like these using LLM’s can bring to your organisation.

[Check it out here 🚀](https://www.viktor.ai/blog/124/search-engineering-documents-with-viktor-chat-gpt)

---

<div class="post-metadata">

**Author:** ![LRoga](https://community.viktor.ai/letter_avatar_proxy/v4/letter/l/f08c70/32.png) [@LRoga](https://community.viktor.ai/u/LRoga)\
**Post date:** [24 August 2023 08:22 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/3 "2023-08-24T08:22:31Z")

</div>

Great app. I can really see this app help us save a lot of time by not having to manually scour all the engineering- and contract documents for our projects. It would also clean up the inevitable sloppy mistakes that result from the large amounts of text we have to process.

Would it be possible for us to make this into a ‘simple’-type app where we can create entities for all the projects we have? I would like to prepare the embeddings for the different entities, so our projectteams can quickly start asking questions whenever they like.

---

<div class="post-metadata">

**Author:** ![Jelle](https://community.viktor.ai/user_avatar/community.viktor.ai/jelle/32/620_2.png) [@Jelle](https://community.viktor.ai/u/Jelle)\
**Post date:** [24 August 2023 08:43 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/4 "2023-08-24T08:43:55Z")

</div>

Hi Lloyd, thank you for your kind words.

It is indeed possible to make this into a simple app type, so you don’t have to recreate your embeddings each time you open the app. I am finishing up the public repo and will edit this post when it is finished.

---

<div class="post-metadata">

**Author:** ![Maxime](https://community.viktor.ai/letter_avatar_proxy/v4/letter/m/a9adbd/32.png) [@Maxime](https://community.viktor.ai/u/Maxime)\
**Post date:** [30 August 2023 20:04 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/5 "2023-08-30T20:04:38Z")

</div>

Hi Jell, great example! Thanks for sharing the code and providing a full working demo. That’s a great way to demonstrate the value.

We have implemented a very similar app on Viktor with 3 different modules: 1/ doc query, 2/pre-processed embeddings for our corporate documents, and 3/ the standard chatbot everybody loves to use.

We have received a great feedback from our first users. We plan for more developments and use-cases.

I’m looking forward to reading about the storage options as this has been one of our limiting factors.

---

<div class="post-metadata">

**Author:** ![thomasvdl](https://community.viktor.ai/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@thomasvdl](https://community.viktor.ai/u/thomasvdl)\
**Post date:** [4 August 2025 14:27 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/6 "2025-08-04T14:27:14Z")

</div>

Could this app receive an update to a new version of Python (preferably 3.13), Viktor SDK etc?  
I tried but got stuck in the requirements.  
I would really like to try it out in a local version, as the PDFs I upload keep crashing the app.

---

<div class="post-metadata">

**Author:** ![rvandijk](https://community.viktor.ai/user_avatar/community.viktor.ai/rvandijk/32/866_2.png) [@rvandijk](https://community.viktor.ai/u/rvandijk)\
**Post date:** [6 August 2025 11:06 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/7 "2025-08-06T11:06:36Z")

</div>

Hi Thomas,

Ill give it a look. I noticed there is an issue here:

> <https://github.com/viktor-platform/document-searcher/issues/5>
>
> Could this app (requirements) be updated to work on newer Python versions?

I’ll also implement the new [ChatField](https://docs.viktor.ai/docs/create-apps/user-input/llm-chat/) in the app, as I think this is very useful.

---

<div class="post-metadata">

**Author:** ![thomasvdl](https://community.viktor.ai/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@thomasvdl](https://community.viktor.ai/u/thomasvdl)\
**Post date:** [6 August 2025 11:27 UTC](https://community.viktor.ai/t/public-app-document-searcher-powered-by-azureai/1103/8 "2025-08-06T11:27:59Z")

</div>

Thanks @rvandijk 🙂
