Spaces:
Sleeping
Sleeping
samlonka
commited on
Commit
•
93c0cc8
1
Parent(s):
5e70d66
'mantraID'
Browse files
Tools.py
CHANGED
@@ -88,13 +88,6 @@ class MantraToolSpec(BaseToolSpec):
|
|
88 |
super().__init__()
|
89 |
self.df_vedamantra = pd.read_csv(VEDAMANTRA_CSV_PATH, encoding='utf-8')
|
90 |
|
91 |
-
def _get_mantra_details(self, query):
|
92 |
-
try:
|
93 |
-
details = get_details_mantra_json(query)
|
94 |
-
return details['mantraHeader']['language'][1]
|
95 |
-
except Exception as e:
|
96 |
-
raise ValueError(f"Failed to get mantra details: {e}")
|
97 |
-
|
98 |
def _get_mantra_details_by_scripture(self, scripture_name=None, KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
99 |
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
100 |
AnuvakNumber=None, AdhyayaNumber=None):
|
@@ -133,15 +126,17 @@ class MantraToolSpec(BaseToolSpec):
|
|
133 |
AnuvakNumber=None, AdhyayaNumber=None):
|
134 |
try:
|
135 |
if mantraid:
|
136 |
-
|
137 |
else:
|
138 |
filter_df = self._get_mantra_details_by_scripture(scripture_name=scripture_name, KandahNumber=KandahNumber,MandalaNumber=MandalaNumber, ArchikahNumber=ArchikahNumber,
|
139 |
ShuktaNumber=ShuktaNumber, PrapatakNumber=PrapatakNumber, MantraNumber=MantraNumber,
|
140 |
AnuvakNumber=AnuvakNumber, AdhyayaNumber=AdhyayaNumber)
|
141 |
if filter_df is not None:
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
145 |
except Exception as e:
|
146 |
return json.dumps({"error": str(e)})
|
147 |
|
@@ -159,16 +154,14 @@ class MantraToolSpec(BaseToolSpec):
|
|
159 |
'''
|
160 |
try:
|
161 |
if mantraid:
|
162 |
-
|
163 |
else:
|
164 |
filtered_df = self._get_mantra_details_by_scripture(scripture_name=scripture_name, KandahNumber=KandahNumber,MandalaNumber=MandalaNumber, ArchikahNumber=ArchikahNumber,
|
165 |
ShuktaNumber=ShuktaNumber, PrapatakNumber=PrapatakNumber, MantraNumber=MantraNumber,
|
166 |
AnuvakNumber=AnuvakNumber, AdhyayaNumber=AdhyayaNumber)
|
167 |
if filtered_df is not None:
|
168 |
-
|
169 |
-
|
170 |
-
else:
|
171 |
-
return None
|
172 |
json_dict = get_details_mantra_json(query)
|
173 |
mantra_summary = json_dict['mantraSummary']['language']
|
174 |
summary_dict = {"Roman-IAST summary of vedamantra": json_dict['mantraSummary']['language'][1]}
|
|
|
88 |
super().__init__()
|
89 |
self.df_vedamantra = pd.read_csv(VEDAMANTRA_CSV_PATH, encoding='utf-8')
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
def _get_mantra_details_by_scripture(self, scripture_name=None, KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
92 |
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
93 |
AnuvakNumber=None, AdhyayaNumber=None):
|
|
|
126 |
AnuvakNumber=None, AdhyayaNumber=None):
|
127 |
try:
|
128 |
if mantraid:
|
129 |
+
MantraID = mantraid
|
130 |
else:
|
131 |
filter_df = self._get_mantra_details_by_scripture(scripture_name=scripture_name, KandahNumber=KandahNumber,MandalaNumber=MandalaNumber, ArchikahNumber=ArchikahNumber,
|
132 |
ShuktaNumber=ShuktaNumber, PrapatakNumber=PrapatakNumber, MantraNumber=MantraNumber,
|
133 |
AnuvakNumber=AnuvakNumber, AdhyayaNumber=AdhyayaNumber)
|
134 |
if filter_df is not None:
|
135 |
+
MantraID = filter_df.iloc[0]['mantra_number']
|
136 |
+
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{MantraID}'"
|
137 |
+
details = get_details_mantra_json(query)
|
138 |
+
mantra_details = details['mantraHeader']['language'][1]
|
139 |
+
return mantra_details
|
140 |
except Exception as e:
|
141 |
return json.dumps({"error": str(e)})
|
142 |
|
|
|
154 |
'''
|
155 |
try:
|
156 |
if mantraid:
|
157 |
+
MantraID = mantraid
|
158 |
else:
|
159 |
filtered_df = self._get_mantra_details_by_scripture(scripture_name=scripture_name, KandahNumber=KandahNumber,MandalaNumber=MandalaNumber, ArchikahNumber=ArchikahNumber,
|
160 |
ShuktaNumber=ShuktaNumber, PrapatakNumber=PrapatakNumber, MantraNumber=MantraNumber,
|
161 |
AnuvakNumber=AnuvakNumber, AdhyayaNumber=AdhyayaNumber)
|
162 |
if filtered_df is not None:
|
163 |
+
MantraID = filtered_df.iloc[0]['mantra_number']
|
164 |
+
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{MantraID}'"
|
|
|
|
|
165 |
json_dict = get_details_mantra_json(query)
|
166 |
mantra_summary = json_dict['mantraSummary']['language']
|
167 |
summary_dict = {"Roman-IAST summary of vedamantra": json_dict['mantraSummary']['language'][1]}
|