This project implements a chat bot using LangChain and LlamaIndex, with a FastAPI backend.
├── app
│ ├── chat_bot.py # Redmine data base assistant
│ ├── evaluators
│ │ └── dataset.ipynb # creating eval datasets on langsmith
│ ├── langchainService
│ │ ├── database_retriver.py
│ │ ├── langchain_util.py
│ │ ├── prompts.py
│ │ ├── sql_agent_graph.py # main file for Redmine db assistant
│ │ ├── summary_chain
│ │ └── test_nodebooks
│ ├── llamaIndex
│ │ ├── llamaIndexAgentDoc.py
│ │ ├── llamaIndexAgent.py
│ │ ├── llamaIndex_utils.py
│ │ └── rnd
│ ├── main.py # main fast api entry point
│ └── utils
│ ├── chat_bot_utils.py
│ ├── connections.py
│ ├── db_info.py
│ ├── models.py
│ └── settings.py
├── docker-compose.yml
├── Dockerfile
├── env_example.txt
├── poetry.lock
├── pyproject.toml
├── README.md- Python 3.10 or higher
- Poetry for dependency management
- Docker and Docker Compose (optional, for containerized deployment)
-
Clone the repository:
git clone <repository-url> cd <project-directory>
-
Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 - -
Set up environment variables:
- Copy
env_example.txtto.env - Fill in the required environment variables in the
.envfile
- Copy
-
Set up python environment
python3 -m venv venv # Activate venvironment . venv/bin/activate
-
If you've added new dependencies or updated existing ones, update the lock file:
poetry lock -
Install dependencies:
poetry install -
Run the FastAPI application:
poetry run uvicorn app.main:app --reload --reload-delay 1 --log-level debug --reload-dir app/ --host 0.0.0.0 --port 8080Alternatively, you can run the application with:
poetry run python app/main.py -
To add new dependencies:
poetry add <package-name> -
To update dependencies:
poetry update
- Build and start the Docker containers:
docker-compose up --build
app/main.py: Entry point of the FastAPI applicationapp/chat_bot.py: Main chat bot logicapp/langchainService/: LangChain related services and utilitiesapp/llamaIndex/: LlamaIndex integration componentsapp/utils/: Utility functions and configurationsapp/evaluators/: Evaluation scripts and notebooks
Adjust the settings in app/utils/settings.py and environment variables as needed.
@app.post("/ask/lang")
async def ask_lang_agent(request: userInput):
response = ask_lang(query=request.question)
return response["output"]