Spaces:
Sleeping
Sleeping
Taras Yaroshko
commited on
Commit
•
dbdeff7
1
Parent(s):
c46c365
Add filtering responses by summit
Browse files- app/utils/llm_utils.py +4 -3
app/utils/llm_utils.py
CHANGED
@@ -71,22 +71,23 @@ def answer_prompt_with_template(
|
|
71 |
)
|
72 |
qa_prompt_tmpl = PromptTemplate(QA_PROMPT_TEMPLATE)
|
73 |
query_engine = index.as_query_engine(
|
74 |
-
text_qa_template=qa_prompt_tmpl, similarity_top_k=
|
75 |
)
|
76 |
response = query_engine.query(query_str)
|
|
|
77 |
elif page_type == "summit_page":
|
78 |
filters = MetadataFilters(
|
79 |
filters=[ExactMatchFilter(key="summit_id", value=meta_id)]
|
80 |
)
|
81 |
qa_prompt_tmpl = PromptTemplate(QA_PROMPT_TEMPLATE)
|
82 |
query_engine = index.as_query_engine(
|
83 |
-
text_qa_template=qa_prompt_tmpl, similarity_top_k=
|
84 |
)
|
85 |
response = query_engine.query(query_str)
|
86 |
else:
|
87 |
qa_prompt_tmpl = PromptTemplate(QA_PROMPT_TEMPLATE)
|
88 |
query_engine = index.as_query_engine(
|
89 |
-
text_qa_template=qa_prompt_tmpl, similarity_top_k=
|
90 |
)
|
91 |
response = query_engine.query(query_str)
|
92 |
try:
|
|
|
71 |
)
|
72 |
qa_prompt_tmpl = PromptTemplate(QA_PROMPT_TEMPLATE)
|
73 |
query_engine = index.as_query_engine(
|
74 |
+
text_qa_template=qa_prompt_tmpl, similarity_top_k=4, filters=filters
|
75 |
)
|
76 |
response = query_engine.query(query_str)
|
77 |
+
print(response.response)
|
78 |
elif page_type == "summit_page":
|
79 |
filters = MetadataFilters(
|
80 |
filters=[ExactMatchFilter(key="summit_id", value=meta_id)]
|
81 |
)
|
82 |
qa_prompt_tmpl = PromptTemplate(QA_PROMPT_TEMPLATE)
|
83 |
query_engine = index.as_query_engine(
|
84 |
+
text_qa_template=qa_prompt_tmpl, similarity_top_k=4, filters=filters
|
85 |
)
|
86 |
response = query_engine.query(query_str)
|
87 |
else:
|
88 |
qa_prompt_tmpl = PromptTemplate(QA_PROMPT_TEMPLATE)
|
89 |
query_engine = index.as_query_engine(
|
90 |
+
text_qa_template=qa_prompt_tmpl, similarity_top_k=4
|
91 |
)
|
92 |
response = query_engine.query(query_str)
|
93 |
try:
|