feat: Update system templates with custom personality support (#2209)

This pull request updates the system templates to include support for
custom personality. It adds a new parameter called "custom_personality"
to the generate_stream function, which allows users to provide a custom
personality for the AI assistant. This feature enhances the user
experience by allowing them to personalize the assistant's responses.
This commit is contained in:
Stan Girard 2024-02-18 16:22:21 -08:00 committed by GitHub
parent 57ec5a634b
commit 2ae8ec1739
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -36,7 +36,8 @@ class BigBrain(KnowledgeBrainQA):
def get_chain(self):
system_template = """Combine these summaries in a way that makes sense and answer the user's question.
Use markdown or any other techniques to display the content in a nice and aerated way.
Use markdown or any other techniques to display the content in a nice and aerated way.
Here are user instructions on how to respond: {custom_personality}
______________________
{summaries}"""
messages = [
@ -88,6 +89,9 @@ class BigBrain(KnowledgeBrainQA):
{
"question": question.question,
"chat_history": transformed_history,
"custom_personality": (
self.prompt_to_use.content if self.prompt_to_use else None
),
}
):
if "answer" in chunk:

View File

@ -28,7 +28,10 @@ class GPT4Brain(KnowledgeBrainQA):
prompt = ChatPromptTemplate.from_messages(
[
("system", "You are GPT-4 powered by Quivr. You are an assistant."),
(
"system",
"You are GPT-4 powered by Quivr. You are an assistant. {custom_personality}",
),
MessagesPlaceholder(variable_name="chat_history"),
("human", "{question}"),
]
@ -53,6 +56,9 @@ class GPT4Brain(KnowledgeBrainQA):
{
"question": question.question,
"chat_history": transformed_history,
"custom_personality": (
self.prompt_to_use.content if self.prompt_to_use else None
),
}
):
response_tokens.append(chunk.content)