https://github.com/ma2za/docqa-stream
Document QA with FastAPI, Weaviate and Azure OpenAI
https://github.com/ma2za/docqa-stream
chatgpt fastapi langchain openai weaviate
Last synced: 5 months ago
JSON representation
Document QA with FastAPI, Weaviate and Azure OpenAI
- Host: GitHub
- URL: https://github.com/ma2za/docqa-stream
- Owner: ma2za
- License: apache-2.0
- Created: 2023-08-23T19:16:30.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-12-21T20:21:17.000Z (6 months ago)
- Last Synced: 2025-12-23T08:17:11.640Z (6 months ago)
- Topics: chatgpt, fastapi, langchain, openai, weaviate
- Language: Python
- Homepage:
- Size: 1.79 MB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DocQA Stream with FastAPI, Weaviate and Azure OpenAI
I noticed that there aren't many examples on how to deploy via docker compose
a **FastAPI** application backed by a self-hosted **Weaviate** vector store, so here is one.
The interaction with Azure OpenAI happens through **langchain**.

## Quickstart
The API exposes 2 endpoints:
- **/files/upload**: a POST with a .pdf document to store in a weaviate
collection.
- **/files/query**: a GET with a question to ask based on the uploaded
documents. The response will be streamed back to the user.
### 1) Set the environment
Create a .env in the project root folder in order to set up the environment variables:
```text
WEAVIATE_SERVICE_NAME=weaviate
FASTAPI_PORT=8000
WEAVIATE_PORT=8080
WEAVIATE_COLLECTION = Document
WEAVIATE_DROP_COLLECTION = False
OPENAI_API_TYPE = azure
OPENAI_API_VERSION = 2023-07-01-preview
OPENAI_DEPLOYMENT_NAME=
OPENAI_API_KEY =
OPENAI_API_BASE =
```
If those ports are not in use then you can leave these variables as
they are, you just need to set **OPENAI_API_KEY**, **OPENAI_API_BASE** and
**OPENAI_DEPLOYMENT_NAME** with the values you can find on the Azure dashboard of your
Azure Open AI resource deployment.
### 2) Docker compose
```shell
docker compose up --build
```
Once it is done, you can check if everything is working fine by
making a GET to the following endpoint:
```text
http://localhost:8000/health
```
If you get an OK message than you are ready to go. You can go the openAPI
endpoint and start testing the API:
```text
http://localhost:8000/docs
```
Run tests:
```shell
docker exec fastapi-application poetry run pytest .
```