jeremierostan commited on
Commit
18801f2
·
verified ·
1 Parent(s): af1dd95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -70,19 +70,20 @@ def gemini_response(query):
70
  return chain.invoke({"context": full_pdf_content, "input": query}).content
71
 
72
  # Function to generate final response
73
- def generate_final_response(response1, response2):
74
  prompt = ChatPromptTemplate.from_template("""
75
  You are an AI assistant helping educators understand and implement data protection and compliance with official regulations when using AI.
76
  Your goal is to provide simple, practical explanation of and advice on how to meet these regulatory requirements based on the 2 given responses.
77
  To do so:
78
- 1. Analyze the following two responses. Inspect their content, and highlight differences. This MUST be done
 
79
  internally as a hidden state.
80
- 2. Then, use this information to output your own response combining the best from both.
81
- If the responses differ or contradict each other on important points, include that in your response.
82
- Only output your own response.
83
  """)
84
  chain = prompt | openai_client
85
- return chain.invoke({"response1": response1, "response2": response2}).content
86
 
87
  # Function to process the query
88
  def process_query(user_query):
 
70
  return chain.invoke({"context": full_pdf_content, "input": query}).content
71
 
72
  # Function to generate final response
73
+ def generate_final_response(query, response1, response2):
74
  prompt = ChatPromptTemplate.from_template("""
75
  You are an AI assistant helping educators understand and implement data protection and compliance with official regulations when using AI.
76
  Your goal is to provide simple, practical explanation of and advice on how to meet these regulatory requirements based on the 2 given responses.
77
  To do so:
78
+ 1. Read the user query
79
+ 2. Analyze the following two responses. Inspect their content, and highlight their differences. This MUST be done
80
  internally as a hidden state.
81
+ 2. Then, use this information to output your own response to the user query, synthesizing the responses all while maintaining their strengths
82
+ If the responses differ or contradict each other on important points, include that in your response as this could be a sign of hallucination.
83
+ Only output your own final response to the user query.
84
  """)
85
  chain = prompt | openai_client
86
+ return chain.invoke({"query": query, "response1": response1, "response2": response2}).content
87
 
88
  # Function to process the query
89
  def process_query(user_query):