Spaces:
Running
on
T4
Running
on
T4
keep 2 filter options in ui and allow api to take more
Browse files- app.py +7 -10
- utils/__pycache__/retriever.cpython-311.pyc +0 -0
app.py
CHANGED
@@ -28,6 +28,8 @@ def retrieve(
|
|
28 |
query:str,
|
29 |
collection_name:str = None,
|
30 |
filter_metadata:dict = None,
|
|
|
|
|
31 |
) -> list:
|
32 |
"""
|
33 |
Retrieve semantically similar documents from the vector database for MCP clients.
|
@@ -42,7 +44,9 @@ def retrieve(
|
|
42 |
Returns:
|
43 |
list: List of dictionaries containing document content, metadata, and scores
|
44 |
"""
|
45 |
-
|
|
|
|
|
46 |
|
47 |
# Call retriever function and return raw results
|
48 |
results = get_context(
|
@@ -85,9 +89,7 @@ with gr.Blocks() as ui:
|
|
85 |
lines=1,
|
86 |
placeholder="Ecuador, Guatemala",
|
87 |
info="Filter by document subtype (leave empty for all)"
|
88 |
-
)
|
89 |
-
|
90 |
-
filter_metadata_state = gr.State(None)
|
91 |
submit_btn = gr.Button("Submit", variant="primary")
|
92 |
|
93 |
# Output needs to be in json format to be added as tool in HuggingChat
|
@@ -106,14 +108,9 @@ with gr.Blocks() as ui:
|
|
106 |
# api_name="retrieve"
|
107 |
# )
|
108 |
submit_btn.click(
|
109 |
-
fn=create_metadata_dict,
|
110 |
-
inputs=[sources_input, sources_value],
|
111 |
-
outputs=filter_metadata_state,
|
112 |
-
queue=False
|
113 |
-
).then(
|
114 |
# 3. Use the updated state as an input to the retrieve function.
|
115 |
fn=retrieve,
|
116 |
-
inputs=[query_input, collection_name,
|
117 |
outputs=output,
|
118 |
queue=False
|
119 |
)
|
|
|
28 |
query:str,
|
29 |
collection_name:str = None,
|
30 |
filter_metadata:dict = None,
|
31 |
+
sources_input:str = None,
|
32 |
+
sources_value:str = None,
|
33 |
) -> list:
|
34 |
"""
|
35 |
Retrieve semantically similar documents from the vector database for MCP clients.
|
|
|
44 |
Returns:
|
45 |
list: List of dictionaries containing document content, metadata, and scores
|
46 |
"""
|
47 |
+
if not filter_metadata:
|
48 |
+
if sources_input and sources_value:
|
49 |
+
filter_metadata = {sources_input: sources_value}
|
50 |
|
51 |
# Call retriever function and return raw results
|
52 |
results = get_context(
|
|
|
89 |
lines=1,
|
90 |
placeholder="Ecuador, Guatemala",
|
91 |
info="Filter by document subtype (leave empty for all)"
|
92 |
+
)
|
|
|
|
|
93 |
submit_btn = gr.Button("Submit", variant="primary")
|
94 |
|
95 |
# Output needs to be in json format to be added as tool in HuggingChat
|
|
|
108 |
# api_name="retrieve"
|
109 |
# )
|
110 |
submit_btn.click(
|
|
|
|
|
|
|
|
|
|
|
111 |
# 3. Use the updated state as an input to the retrieve function.
|
112 |
fn=retrieve,
|
113 |
+
inputs=[query_input, collection_name, None, sources_input, sources_value],
|
114 |
outputs=output,
|
115 |
queue=False
|
116 |
)
|
utils/__pycache__/retriever.cpython-311.pyc
CHANGED
Binary files a/utils/__pycache__/retriever.cpython-311.pyc and b/utils/__pycache__/retriever.cpython-311.pyc differ
|
|