Skip to content

Commit

Permalink
Refactor prepare_prompt function to improve code readability and fix …
Browse files Browse the repository at this point in the history
…prompt formatting
  • Loading branch information
FloRul committed Mar 6, 2024
1 parent b7cff1f commit 87bb14d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Binary file modified .DS_Store
Binary file not shown.
7 changes: 4 additions & 3 deletions lambdas/inference/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@


def prepare_prompt(query: str, docs: list, history: list, source: str):
basic_prompt = f'\n\nHuman: The user sent the following message : "{query}".'
basic_prompt = f'\n\nThe user sent the following message : "{query}".'
source_prompt = prepare_source_prompt(source)
document_prompt = prepare_document_prompt(docs)
history_prompt = prepare_history_prompt(history)
source_prompt = prepare_source_prompt(source)

final_prompt = f"""{basic_prompt}\n
{source_prompt}\n
Expand All @@ -43,7 +43,8 @@ def prepare_prompt(query: str, docs: list, history: list, source: str):

def prepare_source_prompt(source: str):
if source == "email":
return "You are currently answering an email so your answer can be more detailed. After you finish answering the initial query generate follow-up questions and answer it too up to 4 questions."
return """You are currently answering an email so your answer can be more detailed.
After you finish answering the initial query generate follow-up questions and answer it too up to 4 questions."""
elif source == "call":
return "Make your answer short and concise."
else:
Expand Down

0 comments on commit 87bb14d

Please sign in to comment.