Skip to content

Commit

Permalink
feat(prompt): improved answer readability with markdown and aerataed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
StanGirard authored Sep 17, 2023
1 parent 2e4fdc8 commit 4a0a7ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
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

0 comments on commit 4a0a7ab

Please sign in to comment.