Update app1.py
Browse files
app1.py
CHANGED
@@ -158,7 +158,7 @@ if query:
|
|
158 |
st.write("Extracted Context (page_content):", context)
|
159 |
st.write("Number of Extracted Contexts:", len(context))
|
160 |
|
161 |
-
relevancy_prompt = """You are an expert judge tasked with evaluating
|
162 |
Analyze the provided QUERY AND CONTEXT to determine if each Ccontent in the CONTEXT LIST contains Relevant information to answer the QUERY.
|
163 |
|
164 |
Guidelines:
|
@@ -200,4 +200,45 @@ if query:
|
|
200 |
|
201 |
context_relevancy_checker_prompt = PromptTemplate(input_variables=["retriever_query","context"],template=relevancy_prompt)
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
|
|
158 |
st.write("Extracted Context (page_content):", context)
|
159 |
st.write("Number of Extracted Contexts:", len(context))
|
160 |
|
161 |
+
relevancy_prompt = """You are an expert judge tasked with evaluating whether the EACH OF THE CONTEXT provided in the CONTEXT LIST is self sufficient to answer the QUERY asked.
|
162 |
Analyze the provided QUERY AND CONTEXT to determine if each Ccontent in the CONTEXT LIST contains Relevant information to answer the QUERY.
|
163 |
|
164 |
Guidelines:
|
|
|
200 |
|
201 |
context_relevancy_checker_prompt = PromptTemplate(input_variables=["retriever_query","context"],template=relevancy_prompt)
|
202 |
|
203 |
+
relevant_prompt = PromptTemplate(
|
204 |
+
input_variables=["relevancy_response"],
|
205 |
+
template="""
|
206 |
+
Your main task is to analyze the json structure as a part of the Relevancy Response.
|
207 |
+
Review the Relevancy Response and do the following:-
|
208 |
+
(1) Look at the Json Structure content
|
209 |
+
(2) Analyze the 'score' key in the Json Structure content.
|
210 |
+
(3) pick the value of 'content' key against those 'score' key value which has 0.
|
211 |
+
|
212 |
+
Relevancy Response:
|
213 |
+
{relevancy_response}
|
214 |
+
|
215 |
+
Provide your verdict in JSON format with a single key 'content number' and no preamble or explanation:
|
216 |
+
[{{"content":<content number>}}]
|
217 |
+
"""
|
218 |
+
)
|
219 |
+
|
220 |
+
context_prompt = PromptTemplate(
|
221 |
+
input_variables=["context_number"],
|
222 |
+
template="""
|
223 |
+
You main task is to analyze the json structure as a part of the Context Number Response and the list of Contexts provided in the 'Content List' and perform the following steps:-
|
224 |
+
(1) Look at the output from the Relevant Context Picker Agent.
|
225 |
+
(2) Analyze the 'content' key in the Json Structure format({{"content":<<content_number>>}}).
|
226 |
+
(3) Retrieve the value of 'content' key and pick up the context corresponding to that element from the Content List provided.
|
227 |
+
(4) Pass the retrieved context for each corresponing element number referred in the 'Context Number Response'
|
228 |
+
|
229 |
+
Context Number Response:
|
230 |
+
{context_number}
|
231 |
+
|
232 |
+
Content List:
|
233 |
+
{context}
|
234 |
+
|
235 |
+
Provide your verdict in JSON format with a two key 'relevant_content' and 'context_number' no preamble or explanation:
|
236 |
+
[{{"context_number":<content1>,"relevant_content":<content corresponing to that element 1 in the Content List>}},
|
237 |
+
{{"context_number":<content4>,"relevant_content":<content corresponing to that element 4 in the Content List>}},
|
238 |
+
...
|
239 |
+
]
|
240 |
+
"""
|
241 |
+
)
|
242 |
+
|
243 |
+
|
244 |
|