Skip to content

Commit 430cbf3

Browse files
committed
Merge branch 'main' into feat/update-llama-index
# Conflicts: # poetry.lock # pyproject.toml
2 parents cd1f1d6 + 5fbb402 commit 430cbf3

File tree

8 files changed

+263
-154
lines changed

8 files changed

+263
-154
lines changed

docker-compose.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ services:
88
# This service builds from an external Dockerfile and runs the Ollama mode.
99
private-gpt-ollama:
1010
image: ${PGPT_IMAGE:-zylonai/private-gpt}:${PGPT_TAG:-0.6.2}-ollama # x-release-please-version
11+
user: root
1112
build:
1213
context: .
1314
dockerfile: Dockerfile.ollama
1415
volumes:
15-
- ./local_data/:/home/worker/app/local_data
16+
- ./local_data:/home/worker/app/local_data
1617
ports:
1718
- "8001:8001"
1819
environment:
@@ -27,11 +28,14 @@ services:
2728
- ollama-cpu
2829
- ollama-cuda
2930
- ollama-api
31+
depends_on:
32+
- ollama
3033

3134
# Private-GPT service for the local mode
3235
# This service builds from a local Dockerfile and runs the application in local mode.
3336
private-gpt-llamacpp-cpu:
3437
image: ${PGPT_IMAGE:-zylonai/private-gpt}:${PGPT_TAG:-0.6.2}-llamacpp-cpu # x-release-please-version
38+
user: root
3539
build:
3640
context: .
3741
dockerfile: Dockerfile.llamacpp-cpu
@@ -44,7 +48,7 @@ services:
4448
environment:
4549
PORT: 8001
4650
PGPT_PROFILES: local
47-
HF_TOKEN: ${HF_TOKEN}
51+
HF_TOKEN: ${HF_TOKEN:-}
4852
profiles:
4953
- llamacpp-cpu
5054

@@ -57,7 +61,7 @@ services:
5761
ollama:
5862
image: traefik:v2.10
5963
ports:
60-
- "8081:8080"
64+
- "8080:8080"
6165
command:
6266
- "--providers.file.filename=/etc/router.yml"
6367
- "--log.level=ERROR"
@@ -102,4 +106,4 @@ services:
102106
count: 1
103107
capabilities: [gpu]
104108
profiles:
105-
- ollama-cuda
109+
- ollama-cuda

poetry.lock

Lines changed: 203 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

private_gpt/components/embedding/embedding_component.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,23 @@ def __init__(self, settings: Settings) -> None:
144144
api_key=settings.gemini.api_key,
145145
model_name=settings.gemini.embedding_model,
146146
)
147+
case "mistralai":
148+
try:
149+
from llama_index.embeddings.mistralai import ( # type: ignore
150+
MistralAIEmbedding,
151+
)
152+
except ImportError as e:
153+
raise ImportError(
154+
"Mistral dependencies not found, install with `poetry install --extras embeddings-mistral`"
155+
) from e
156+
157+
api_key = settings.openai.api_key
158+
model = settings.openai.embedding_model
159+
160+
self.embedding_model = MistralAIEmbedding(
161+
api_key=api_key,
162+
model=model,
163+
)
147164
case "mock":
148165
# Not a random number, is the dimensionality used by
149166
# the default embedding model

private_gpt/components/ingest/ingest_helper.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ def _load_file_to_documents(file_name: str, file_data: Path) -> list[Document]:
9292
return string_reader.load_data([file_data.read_text()])
9393

9494
logger.debug("Specific reader found for extension=%s", extension)
95-
return reader_cls().load_data(file_data)
95+
documents = reader_cls().load_data(file_data)
96+
97+
# Sanitize NUL bytes in text which can't be stored in Postgres
98+
for i in range(len(documents)):
99+
documents[i].text = documents[i].text.replace("\u0000", "")
100+
101+
return documents
96102

97103
@staticmethod
98104
def _exclude_metadata(documents: list[Document]) -> None:

private_gpt/settings/settings.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ class HuggingFaceSettings(BaseModel):
197197

