File tree Expand file tree Collapse file tree 7 files changed +67
-15
lines changed Expand file tree Collapse file tree 7 files changed +67
-15
lines changed Original file line number Diff line number Diff line change 3
3
.github
4
4
.vscode
5
5
.DS_Store
6
+ .mypy_cache
7
+ .ruff_cache
8
+ local_data
6
9
terraform
7
10
tests
8
11
Dockerfile
Original file line number Diff line number Diff line change
1
+ name : Create and publish a Docker image
2
+
3
+ on :
4
+ release :
5
+ types : [ published ]
6
+ push :
7
+ branches :
8
+ - main
9
+ pull_request :
10
+
11
+ env :
12
+ REGISTRY : ghcr.io
13
+ IMAGE_NAME : ${{ github.repository }}
14
+
15
+ jobs :
16
+ build-and-push-image :
17
+ runs-on : ubuntu-latest
18
+ permissions :
19
+ contents : read
20
+ packages : write
21
+ steps :
22
+ - name : Checkout repository
23
+ uses : actions/checkout@v4
24
+ - name : Log in to the Container registry
25
+ uses : docker/login-action@v3
26
+ with :
27
+ registry : ${{ env.REGISTRY }}
28
+ username : ${{ github.actor }}
29
+ password : ${{ secrets.GITHUB_TOKEN }}
30
+ - name : Extract metadata (tags, labels) for Docker
31
+ id : meta
32
+ uses : docker/metadata-action@v5
33
+ with :
34
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35
+ tags : |
36
+ type=ref,event=branch
37
+ type=ref,event=pr
38
+ type=semver,pattern={{version}}
39
+ type=semver,pattern={{major}}.{{minor}}
40
+ type=sha
41
+ - name : Build and push Docker image
42
+ uses : docker/build-push-action@v5
43
+ with :
44
+ context : .
45
+ push : true
46
+ tags : ${{ steps.meta.outputs.tags }}
47
+ labels : ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change @@ -23,10 +23,7 @@ FROM base as dependencies
23
23
WORKDIR /home/worker/app
24
24
COPY pyproject.toml poetry.lock ./
25
25
26
- RUN poetry install --with local
27
26
RUN poetry install --with ui
28
- RUN CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" \
29
- poetry run pip install --force-reinstall --no-cache-dir llama-cpp-python
30
27
31
28
FROM base as app
32
29
@@ -39,9 +36,11 @@ EXPOSE 8080
39
36
RUN adduser --system worker
40
37
WORKDIR /home/worker/app
41
38
42
- # Copy everything, including the virtual environment
43
- COPY --chown=worker --from=dependencies /home/worker/app .
44
- COPY --chown=worker . .
39
+ RUN mkdir "local_data" ; chown worker local_data
40
+ COPY --chown=worker --from=dependencies /home/worker/app/.venv/ .venv
41
+ COPY --chown=worker private_gpt/ private_gpt
42
+ COPY --chown=worker docs/ docs
43
+ COPY --chown=worker *.yaml *.md ./
45
44
46
45
USER worker
47
46
ENTRYPOINT .venv/bin/python -m private_gpt
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class EmbeddingComponent:
13
13
@inject
14
14
def __init__ (self ) -> None :
15
15
match settings .llm .mode :
16
- case "local" :
16
+ case "local" | "sagemaker" :
17
17
from llama_index .embeddings import HuggingFaceEmbedding
18
18
19
19
self .embedding_model = HuggingFaceEmbedding (
Original file line number Diff line number Diff line change 21
21
)
22
22
23
23
if TYPE_CHECKING :
24
- from collections .abc import Callable
25
-
26
24
from llama_index .callbacks import CallbackManager
27
25
from llama_index .llms import (
28
26
CompletionResponseGen ,
@@ -113,10 +111,10 @@ class SagemakerLLM(CustomLLM):
113
111
context_window : int = Field (
114
112
description = "The maximum number of context tokens for the model."
115
113
)
116
- messages_to_prompt : Callable [..., str ] = Field (
114
+ messages_to_prompt : Any = Field (
117
115
description = "The function to convert messages to a prompt." , exclude = True
118
116
)
119
- completion_to_prompt : Callable [..., str ] = Field (
117
+ completion_to_prompt : Any = Field (
120
118
description = "The function to convert a completion to a prompt." , exclude = True
121
119
)
122
120
generate_kwargs : dict [str , Any ] = Field (
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ def __init__(self) -> None:
37
37
38
38
self .llm = SagemakerLLM (
39
39
endpoint_name = settings .sagemaker .endpoint_name ,
40
+ messages_to_prompt = messages_to_prompt ,
41
+ completion_to_prompt = completion_to_prompt ,
40
42
)
41
43
case "openai" :
42
44
from llama_index .llms import OpenAI
Original file line number Diff line number Diff line change @@ -3,12 +3,15 @@ server:
3
3
port : ${PORT:8080}
4
4
5
5
llm :
6
- mode : local
6
+ mode : ${PGPT_MODE:mock}
7
7
8
8
local :
9
- llm_hf_repo_id : TheBloke/Mistral-7B-Instruct-v0.1-GGUF
10
- llm_hf_model_file : mistral-7b-instruct-v0.1.Q4_K_M.gguf
11
- embedding_hf_model_name : BAAI/bge-small-en-v1.5
9
+ llm_hf_repo_id : ${PGPT_HF_REPO_ID:TheBloke/Mistral-7B-Instruct-v0.1-GGUF}
10
+ llm_hf_model_file : ${PGPT_HF_MODEL_FILE:mistral-7b-instruct-v0.1.Q4_K_M.gguf}
11
+ embedding_hf_model_name : ${PGPT_EMBEDDING_HF_MODEL_NAME:BAAI/bge-small-en-v1.5}
12
+
13
+ sagemaker :
14
+ endpoint_name : ${PGPT_SAGEMAKER_ENDPOINT_NAME:}
12
15
13
16
ui :
14
17
enabled : true
You can’t perform that action at this time.
0 commit comments