Spaces:
Runtime error
Runtime error
Chintan Donda
commited on
Commit
·
92e120c
1
Parent(s):
f0af1c3
Display Mandir Price in proper format
Browse files
app.py
CHANGED
@@ -92,6 +92,16 @@ class DomState:
|
|
92 |
):
|
93 |
if state_name and apmc_name and commodity_name and from_date and to_date:
|
94 |
self.mandi_price = self.kkms_kssw_obj.mandi_utils_obj.get_mandi_price(state_name, apmc_name, commodity_name, from_date, to_date)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
return self.mandi_price
|
96 |
|
97 |
|
@@ -185,7 +195,9 @@ class DomState:
|
|
185 |
return list(obj)
|
186 |
return obj
|
187 |
self.kb_sources = self.kkms_kssw_obj.langchain_utils_obj.get_index_category_wise_data_sources()
|
188 |
-
# return json.dumps(self.kb_sources, default=_serialize_sets)
|
|
|
|
|
189 |
kb_sources = ''
|
190 |
for index_category, doc_type in self.kb_sources.items():
|
191 |
if not doc_type:
|
@@ -201,8 +213,8 @@ class DomState:
|
|
201 |
for doc in source:
|
202 |
kb_sources += f'\t\t\t\n{doc}'
|
203 |
kb_sources += '\n\n'
|
204 |
-
|
205 |
self.kb_sources = kb_sources
|
|
|
206 |
return self.kb_sources
|
207 |
|
208 |
|
|
|
92 |
):
|
93 |
if state_name and apmc_name and commodity_name and from_date and to_date:
|
94 |
self.mandi_price = self.kkms_kssw_obj.mandi_utils_obj.get_mandi_price(state_name, apmc_name, commodity_name, from_date, to_date)
|
95 |
+
|
96 |
+
# NOTE: Below code is only to display Mandi Prices in Gradio front-end. It could be removed when Engineering team writes a wrapper on top of app.py.
|
97 |
+
self.mandi_price = sorted(self.mandi_price['data'], key=lambda x: x.get('created_at', ''), reverse=True)
|
98 |
+
mandi_price = ''
|
99 |
+
for ids in self.mandi_price:
|
100 |
+
mandi_price += f'='*100 + '\n'
|
101 |
+
for id, val in ids.items():
|
102 |
+
mandi_price += '%-30s: %s\n' % (id, val)
|
103 |
+
self.mandi_price = mandi_price
|
104 |
+
|
105 |
return self.mandi_price
|
106 |
|
107 |
|
|
|
195 |
return list(obj)
|
196 |
return obj
|
197 |
self.kb_sources = self.kkms_kssw_obj.langchain_utils_obj.get_index_category_wise_data_sources()
|
198 |
+
# return json.dumps(self.kb_sources, default=_serialize_sets) # TODO: Uncommet this line if we don't want to display data sources on Gradio in proper format.
|
199 |
+
|
200 |
+
# NOTE: Below code is only to display Data Sources in Gradio front-end. It could be removed when Engineering team writes a wrapper on top of app.py.
|
201 |
kb_sources = ''
|
202 |
for index_category, doc_type in self.kb_sources.items():
|
203 |
if not doc_type:
|
|
|
213 |
for doc in source:
|
214 |
kb_sources += f'\t\t\t\n{doc}'
|
215 |
kb_sources += '\n\n'
|
|
|
216 |
self.kb_sources = kb_sources
|
217 |
+
|
218 |
return self.kb_sources
|
219 |
|
220 |
|