Spaces:
Sleeping
Sleeping
samlonka
commited on
Commit
·
418740e
1
Parent(s):
6ad6433
tools modified
Browse files
Tools.py
CHANGED
@@ -54,7 +54,7 @@ class ScriptureDescriptionToolSpec(BaseToolSpec):
|
|
54 |
|
55 |
class MantraToolSpec(BaseToolSpec):
|
56 |
'''
|
57 |
-
To obtain the vedamantra details such as vedamantra,
|
58 |
`get_vedamantra_details`. The mantra summary like anvaya, mantraVishaya, bhavartha/meaning (adhibautic, ahyatmic, adhidaivic), purpose, usage, tippani of vedamantra accessible using the function 'get_vedamantra_summary'
|
59 |
Sample Query:
|
60 |
1. What is the vedamantra of the mantra from Rigveda, first mandala, first shukta, and first mantra?
|
@@ -72,7 +72,6 @@ class MantraToolSpec(BaseToolSpec):
|
|
72 |
def _get_mantra_details(self, query):
|
73 |
try:
|
74 |
details = get_details_mantra_json(query)
|
75 |
-
print(f"The details of the vedamantra are: {details}")
|
76 |
return details['mantraHeader']['language'][1]
|
77 |
except Exception as e:
|
78 |
raise ValueError(f"Failed to get mantra details: {e}")
|
@@ -80,7 +79,6 @@ class MantraToolSpec(BaseToolSpec):
|
|
80 |
def _query_db(self, conditions):
|
81 |
try:
|
82 |
result = self.df_vedamantra[conditions]['mantra_number'].values
|
83 |
-
print(f"The result of vedamatra are: {result}")
|
84 |
if len(result) == 0:
|
85 |
raise ValueError("Mantra not found.")
|
86 |
return result[0]
|
@@ -146,6 +144,7 @@ class PadaToolSpec(BaseToolSpec):
|
|
146 |
self.df_vedic_content = pd.read_csv(VEDAMANTRA_CSV_PATH,encoding = 'utf-8')
|
147 |
|
148 |
def _get_pada_details_by_scripture(self, pada, scripture_name=None, **kwargs):
|
|
|
149 |
try:
|
150 |
condition = (self.df_terms['Pada'] == pada)
|
151 |
if scripture_name:
|
@@ -203,6 +202,7 @@ class PadaToolSpec(BaseToolSpec):
|
|
203 |
return []
|
204 |
|
205 |
def get_pada_meaning(self, pada):
|
|
|
206 |
try:
|
207 |
pada_details = self.df_terms[self.df_terms['Pada'] == pada]
|
208 |
meanings_list = []
|
@@ -217,34 +217,36 @@ class PadaToolSpec(BaseToolSpec):
|
|
217 |
return {"error": f"Required meaning associated with pada is not available. {e}"}
|
218 |
|
219 |
|
220 |
-
def get_adibauatic_adidaivic_adhyatmic_meaning_of_pada(self, pada,
|
|
|
221 |
try:
|
222 |
if mantraid:
|
223 |
details = self.df_terms[(self.df_terms['mantra_id'] == mantraid) & (self.df_terms['Pada'] == pada)]
|
|
|
224 |
else:
|
225 |
if scripture_name is not None:
|
226 |
details = self._get_pada_details_by_scripture(pada, scripture_name, **kwargs)
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
return {"error": f"No details found for pada '{pada}'"}
|
231 |
-
pada_details = details.iloc[0]
|
232 |
-
#print(pada_details)
|
233 |
-
mantraID = pada_details['mantra_id']
|
234 |
-
meanings = self._get_vedamantra_meaning(mantraID,MahatmaName=kwargs.get('MahatmaName'))
|
235 |
-
if 'error' in meanings:
|
236 |
-
return meanings
|
237 |
-
ab_term_morph_list = self._get_pada_morphology(pada_details, meanings['adibhautic'])
|
238 |
-
ad_term_morph_list = self._get_pada_morphology(pada_details, meanings['adidaivic'])
|
239 |
-
at_term_morph_list = self._get_pada_morphology(pada_details, meanings['adhyatmic'])
|
240 |
-
return {
|
241 |
-
f'adibhautic_info_{pada}': ab_term_morph_list,
|
242 |
-
'vedamantra_adibhautic_meaning': meanings['adibhautic'],
|
243 |
-
f'adidavic_info_{pada}': ad_term_morph_list,
|
244 |
-
'vedamantra_adidavic_meaning': meanings['adidaivic'],
|
245 |
-
f'adhyatmic_info_{pada}': at_term_morph_list,
|
246 |
-
'vedamantra_adhyatmic_meaning': meanings['adhyatmic']
|
247 |
-
}
|
248 |
except Exception as e:
|
249 |
logging.error(f"Error in get_adibauatic_adidaivic_adhyatmic_meaning_of_pada: {e}")
|
250 |
-
return {"error": f"Failed to get meaning of the word {pada}. {e}"}
|
|
|
54 |
|
55 |
class MantraToolSpec(BaseToolSpec):
|
56 |
'''
|
57 |
+
To obtain the vedamantra details such as vedamantra, padapatha, devata, chandah, rishi etc of vedamantras (or mantras or hyms) from all vedas (RigVeda, AtharvaVeda, SamaVeda, KrishnaYajurVeda, and ShuklaYajurVeda) using the function
|
58 |
`get_vedamantra_details`. The mantra summary like anvaya, mantraVishaya, bhavartha/meaning (adhibautic, ahyatmic, adhidaivic), purpose, usage, tippani of vedamantra accessible using the function 'get_vedamantra_summary'
|
59 |
Sample Query:
|
60 |
1. What is the vedamantra of the mantra from Rigveda, first mandala, first shukta, and first mantra?
|
|
|
72 |
def _get_mantra_details(self, query):
|
73 |
try:
|
74 |
details = get_details_mantra_json(query)
|
|
|
75 |
return details['mantraHeader']['language'][1]
|
76 |
except Exception as e:
|
77 |
raise ValueError(f"Failed to get mantra details: {e}")
|
|
|
79 |
def _query_db(self, conditions):
|
80 |
try:
|
81 |
result = self.df_vedamantra[conditions]['mantra_number'].values
|
|
|
82 |
if len(result) == 0:
|
83 |
raise ValueError("Mantra not found.")
|
84 |
return result[0]
|
|
|
144 |
self.df_vedic_content = pd.read_csv(VEDAMANTRA_CSV_PATH,encoding = 'utf-8')
|
145 |
|
146 |
def _get_pada_details_by_scripture(self, pada, scripture_name=None, **kwargs):
|
147 |
+
pada = iast_process(pada)
|
148 |
try:
|
149 |
condition = (self.df_terms['Pada'] == pada)
|
150 |
if scripture_name:
|
|
|
202 |
return []
|
203 |
|
204 |
def get_pada_meaning(self, pada):
|
205 |
+
pada=iast_process(pada)
|
206 |
try:
|
207 |
pada_details = self.df_terms[self.df_terms['Pada'] == pada]
|
208 |
meanings_list = []
|
|
|
217 |
return {"error": f"Required meaning associated with pada is not available. {e}"}
|
218 |
|
219 |
|
220 |
+
def get_adibauatic_adidaivic_adhyatmic_meaning_of_pada(self, pada, mantraid=None, scripture_name=None, **kwargs):
|
221 |
+
pada = iast_process(pada)
|
222 |
try:
|
223 |
if mantraid:
|
224 |
details = self.df_terms[(self.df_terms['mantra_id'] == mantraid) & (self.df_terms['Pada'] == pada)]
|
225 |
+
|
226 |
else:
|
227 |
if scripture_name is not None:
|
228 |
details = self._get_pada_details_by_scripture(pada, scripture_name, **kwargs)
|
229 |
+
|
230 |
+
if not details.empty:
|
231 |
+
pada_details = details.iloc[0]
|
232 |
+
#print(pada_details)
|
233 |
+
mantraID = pada_details['mantra_id']
|
234 |
+
meanings = self._get_vedamantra_meaning(mantraID,MahatmaName=kwargs.get('MahatmaName'))
|
235 |
+
if 'error' in meanings:
|
236 |
+
return meanings
|
237 |
+
ab_term_morph_list = self._get_pada_morphology(pada_details, meanings['adibhautic'])
|
238 |
+
ad_term_morph_list = self._get_pada_morphology(pada_details, meanings['adidaivic'])
|
239 |
+
at_term_morph_list = self._get_pada_morphology(pada_details, meanings['adhyatmic'])
|
240 |
+
return {
|
241 |
+
f'adibhautic_info_{pada}': ab_term_morph_list,
|
242 |
+
'vedamantra_adibhautic_meaning': meanings['adibhautic'],
|
243 |
+
f'adidavic_info_{pada}': ad_term_morph_list,
|
244 |
+
'vedamantra_adidavic_meaning': meanings['adidaivic'],
|
245 |
+
f'adhyatmic_info_{pada}': at_term_morph_list,
|
246 |
+
'vedamantra_adhyatmic_meaning': meanings['adhyatmic']
|
247 |
+
}
|
248 |
+
else:
|
249 |
return {"error": f"No details found for pada '{pada}'"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
except Exception as e:
|
251 |
logging.error(f"Error in get_adibauatic_adidaivic_adhyatmic_meaning_of_pada: {e}")
|
252 |
+
return {"error": f"Failed to get meaning of the word {pada}. {e}"}
|