phuochungus commited on
Commit
8fab380
1 Parent(s): 42a588a

save change

Browse files
Files changed (11) hide show
  1. .dockerignore +3 -0
  2. .gitattributes +35 -0
  3. .gitignore +3 -0
  4. .vscode/settings.json +5 -0
  5. Dockerfile +26 -0
  6. README.md +91 -0
  7. app/__init__.py +3 -0
  8. app/server.py +21 -0
  9. compose.yml +9 -0
  10. pyproject.toml +24 -0
  11. requirements.txt +6 -0
.dockerignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ __pycache__
2
+ **/.env
3
+ compose.yml
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ __pycache__
2
+ **/.env
3
+ **/*.pdf
.vscode/settings.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "yaml.schemas": {
3
+ "https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json": "file:///d%3A/template/app/compose.yaml"
4
+ }
5
+ }
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ RUN apt-get update && apt-get install -y sudo
4
+
5
+ RUN useradd -m -u 1000 user
6
+
7
+ USER user
8
+
9
+ ENV HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH
11
+
12
+ WORKDIR $HOME/app
13
+
14
+ COPY --chown=user requirements.txt .
15
+
16
+ RUN pip install -r requirements.txt
17
+
18
+ COPY --chown=user ./packages ./packages
19
+
20
+ RUN cd packages/rag-redis && pip install -e .
21
+
22
+ COPY --chown=user . .
23
+
24
+ EXPOSE 8080
25
+
26
+ CMD exec uvicorn app.server:app --host 0.0.0.0 --port 8080
README.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Chatbot AI
3
+ emoji: 🐠
4
+ colorFrom: purple
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ app_port: 8080
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
13
+ # app
14
+
15
+ ## Installation
16
+
17
+ Install the LangChain CLI if you haven't yet
18
+
19
+ ```bash
20
+ pip install -U langchain-cli
21
+ ```
22
+
23
+ ## Adding packages
24
+
25
+ ```bash
26
+ # adding packages from
27
+ # https://github.com/langchain-ai/langchain/tree/master/templates
28
+ langchain app add $PROJECT_NAME
29
+
30
+ # adding custom GitHub repo packages
31
+ langchain app add --repo $OWNER/$REPO
32
+ # or with whole git string (supports other git providers):
33
+ # langchain app add git+https://github.com/hwchase17/chain-of-verification
34
+
35
+ # with a custom api mount point (defaults to `/{package_name}`)
36
+ langchain app add $PROJECT_NAME --api_path=/my/custom/path/rag
37
+ ```
38
+
39
+ Note: you remove packages by their api path
40
+
41
+ ```bash
42
+ langchain app remove my/custom/path/rag
43
+ ```
44
+
45
+ ## Setup LangSmith (Optional)
46
+ LangSmith will help us trace, monitor and debug LangChain applications.
47
+ LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
48
+ If you don't have access, you can skip this section
49
+
50
+
51
+ ```shell
52
+ export LANGCHAIN_TRACING_V2=true
53
+ export LANGCHAIN_API_KEY=<your-api-key>
54
+ export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
55
+ ```
56
+
57
+ ## Launch LangServe
58
+
59
+ ```bash
60
+ langchain serve
61
+ ```
62
+
63
+ ## Running in Docker
64
+
65
+ This project folder includes a Dockerfile that allows you to easily build and host your LangServe app.
66
+
67
+ ### Building the Image
68
+
69
+ To build the image, you simply:
70
+
71
+ ```shell
72
+ docker build . -t my-langserve-app
73
+ ```
74
+
75
+ If you tag your image with something other than `my-langserve-app`,
76
+ note it for use in the next step.
77
+
78
+ ### Running the Image Locally
79
+
80
+ To run the image, you'll need to include any environment variables
81
+ necessary for your application.
82
+
83
+ In the below example, we inject the `OPENAI_API_KEY` environment
84
+ variable with the value set in my local environment
85
+ (`$OPENAI_API_KEY`)
86
+
87
+ We also expose port 8080 with the `-p 8080:8080` option.
88
+
89
+ ```shell
90
+ docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8080:8080 my-langserve-app
91
+ ```
app/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from dotenv import load_dotenv
2
+
3
+ load_dotenv()
app/server.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.responses import RedirectResponse
3
+ from langserve import add_routes
4
+
5
+ from rag_redis.chain import chain as rag_redis_chain
6
+
7
+ app = FastAPI()
8
+
9
+
10
+ @app.get("/")
11
+ async def redirect_root_to_docs():
12
+ return RedirectResponse("/docs")
13
+
14
+
15
+ add_routes(app, rag_redis_chain, path="/rag-redis")
16
+ # Edit this to add the chain you want to add
17
+
18
+ if __name__ == "__main__":
19
+ import uvicorn
20
+
21
+ uvicorn.run(app, host="0.0.0.0", port=8000)
compose.yml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ app:
3
+ image: phuochungus/homeland_chatgpt
4
+ build: .
5
+ ports:
6
+ - 8080:8080
7
+ environment:
8
+ - OPENAI_API_KEY
9
+ - REDIS_URL
pyproject.toml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "app"
3
+ version = "0.1.0"
4
+ description = ""
5
+ authors = ["Your Name <you@example.com>"]
6
+ readme = "README.md"
7
+ packages = [
8
+ { include = "app" },
9
+ ]
10
+
11
+ [tool.poetry.dependencies]
12
+ python = "^3.11"
13
+ uvicorn = "^0.23.2"
14
+ langserve = {extras = ["server"], version = ">=0.0.30"}
15
+ pydantic = "<2"
16
+ rag-redis = {path = "packages/rag-redis", develop = true}
17
+
18
+
19
+ [tool.poetry.group.dev.dependencies]
20
+ langchain-cli = ">=0.0.15"
21
+
22
+ [build-system]
23
+ requires = ["poetry-core"]
24
+ build-backend = "poetry.core.masonry.api"
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ fastapi==0.104.1
2
+ langchain==0.0.347
3
+ langserve==0.0.34
4
+ python-dotenv==1.0.0
5
+ uvicorn==0.24.0.post1
6
+ pydantic==1.10.13