198198
class EmbeddingSettings(BaseModel):
199199
mode: Literal[
200-
"huggingface", "openai", "azopenai", "sagemaker", "ollama", "mock", "gemini"
200+
"huggingface",
201+
"openai",
202+
"azopenai",
203+
"sagemaker",
204+
"ollama",
205+
"mock",
206+
"gemini",
207+
"mistralai",
201208
]
202209
ingest_mode: Literal["simple", "batch", "parallel", "pipeline"] = Field(
203210
"simple",
@@ -350,6 +357,10 @@ class AzureOpenAISettings(BaseModel):
350357
class UISettings(BaseModel):
351358
enabled: bool
352359
path: str
360+
default_mode: Literal["RAG", "Search", "Basic", "Summarize"] = Field(
361+
"RAG",
362+
description="The default mode.",
363+
)
353364
default_chat_system_prompt: str = Field(
354365
None,
355366
description="The default system prompt to use for the chat mode.",

private_gpt/ui/ui.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ def __init__(
100100
self._selected_filename = None
101101

102102
# Initialize system prompt based on default mode
103-
self.mode = MODES[0]
104-
self._system_prompt = self._get_default_system_prompt(self.mode)
103+
default_mode_map = {mode.value: mode for mode in Modes}
104+
self._default_mode = default_mode_map.get(
105+
settings().ui.default_mode, Modes.RAG_MODE
106+
)
107+
self._system_prompt = self._get_default_system_prompt(self._default_mode)
105108

106109
def _chat(
107110
self, message: str, history: list[list[str]], mode: Modes, *_: Any
@@ -391,7 +394,7 @@ def _build_ui_blocks(self) -> gr.Blocks:
391394

392395
with gr.Row(equal_height=False):
393396
with gr.Column(scale=3):
394-
default_mode = MODES[0]
397+
default_mode = self._default_mode
395398
mode = gr.Radio(
396399
[mode.value for mode in MODES],
397400
label="Mode",

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ llama-index-embeddings-huggingface = {version ="*", optional = true}
3030
llama-index-embeddings-openai = {version ="*", optional = true}
3131
llama-index-embeddings-azure-openai = {version ="*", optional = true}
3232
llama-index-embeddings-gemini = {version ="*", optional = true}
33+
llama-index-embeddings-mistralai = {version ="*", optional = true}
3334
llama-index-vector-stores-qdrant = {version ="*", optional = true}
3435
llama-index-vector-stores-milvus = {version ="*", optional = true}
3536
llama-index-vector-stores-chroma = {version ="*", optional = true}
@@ -74,6 +75,7 @@ embeddings-openai = ["llama-index-embeddings-openai"]
7475
embeddings-sagemaker = ["boto3"]
7576
embeddings-azopenai = ["llama-index-embeddings-azure-openai"]
7677
embeddings-gemini = ["llama-index-embeddings-gemini"]
78+
embeddings-mistral = ["llama-index-embeddings-mistralai"]
7779
vector-stores-qdrant = ["llama-index-vector-stores-qdrant"]
7880
vector-stores-clickhouse = ["llama-index-vector-stores-clickhouse", "clickhouse_connect"]
7981
vector-stores-chroma = ["llama-index-vector-stores-chroma"]

settings.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,23 @@ data:
2525
ui:
2626
enabled: true
2727
path: /
28+
# "RAG", "Search", "Basic", or "Summarize"
29+
default_mode: "RAG"
2830
default_chat_system_prompt: >
29-
You are a helpful, respectful and honest assistant.
31+
You are a helpful, respectful and honest assistant.
3032
Always answer as helpfully as possible and follow ALL given instructions.
3133
Do not speculate or make up information.
3234
Do not reference any given instructions or context.
3335
default_query_system_prompt: >
34-
You can only answer questions about the provided context.
35-
If you know the answer but it is not based in the provided context, don't provide
36+
You can only answer questions about the provided context.
37+
If you know the answer but it is not based in the provided context, don't provide
3638
the answer, just state the answer is not in the context provided.
3739
default_summarization_system_prompt: >
38-
Provide a comprehensive summary of the provided context information.
40+
Provide a comprehensive summary of the provided context information.
3941
The summary should cover all the key points and main ideas presented in
40-
the original text, while also condensing the information into a concise
42+
the original text, while also condensing the information into a concise
4143
and easy-to-understand format. Please ensure that the summary includes
42-
relevant details and examples that support the main ideas, while avoiding
44+
relevant details and examples that support the main ideas, while avoiding
4345
any unnecessary information or repetition.
4446
delete_file_button_enabled: true
4547
delete_all_files_button_enabled: true

0 commit comments

Comments
 (0)