ryanrwatkins commited on
Commit
0669d9c
1 Parent(s): 0176780

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -40
app.py CHANGED
@@ -562,7 +562,7 @@ def instantiate_LLM(LLM_provider,api_key,temperature=0.5,top_p=0.95,model_name=N
562
  )
563
  return llm
564
 
565
-
566
  def get_environment_variable(key):
567
  if key in os.environ:
568
  value = os.environ.get(key)
@@ -571,7 +571,7 @@ def get_environment_variable(key):
571
  print(f"\n[ERROR]: {key} is not found in your environment variables.")
572
  value = getpass(f"Insert your {key}")
573
  return value
574
-
575
 
576
 
577
 
@@ -625,45 +625,7 @@ memory.load_memory_variables({})
625
 
626
 
627
 
628
- standalone_question_template = """Given the following conversation and a follow up question,
629
- rephrase the follow up question to be a standalone question, in its original language.\n\n
630
- Chat History:\n{chat_history}\n
631
- Follow Up Input: {question}\n
632
- Standalone question:"""
633
-
634
- standalone_question_prompt = PromptTemplate(
635
- input_variables=['chat_history', 'question'],
636
- template=standalone_question_template
637
- )
638
-
639
 
640
- def answer_template(language="english"):
641
- """Pass the standalone question along with the chat history and context
642
- to the `LLM` wihch will answer"""
643
-
644
- template = f"""Answer the question at the end, using only the following context (delimited by <context></context>).
645
- Your answer must be in the language at the end.
646
-
647
- <context>
648
- {{chat_history}}
649
-
650
- {{context}}
651
- </context>
652
-
653
- Question: {{question}}
654
- Language: {language}.
655
-
656
- """
657
- return template
658
-
659
- answer_prompt = ChatPromptTemplate.from_template(answer_template())
660
-
661
- # invoke the ChatPromptTemplate
662
- answer_prompt.invoke(
663
- {"question":"plaese give more details about DTC, including its use cases and implementation.",
664
- "context":[Document(page_content="DTC use cases include...")], # the context is a list of retrieved documents.
665
- "chat_history":memory.chat_memory}
666
- )
667
 
668
 
669
 
 
562
  )
563
  return llm
564
 
565
+ """
566
  def get_environment_variable(key):
567
  if key in os.environ:
568
  value = os.environ.get(key)
 
571
  print(f"\n[ERROR]: {key} is not found in your environment variables.")
572
  value = getpass(f"Insert your {key}")
573
  return value
574
+ """
575
 
576
 
577
 
 
625
 
626
 
627
 
 
 
 
 
 
 
 
 
 
 
 
628
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
629
 
630
 
631