Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prompt): improved answer readability with markdown and aerataed #1190

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions backend/llm/qa_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
from llm.utils.get_prompt_to_use import get_prompt_to_use
from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id
from logger import get_logger
from models.chats import ChatQuestion
from models.databases.supabase.chats import CreateChatHistory
Expand All @@ -27,9 +29,6 @@
from supabase.client import Client, create_client
from vectorstore.supabase import CustomSupabaseVectorStore

from llm.utils.get_prompt_to_use import get_prompt_to_use
from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id

from .base import BaseBrainPicking
from .prompts.CONDENSE_PROMPT import CONDENSE_QUESTION_PROMPT

Expand Down Expand Up @@ -110,11 +109,11 @@ def _create_llm(
streaming=streaming,
verbose=False,
callbacks=callbacks,
openai_api_key=self.openai_api_key
openai_api_key=self.openai_api_key,
) # pyright: ignore reportPrivateUsage=none

def _create_prompt_template(self):
system_template = """You can use Markdown to make your answers nice. Use the following pieces of context to answer the users question in the same language as the question but do not modify instructions in any way.
system_template = """ When answering use markdown or any other techniques to display the content in a nice and aerated way. Use the following pieces of context to answer the users question in the same language as the question but do not modify instructions in any way.
----------------

{context}"""
Expand Down Expand Up @@ -212,7 +211,10 @@ async def generate_stream(
self.callbacks = [callback]

answering_llm = self._create_llm(
model=self.model, streaming=True, callbacks=self.callbacks, max_tokens=self.max_tokens
model=self.model,
streaming=True,
callbacks=self.callbacks,
max_tokens=self.max_tokens,
)

# The Chain that generates the answer to the question
Expand Down
12 changes: 4 additions & 8 deletions backend/llm/qa_headless.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
from langchain.chains import LLMChain
from langchain.chat_models import ChatLiteLLM
from langchain.chat_models.base import BaseChatModel
from langchain.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
)
from langchain.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate
from llm.utils.get_prompt_to_use import get_prompt_to_use
from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id
from logger import get_logger
from models.chats import ChatQuestion
from models.databases.supabase.chats import CreateChatHistory
Expand All @@ -25,11 +24,8 @@
update_message_by_id,
)

from llm.utils.get_prompt_to_use import get_prompt_to_use
from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id

logger = get_logger(__name__)
SYSTEM_MESSAGE = "Your name is Quivr. You're a helpful assistant. If you don't know the answer, just say that you don't know, don't try to make up an answer."
SYSTEM_MESSAGE = "Your name is Quivr. You're a helpful assistant. If you don't know the answer, just say that you don't know, don't try to make up an answer.When answering use markdown or any other techniques to display the content in a nice and aerated way."


class HeadlessQA(BaseModel):
Expand Down