wrdias commited on
Commit
7f3eb40
·
verified ·
1 Parent(s): 46fe793

Upload 6 files

Browse files
Files changed (6) hide show
  1. .dockerignore +9 -0
  2. .gitignore +6 -0
  3. Dockerfile +7 -0
  4. Readme.md +55 -0
  5. docker-compose.yaml +19 -0
  6. requirements.txt +12 -0
.dockerignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ myenv/
2
+ /app/__pycache__/
3
+ ./app/__pycache__/
4
+ ./app/__pycache__/
5
+
6
+ *.env
7
+ *.env.*
8
+ env.*
9
+
.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ ./myenv
2
+ .env
3
+ ./env
4
+ ./.env
5
+ /myenv
6
+ myenv
Dockerfile ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ FROM python:3.8.10-slim
2
+
3
+ WORKDIR /code
4
+ COPY ./requirements.txt /code/requirements.txt
5
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
6
+ COPY ./app /code
7
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Readme.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FastAPI for interacting with langchain and GPT-3.5 based chatbot, with Redis database as the vector store-backed retriever memory.
2
+
3
+ ## How to run
4
+
5
+ ### Using virtual environment:
6
+
7
+ 1. Set up a virtual environment:
8
+ <code>python -m venv myenv</code>
9
+
10
+ 2. Create a .env file and add 'OPENAI_API_KEY', 'REDIS_URL', and 'HUGGINGFACEHUB_API_TOKEN as variables
11
+
12
+ 3. Navigate to the app directory:
13
+ <code>cd app</code>
14
+
15
+ 4. Install the required dependencies:
16
+ <code>pip install -r requirements.txt</code>
17
+
18
+ 5. Run the FastAPI server with uvicorn:
19
+ <code>uvicorn main:app --reload --port=8000 --host=0.0.0.0</code>
20
+
21
+
22
+ ### Using Docker Compose:
23
+
24
+ 1. Build the Docker images:
25
+ <code>docker-compose build</code>
26
+
27
+ 2. Start the Docker containers:
28
+ <code>docker-compose up</code>
29
+
30
+
31
+ ## API Documentation
32
+
33
+ ### Changing User for Redis Vector Store
34
+
35
+ To change the Redis vector store retriever memory to a specific user, send a request to the following endpoint:
36
+
37
+ <code>localhost:8000/api/{username}</code>
38
+
39
+ Replace `{username}` with the desired username. This action ensures that the chatbot will only retrieve data from the Redis database specific to that user.
40
+
41
+
42
+ ### Accessing API Documentation
43
+
44
+ For detailed documentation on how to interact with the APIs in the application, visit:
45
+ <code>localhost:8000/docs</code>
46
+
47
+
48
+ This endpoint provides comprehensive guidance on utilizing the APIs effectively.
49
+
50
+ ---
51
+
52
+ You can seamlessly integrate this backend into your existing application, providing your users with access to a dedicated vector-based database chatbot. Remember to generate the repsective API keys.
53
+
54
+
55
+
docker-compose.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3'
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ command: sh -c "uvicorn main:app --reload --port=8000 --host=0.0.0.0"
9
+ ports:
10
+ - "8000:8000"
11
+ volumes:
12
+ - ./app:/code/app
13
+ environment:
14
+ - OPENAI_API_KEY=YPUR-OPENAI_API_KEY
15
+ - REDIS_URL=YOUR-REDIS_URL
16
+ - HUGGINGFACEHUB_API_TOKEN=YOUR-HUGGINGFACEHUB_API_TOKEN
17
+
18
+
19
+
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain
2
+ openai
3
+ tiktoken
4
+ langchain_openai
5
+ redis[hiredis]
6
+ python-dotenv
7
+ huggingface_hub
8
+ langchainhub
9
+ langserve[all]
10
+ fastapi
11
+ pydantic==1.10.13
12
+ uvicorn