-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 43a2306
Showing
15 changed files
with
828 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Include any files or directories that you don't want to be copied to your | ||
# container here (e.g., local build artifacts, temporary files, etc.). | ||
# | ||
# For more help, visit the .dockerignore file reference guide at | ||
# https://docs.docker.com/go/build-context-dockerignore/ | ||
|
||
**/.DS_Store | ||
**/__pycache__ | ||
**/.venv | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/compose.y*ml | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
venv/ | ||
__pycache__/ | ||
chroma/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Comments are provided throughout this file to help you get started. | ||
# If you need more help, visit the Dockerfile reference guide at | ||
# https://docs.docker.com/go/dockerfile-reference/ | ||
|
||
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 | ||
|
||
ARG PYTHON_VERSION=3.12.5 | ||
FROM python:${PYTHON_VERSION}-slim as base | ||
|
||
# Prevents Python from writing pyc files. | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Keeps Python from buffering stdout and stderr to avoid situations where | ||
# the application crashes without emitting any logs due to buffering. | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app | ||
|
||
# Create a non-privileged user that the app will run under. | ||
# See https://docs.docker.com/go/dockerfile-user-best-practices/ | ||
ARG UID=10001 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
appuser | ||
|
||
# Download dependencies as a separate step to take advantage of Docker's caching. | ||
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. | ||
# Leverage a bind mount to requirements.txt to avoid having to copy them into | ||
# into this layer. | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
--mount=type=bind,source=requirements.txt,target=requirements.txt \ | ||
python -m pip install -r requirements.txt | ||
|
||
# Switch to the non-privileged user to run the application. | ||
USER appuser | ||
|
||
# Copy the source code into the container. | ||
COPY . . | ||
|
||
# Expose the port that the application listens on. | ||
EXPOSE 8000 | ||
|
||
# Run the application. | ||
CMD uvicorn 'main:app' --host=0.0.0.0 --port=8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### Building and running your application | ||
|
||
When you're ready, start your application by running: | ||
`docker compose up --build`. | ||
|
||
Your application will be available at http://localhost:8000. | ||
|
||
### Deploying your application to the cloud | ||
|
||
First, build your image, e.g.: `docker build -t myapp .`. | ||
If your cloud uses a different CPU architecture than your development | ||
machine (e.g., you are on a Mac M1 and your cloud provider is amd64), | ||
you'll want to build the image for that platform, e.g.: | ||
`docker build --platform=linux/amd64 -t myapp .`. | ||
|
||
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`. | ||
|
||
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/) | ||
docs for more detail on building and pushing. | ||
|
||
### References | ||
* [Docker's Python guide](https://docs.docker.com/language/python/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# RAG FASTAPI For Pdf,txt,doc files | ||
|
||
![ss6](./imgs/fastapi.png) | ||
![ss6](./imgs/pic.png) | ||
|
||
## Table of Contents | ||
|
||
- [API Documentation](#api-documentation) | ||
- [Setup Instructions](#setup-instructions) | ||
- [Prerequisites](#prerequisites) | ||
- [Installation](#installation) | ||
- [Running the Application](#running-the-application) | ||
- [Docker Setup](#docker-setup) | ||
- [Potential Improvements](#potential-improvements) | ||
- [Contributing](#contributing) | ||
|
||
## API Documentation | ||
|
||
The API provides several endpoints for interacting with the application. You can access the detailed API documentation via Postman. To get started: | ||
|
||
1. **API DOCS**: check `api-documentation.pdf` file | ||
2. **API Endpoints**: | ||
|
||
- **Process Document** | ||
- **Endpoint**: `POST /api/documents/process` | ||
- **Input**: File path | ||
- **Output**: Asset ID | ||
- **Description**: This endpoint processes the document at the given file path and returns an Asset ID. | ||
- **Start Chat** | ||
- **Endpoint**: `POST /api/chat/start` | ||
- **Input**: Asset ID | ||
- **Output**: Chat thread ID | ||
- **Description**: This endpoint initiates a chat session using the provided Asset ID and returns a Chat thread ID. | ||
- **Send Chat Message** | ||
- **Endpoint**: `POST /api/chat/message` | ||
- **Input**: Chat thread ID, User message | ||
- **Output**: Agent response (streamed) | ||
- **Description**: This endpoint sends a user message to the chat thread and streams the agent's response in real-time. | ||
- **Get Chat History** | ||
- **Endpoint**: `GET /api/chat/history` | ||
- **Input**: Chat thread ID | ||
- **Output**: Chat history | ||
- **Description**: This endpoint retrieves the full history of a chat session using the provided Chat thread ID. | ||
|
||
## Setup Instructions | ||
|
||
### Prerequisites | ||
|
||
Ensure you have the following installed: | ||
|
||
- Python 3.x | ||
- pip (Python package manager) | ||
- Docker (for containerized setup) | ||
|
||
### Setting Up a Virtual Environment | ||
|
||
It is recommended to use a virtual environment to manage dependencies for your project. Here’s how you can set one up: | ||
|
||
1. Navigate to your project directory: | ||
|
||
```bash | ||
cd myapp | ||
|
||
``` | ||
|
||
2. Create a virtual environment: | ||
|
||
```bash | ||
python3 -m venv venv | ||
``` | ||
|
||
3. Activate the virtual environment: | ||
- On macOS and Linux: | ||
|
||
```bash | ||
source venv/bin/activate | ||
``` | ||
|
||
- On Windows: | ||
|
||
```bash | ||
.\\venv\\Scripts\\activate | ||
``` | ||
|
||
4. Once activated, your terminal should show the virtual environment name, indicating that you are working inside the virtual environment. | ||
|
||
### Installation | ||
|
||
1. Clone the repository: | ||
|
||
```bash | ||
git clone <url> | ||
cd myapp | ||
``` | ||
2. Install the required Python packages: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
### Running the Application | ||
|
||
To run the application locally, use the following command: | ||
|
||
```bash | ||
python main.py | ||
``` | ||
|
||
This will start the server on `http://localhost:8000`. You can test the endpoints using at `http://localhost:8000/docs` | ||
|
||
You can also run the sample streamlit app using - `streamlit run streamlit.py` | ||
|
||
### Docker Setup | ||
|
||
To set up and run the application using Docker, follow these steps: | ||
|
||
1. **Build the Docker image**: | ||
|
||
```bash | ||
docker build -t myapp . | ||
``` | ||
2. **Run the Docker container**: | ||
|
||
```bash | ||
docker run -p 8000:8000 myapp | ||
``` | ||
3. The application will be accessible at `http://localhost:8000`. | ||
|
||
## Potential Improvements | ||
|
||
- **Authentication**: Implement user authentication and authorization to secure endpoints. | ||
- **Error Handling**: Enhance error handling mechanisms for better API responses. | ||
- **Logging**: Introduce logging to track application activities and errors. | ||
- **Testing**: Add unit and integration tests to ensure code reliability. | ||
- **Scalability**: Consider optimizing the application for performance and scalability. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue to discuss improvements or fixes. |
Binary file not shown.
Oops, something went wrong.