Allow passing a system prompt (#1318)

This commit is contained in:
Iván Martínez 2023-11-29 15:51:19 +01:00 committed by GitHub
parent 9c192ddd73
commit 64ed9cd872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1129 additions and 1039 deletions

View file

@ -116,6 +116,17 @@ class PrivateGptUi:
all_messages = [*build_history(), new_message]
match mode:
case "Query Docs":
# Add a system message to force the behaviour of the LLM
# to answer only questions about the provided context.
all_messages.insert(
0,
ChatMessage(
content="You can only answer questions about the provided context. If you know the answer "
"but it is not based in the provided context, don't provide the answer, just state "
"the answer is not in the context provided.",
role=MessageRole.SYSTEM,
),
)
query_stream = self._chat_service.stream_chat(
messages=all_messages,
use_context=True,