Spaces:
Running
on
T4
Running
on
T4
fix for textbox parsing
Browse files- app.py +24 -7
- utils/__pycache__/retriever.cpython-311.pyc +0 -0
app.py
CHANGED
@@ -14,6 +14,14 @@ except Exception as e:
|
|
14 |
# ---------------------------------------------------------------------
|
15 |
# MCP - returns raw dictionary format
|
16 |
# ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
def retrieve(
|
19 |
query:str,
|
@@ -77,11 +85,8 @@ with gr.Blocks() as ui:
|
|
77 |
placeholder="Ecuador, Guatemala",
|
78 |
info="Filter by document subtype (leave empty for all)"
|
79 |
)
|
80 |
-
|
81 |
-
|
82 |
-
else:
|
83 |
-
filter_metadata = None
|
84 |
-
|
85 |
submit_btn = gr.Button("Submit", variant="primary")
|
86 |
|
87 |
# Output needs to be in json format to be added as tool in HuggingChat
|
@@ -93,11 +98,23 @@ with gr.Blocks() as ui:
|
|
93 |
)
|
94 |
|
95 |
# UI event handler
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
submit_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
fn=retrieve,
|
98 |
-
inputs=[query_input,collection_name,
|
99 |
outputs=output,
|
100 |
-
|
101 |
)
|
102 |
|
103 |
|
|
|
14 |
# ---------------------------------------------------------------------
|
15 |
# MCP - returns raw dictionary format
|
16 |
# ---------------------------------------------------------------------
|
17 |
+
def create_metadata_dict(sources_input, sources_value):
|
18 |
+
"""
|
19 |
+
This helper function creates the filter dictionary based on user input.
|
20 |
+
"""
|
21 |
+
if sources_input and sources_value:
|
22 |
+
return {sources_input: sources_value}
|
23 |
+
return None
|
24 |
+
|
25 |
|
26 |
def retrieve(
|
27 |
query:str,
|
|
|
85 |
placeholder="Ecuador, Guatemala",
|
86 |
info="Filter by document subtype (leave empty for all)"
|
87 |
)
|
88 |
+
|
89 |
+
filter_metadata_state = gr.State(None)
|
|
|
|
|
|
|
90 |
submit_btn = gr.Button("Submit", variant="primary")
|
91 |
|
92 |
# Output needs to be in json format to be added as tool in HuggingChat
|
|
|
98 |
)
|
99 |
|
100 |
# UI event handler
|
101 |
+
# submit_btn.click(
|
102 |
+
# fn=retrieve,
|
103 |
+
# inputs=[query_input,collection_name, filter_metadata],
|
104 |
+
# outputs=output,
|
105 |
+
# api_name="retrieve"
|
106 |
+
# )
|
107 |
submit_btn.click(
|
108 |
+
fn=create_metadata_dict,
|
109 |
+
inputs=[sources_input, sources_value],
|
110 |
+
outputs=filter_metadata_state,
|
111 |
+
queue=False
|
112 |
+
).then(
|
113 |
+
# 3. Use the updated state as an input to the retrieve function.
|
114 |
fn=retrieve,
|
115 |
+
inputs=[query_input, collection_name, filter_metadata_state],
|
116 |
outputs=output,
|
117 |
+
queue=False
|
118 |
)
|
119 |
|
120 |
|
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
|
|