Spaces:
Sleeping
Sleeping
samlonka
commited on
Commit
·
ef9d847
1
Parent(s):
21eb7b6
'tools'
Browse files
Tools.py
CHANGED
@@ -21,11 +21,18 @@ PADA_CSV_PATH = "Data/term_data_processed_v2.csv"
|
|
21 |
|
22 |
class ScriptureDescriptionToolSpec(BaseToolSpec):
|
23 |
'''
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
'''
|
30 |
spec_functions = ["get_description"]
|
31 |
|
@@ -46,9 +53,9 @@ class ScriptureDescriptionToolSpec(BaseToolSpec):
|
|
46 |
except IndexError as e:
|
47 |
raise ValueError(f"Failed to get scripture description: {e}")
|
48 |
|
49 |
-
def get_description(self,
|
50 |
try:
|
51 |
-
conditions = (self.df['scripture_name'].str.lower() ==
|
52 |
if level_3 is not None:
|
53 |
conditions &= (self.df['level_1'] == str(level_1)) & (self.df['level_2'] == str(level_2)) & (self.df['level_3'] == str(level_3))
|
54 |
elif level_2 is not None:
|
@@ -61,19 +68,19 @@ class ScriptureDescriptionToolSpec(BaseToolSpec):
|
|
61 |
|
62 |
class MantraToolSpec(BaseToolSpec):
|
63 |
'''
|
64 |
-
|
65 |
-
and rishi, from all Vedas (RigVeda, AtharvaVeda, SamaVeda, KrishnaYajurVeda, and ShuklaYajurVeda)
|
66 |
-
|
67 |
-
adhibautic (or adhyatmic or adhidyvic) meaning (or
|
68 |
-
|
69 |
-
|
70 |
-
Here's a sample query format:
|
71 |
-
|
72 |
-
1. Obtain the vedamantra of the mantra 1.1.1.1?
|
73 |
2. Retrieve the devata of the vedamantra from Rigveda, first mandala, first shukta, and first mantra.
|
74 |
3. Provide the meaning of the vedamantra from Rigveda, first mandala, first shukta, and first mantra written by Tulsi Ram.
|
75 |
4. Explain the adhibautic meaning of the first mantra from RigVeda, first mandala, and first shukta.
|
76 |
5. Identify the mantraVishaya of the vedamantra from RigVeda, first mandala, first shukta, and first mantra.
|
|
|
|
|
|
|
77 |
'''
|
78 |
spec_functions = ["get_vedamantra_details", "get_vedamantra_summary"]
|
79 |
|
@@ -88,13 +95,30 @@ class MantraToolSpec(BaseToolSpec):
|
|
88 |
except Exception as e:
|
89 |
raise ValueError(f"Failed to get mantra details: {e}")
|
90 |
|
91 |
-
def _get_mantra_details_by_scripture(self, scripture_name=None,
|
|
|
|
|
92 |
try:
|
|
|
93 |
if scripture_name:
|
94 |
condition = (self.df_vedamantra['scripture_name'].str.lower() == scripture_name.lower())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
for key, value in kwargs.items():
|
97 |
-
condition &= (self.df_vedamantra[key] == value)
|
98 |
filtered_df = self.df_vedamantra[condition]
|
99 |
if not filtered_df.empty:
|
100 |
return filtered_df
|
@@ -104,30 +128,43 @@ class MantraToolSpec(BaseToolSpec):
|
|
104 |
logging.error(f"Error in _get_pada_details_by_scripture: {e}")
|
105 |
|
106 |
|
107 |
-
def
|
108 |
-
|
109 |
-
|
110 |
-
return mantraID.values[0]
|
111 |
-
|
112 |
-
def get_vedamantra_details(self, mantraid=None, scripture_name=None,**kwargs):
|
113 |
try:
|
114 |
if mantraid:
|
115 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantraid}'"
|
116 |
else:
|
117 |
-
|
|
|
|
|
|
|
118 |
#print(mantra_id)
|
119 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantra_id}'"
|
120 |
return self._get_mantra_details(query)
|
121 |
except Exception as e:
|
122 |
return {"error": str(e)}
|
123 |
|
124 |
-
def get_vedamantra_summary(self, mantraid=None, scripture_name=None,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
try:
|
126 |
if mantraid:
|
127 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantraid}'"
|
128 |
else:
|
129 |
-
|
130 |
-
|
|
|
|
|
131 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantra_id}'"
|
132 |
json_dict = get_details_mantra_json(query)
|
133 |
mantra_summary = json_dict['mantraSummary']['language']
|
@@ -159,17 +196,33 @@ class PadaToolSpec(BaseToolSpec):
|
|
159 |
self.df_terms = pd.read_csv(PADA_CSV_PATH, dtype={'AnuvakNumber': 'Int64', 'PrapatakNumber': 'Int64', 'KandahNumber': 'Int64', 'ShuktaNumber': 'Int64', 'ArchikahNumber': 'Int64', 'AdhyayaNumber': 'Int64', 'MandalaNumber': 'Int64', 'ParyayaNumber': 'Int64'}, encoding='utf-8')
|
160 |
self.df_vedic_content = pd.read_csv(VEDAMANTRA_CSV_PATH,encoding = 'utf-8')
|
161 |
|
162 |
-
def _get_pada_details_by_scripture(self, pada, scripture_name=None,
|
|
|
|
|
163 |
try:
|
164 |
pada = iast_process(pada)
|
165 |
condition = (self.df_terms['Pada'] == pada)
|
166 |
|
167 |
if scripture_name:
|
168 |
condition &= (self.df_terms['scripture_name'].str.lower() == scripture_name.lower())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
-
for key, value in kwargs.items():
|
171 |
-
condition &= (self.df_terms[key] == value)
|
172 |
-
|
173 |
filtered_df = self.df_terms[condition]
|
174 |
|
175 |
if not filtered_df.empty:
|
@@ -205,7 +258,7 @@ class PadaToolSpec(BaseToolSpec):
|
|
205 |
return best_meaning if best_meaning else {"error": "Required meaning associated with vedamantra is not available."}
|
206 |
except Exception as e:
|
207 |
logging.error(f"Error in _get_vedamantra_meaning: {e}")
|
208 |
-
return {"error": f"An error occurred: {e}"}
|
209 |
|
210 |
def _get_pada_morphology(self, term_details, meanings):
|
211 |
try:
|
@@ -240,27 +293,32 @@ class PadaToolSpec(BaseToolSpec):
|
|
240 |
return meanings_list
|
241 |
except Exception as e:
|
242 |
logging.error(f"Error in get_pada_meaning: {e}")
|
243 |
-
return {"error": f"Required meaning associated with pada is not available. {e}"}
|
244 |
|
245 |
|
246 |
def get_adibauatic_adidaivic_adhyatmic_meaning_of_pada(self, pada, mantraid=None, scripture_name=None,
|
247 |
KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
248 |
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
249 |
-
AnuvakNumber=None, AdhyayaNumber=None,
|
250 |
-
|
|
|
|
|
|
|
|
|
251 |
try:
|
|
|
252 |
if mantraid:
|
253 |
details = self.df_terms[(self.df_terms['mantra_id'] == mantraid) & (self.df_terms['Pada'] == pada)]
|
254 |
-
|
255 |
else:
|
256 |
-
|
257 |
-
|
|
|
258 |
|
259 |
if not details.empty:
|
260 |
pada_details = details.iloc[0]
|
261 |
#print(pada_details)
|
262 |
mantraID = pada_details['mantra_id']
|
263 |
-
meanings = self._get_vedamantra_meaning(mantraID,MahatmaName=
|
264 |
if 'error' in meanings:
|
265 |
return meanings
|
266 |
ab_term_morph_list = self._get_pada_morphology(pada_details, meanings['adibhautic'])
|
@@ -275,7 +333,7 @@ class PadaToolSpec(BaseToolSpec):
|
|
275 |
'vedamantra_adhyatmic_meaning': meanings['adhyatmic']
|
276 |
}
|
277 |
else:
|
278 |
-
return {"error": f"No details found for pada '{pada}'"}
|
279 |
except Exception as e:
|
280 |
logging.error(f"Error in get_adibauatic_adidaivic_adhyatmic_meaning_of_pada: {e}")
|
281 |
-
return {"error": f"Failed to get meaning of the word {pada}. {e}"}
|
|
|
21 |
|
22 |
class ScriptureDescriptionToolSpec(BaseToolSpec):
|
23 |
'''
|
24 |
+
Purpose: Obtains the description or summary about vedas, mandalas, kandas, shuktas, archakah, adhyaya, and other scriptural elements.
|
25 |
+
Returns: A dictionary containing the description or basic information about the specified scriptural element.
|
26 |
+
Structure of the levels in each Vedas:
|
27 |
+
RigVeda->Mandala->Shukta
|
28 |
+
ShuklaYajurVeda->Adhyaya
|
29 |
+
SamaVeda->Archika->Shukta
|
30 |
+
Atharvaveda->Kandah->Shukta
|
31 |
+
Sample query:
|
32 |
+
1. Describe the first kandah, second shukta from Atharvaveda?
|
33 |
+
scripture_name: Atharvaveda, level_0: 1, level_1:2
|
34 |
+
2. Summarize ShuklaYajurVeda?
|
35 |
+
3. What is the difference between ShuklaYajurVeda and KrishnaYajurVeda?
|
36 |
'''
|
37 |
spec_functions = ["get_description"]
|
38 |
|
|
|
53 |
except IndexError as e:
|
54 |
raise ValueError(f"Failed to get scripture description: {e}")
|
55 |
|
56 |
+
def get_description(self, scripture_name: str, level_1: int=None, level_2: int=None, level_3: int=None):
|
57 |
try:
|
58 |
+
conditions = (self.df['scripture_name'].str.lower() == scripture_name.lower())
|
59 |
if level_3 is not None:
|
60 |
conditions &= (self.df['level_1'] == str(level_1)) & (self.df['level_2'] == str(level_2)) & (self.df['level_3'] == str(level_3))
|
61 |
elif level_2 is not None:
|
|
|
68 |
|
69 |
class MantraToolSpec(BaseToolSpec):
|
70 |
'''
|
71 |
+
Use the function `get_vedamantra_details` to retrieve detailed information about Vedic mantras, including vedamantra, padapatha, devata, chandah,
|
72 |
+
and rishi, from all Vedas (RigVeda, AtharvaVeda, SamaVeda, KrishnaYajurVeda, and ShuklaYajurVeda).
|
73 |
+
Use the function `get_vedamantra_summary` to access the information such as anvaya of the mantra, mantraVishaya of the mantra,
|
74 |
+
adhibautic (or adhyatmic or adhidyvic) meaning (or bhavarth) of the mantra, purpose of the mantra, usage of the mantra, and tippani of the mantra.
|
75 |
+
Sample Questions:
|
76 |
+
1. Obtain the vedamantra of the mantra whose id is 1.1.1.1?
|
|
|
|
|
|
|
77 |
2. Retrieve the devata of the vedamantra from Rigveda, first mandala, first shukta, and first mantra.
|
78 |
3. Provide the meaning of the vedamantra from Rigveda, first mandala, first shukta, and first mantra written by Tulsi Ram.
|
79 |
4. Explain the adhibautic meaning of the first mantra from RigVeda, first mandala, and first shukta.
|
80 |
5. Identify the mantraVishaya of the vedamantra from RigVeda, first mandala, first shukta, and first mantra.
|
81 |
+
6. What is the adibhautic meaning of the mantra 1.1.1.9?
|
82 |
+
7. What is the adhyatmic meaning of the mantra 1.1.1.7?
|
83 |
+
8. What is the adhidyic meaning of the 6th mantra from RigVeda, first mandala, and first shukta?
|
84 |
'''
|
85 |
spec_functions = ["get_vedamantra_details", "get_vedamantra_summary"]
|
86 |
|
|
|
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):
|
101 |
try:
|
102 |
+
condition = True
|
103 |
if scripture_name:
|
104 |
condition = (self.df_vedamantra['scripture_name'].str.lower() == scripture_name.lower())
|
105 |
+
if KandahNumber:
|
106 |
+
condition &= (self.df_vedamantra['KandahNumber'] == KandahNumber)
|
107 |
+
if MandalaNumber:
|
108 |
+
condition &= (self.df_vedamantra['MandalaNumber'] == MandalaNumber)
|
109 |
+
if ArchikahNumber:
|
110 |
+
condition &= (self.df_vedamantra['ArchikahNumber'] == ArchikahNumber)
|
111 |
+
if ShuktaNumber:
|
112 |
+
condition &= (self.df_vedamantra['ShuktaNumber'] == ShuktaNumber)
|
113 |
+
if PrapatakNumber:
|
114 |
+
condition &= (self.df_vedamantra['PrapatakNumber'] == PrapatakNumber)
|
115 |
+
if MantraNumber:
|
116 |
+
condition &= (self.df_vedamantra['MantraNumber'] == MantraNumber)
|
117 |
+
if AnuvakNumber:
|
118 |
+
condition &= (self.df_vedamantra['AnuvakNumber'] == AnuvakNumber)
|
119 |
+
if AdhyayaNumber:
|
120 |
+
condition &= (self.df_vedamantra['AdhyayaNumber'] == AdhyayaNumber)
|
121 |
|
|
|
|
|
122 |
filtered_df = self.df_vedamantra[condition]
|
123 |
if not filtered_df.empty:
|
124 |
return filtered_df
|
|
|
128 |
logging.error(f"Error in _get_pada_details_by_scripture: {e}")
|
129 |
|
130 |
|
131 |
+
def get_vedamantra_details(self, mantraid=None, scripture_name=None, KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
132 |
+
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
133 |
+
AnuvakNumber=None, AdhyayaNumber=None):
|
|
|
|
|
|
|
134 |
try:
|
135 |
if mantraid:
|
136 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantraid}'"
|
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 |
+
mantra_id = filter_df['mantra_number'].values[0]
|
142 |
#print(mantra_id)
|
143 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantra_id}'"
|
144 |
return self._get_mantra_details(query)
|
145 |
except Exception as e:
|
146 |
return {"error": str(e)}
|
147 |
|
148 |
+
def get_vedamantra_summary(self, mantraid=None, scripture_name=None, KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
149 |
+
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
150 |
+
AnuvakNumber=None, AdhyayaNumber=None):
|
151 |
+
'''
|
152 |
+
Sample Query:
|
153 |
+
1. Obtain the anvaya of the mantra whose id (mantraid) is 1.1.1.1?
|
154 |
+
2. Retrieve tha adibhautic meaning of the mantra from RigVeda, first mandala, first shukta, and first mantra.
|
155 |
+
3. Provide the adhyatmic meaning of the mantra 1.1.1.9?
|
156 |
+
4. What is the tippani of the mantra 1.1.1.7?
|
157 |
+
5. What is the adhyatmic meaning of the mantra 1.1.1.7?
|
158 |
+
6. What is the mantravishaya of the 6th mantra from RigVeda, first mandala, and first shukta?
|
159 |
+
'''
|
160 |
try:
|
161 |
if mantraid:
|
162 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantraid}'"
|
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 |
+
mantra_id = filtered_df['mantra_number'].values[0]
|
168 |
query = f"SELECT mantra_json FROM veda_content WHERE mantra_number = '{mantra_id}'"
|
169 |
json_dict = get_details_mantra_json(query)
|
170 |
mantra_summary = json_dict['mantraSummary']['language']
|
|
|
196 |
self.df_terms = pd.read_csv(PADA_CSV_PATH, dtype={'AnuvakNumber': 'Int64', 'PrapatakNumber': 'Int64', 'KandahNumber': 'Int64', 'ShuktaNumber': 'Int64', 'ArchikahNumber': 'Int64', 'AdhyayaNumber': 'Int64', 'MandalaNumber': 'Int64', 'ParyayaNumber': 'Int64'}, encoding='utf-8')
|
197 |
self.df_vedic_content = pd.read_csv(VEDAMANTRA_CSV_PATH,encoding = 'utf-8')
|
198 |
|
199 |
+
def _get_pada_details_by_scripture(self, pada, scripture_name=None, KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
200 |
+
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
201 |
+
AnuvakNumber=None, AdhyayaNumber=None):
|
202 |
try:
|
203 |
pada = iast_process(pada)
|
204 |
condition = (self.df_terms['Pada'] == pada)
|
205 |
|
206 |
if scripture_name:
|
207 |
condition &= (self.df_terms['scripture_name'].str.lower() == scripture_name.lower())
|
208 |
+
|
209 |
+
if KandahNumber:
|
210 |
+
condition &= (self.df_terms['KandahNumber'] == KandahNumber)
|
211 |
+
if MandalaNumber:
|
212 |
+
condition &= (self.df_terms['MandalaNumber'] == MandalaNumber)
|
213 |
+
if ArchikahNumber:
|
214 |
+
condition &= (self.df_terms['ArchikahNumber'] == ArchikahNumber)
|
215 |
+
if ShuktaNumber:
|
216 |
+
condition &= (self.df_terms['ShuktaNumber'] == ShuktaNumber)
|
217 |
+
if PrapatakNumber:
|
218 |
+
condition &= (self.df_terms['PrapatakNumber'] == PrapatakNumber)
|
219 |
+
if MantraNumber:
|
220 |
+
condition &= (self.df_terms['MantraNumber'] == MantraNumber)
|
221 |
+
if AnuvakNumber:
|
222 |
+
condition &= (self.df_terms['AnuvakNumber'] == AnuvakNumber)
|
223 |
+
if AdhyayaNumber:
|
224 |
+
condition &= (self.df_terms['AdhyayaNumber'] == AdhyayaNumber)
|
225 |
|
|
|
|
|
|
|
226 |
filtered_df = self.df_terms[condition]
|
227 |
|
228 |
if not filtered_df.empty:
|
|
|
258 |
return best_meaning if best_meaning else {"error": "Required meaning associated with vedamantra is not available."}
|
259 |
except Exception as e:
|
260 |
logging.error(f"Error in _get_vedamantra_meaning: {e}")
|
261 |
+
return json.loads({"error": f"An error occurred: {e}"})
|
262 |
|
263 |
def _get_pada_morphology(self, term_details, meanings):
|
264 |
try:
|
|
|
293 |
return meanings_list
|
294 |
except Exception as e:
|
295 |
logging.error(f"Error in get_pada_meaning: {e}")
|
296 |
+
return json.dumps({"error": f"Required meaning associated with pada is not available. {e}"})
|
297 |
|
298 |
|
299 |
def get_adibauatic_adidaivic_adhyatmic_meaning_of_pada(self, pada, mantraid=None, scripture_name=None,
|
300 |
KandahNumber=None,MandalaNumber=None, ArchikahNumber=None,
|
301 |
ShuktaNumber=None, PrapatakNumber=None, MantraNumber=None,
|
302 |
+
AnuvakNumber=None, AdhyayaNumber=None,MahatmaName=None):
|
303 |
+
'''
|
304 |
+
Sample query:
|
305 |
+
1. What is the meaning of pada 'agnim' from RigVeda, first mandala, first shukta and first mantra?
|
306 |
+
2. What is the adhyatmic meaning of the pada agnim in the context of the mantra whose id is '1.1.1.1?'
|
307 |
+
'''
|
308 |
try:
|
309 |
+
pada = iast_process(pada)
|
310 |
if mantraid:
|
311 |
details = self.df_terms[(self.df_terms['mantra_id'] == mantraid) & (self.df_terms['Pada'] == pada)]
|
|
|
312 |
else:
|
313 |
+
details = self._get_pada_details_by_scripture(pada, scripture_name=scripture_name, KandahNumber=KandahNumber,MandalaNumber=MandalaNumber, ArchikahNumber=ArchikahNumber,
|
314 |
+
ShuktaNumber=ShuktaNumber, PrapatakNumber=PrapatakNumber, MantraNumber=MantraNumber,
|
315 |
+
AnuvakNumber=AnuvakNumber, AdhyayaNumber=AdhyayaNumber)
|
316 |
|
317 |
if not details.empty:
|
318 |
pada_details = details.iloc[0]
|
319 |
#print(pada_details)
|
320 |
mantraID = pada_details['mantra_id']
|
321 |
+
meanings = self._get_vedamantra_meaning(mantraID,MahatmaName=MahatmaName)
|
322 |
if 'error' in meanings:
|
323 |
return meanings
|
324 |
ab_term_morph_list = self._get_pada_morphology(pada_details, meanings['adibhautic'])
|
|
|
333 |
'vedamantra_adhyatmic_meaning': meanings['adhyatmic']
|
334 |
}
|
335 |
else:
|
336 |
+
return json.dumps({"error": f"No details found for pada '{pada}'"})
|
337 |
except Exception as e:
|
338 |
logging.error(f"Error in get_adibauatic_adidaivic_adhyatmic_meaning_of_pada: {e}")
|
339 |
+
return json.dumps({"error": f"Failed to get meaning of the word {pada}. {e}"})
|
app.py
CHANGED
@@ -94,10 +94,10 @@ query_engine_tools = [
|
|
94 |
Helpful to get semantic information from the documents. These documents containing comprehensive information about the Vedas.\
|
95 |
They also covers various aspects, including general details about the Vedas, fundamental terminology associated with Vedic literature, \
|
96 |
and detailed information about Vedamantras for each Veda. The Vedamantra details encompass essential elements such as padapatha, rishi, chandah,\
|
97 |
-
devata, and swarah.This tool is very useful to answer general questions related to vedas
|
98 |
-
Sample Query
|
99 |
-
1. What is the meaning of devata
|
100 |
-
2. What are the different Brahmanas associated with SamaVeda
|
101 |
3. What is the difference between Shruti and Smriti.
|
102 |
'''
|
103 |
),
|
@@ -111,12 +111,12 @@ query_engine_tools = [
|
|
111 |
'''A powerful tool designed to handle queries related to counting information about vedic content document. This document is a .csv file with different columns as follows:\
|
112 |
'mantra_id', 'scripture_name', 'KandahNumber', 'PrapatakNumber','AnuvakNumber', 'MantraNumber', 'DevataName', 'RishiName', 'SwarahName', 'ChandaName',\
|
113 |
'padapatha', 'vedamantra', 'AdhyayaNumber', 'ArchikahNumber', 'ArchikahName', 'ShuktaNumber', 'keyShukta', 'ParyayaNumber', 'MandalaNumber'.\
|
114 |
-
Always provide the final answer after excuting pandas query which is equivalent to user query
|
115 |
-
Sample Query
|
116 |
-
1. How many mantras are there in RigVeda whose swarah is gāndhāra
|
117 |
-
2. How many different devata present in
|
118 |
-
3. Which Kandah has the maximum number of in KrishnaYajurVeda
|
119 |
-
4. Find the number of mantras from AtharvaVeda whose devata is vācaspatiḥ and chandah is anuṣṭup
|
120 |
5. count the mantras in RigVeda whose swarah is gāndhāraḥ?
|
121 |
'''
|
122 |
),
|
@@ -127,13 +127,13 @@ query_engine_tools = [
|
|
127 |
metadata=ToolMetadata(
|
128 |
name="pandas_engine_padas",
|
129 |
description=(
|
130 |
-
'''A powerful tool designed to handle queries related to counting information about pada or words from vedic documents. This document is a .csv file with different columns as follows
|
131 |
-
'Pada', 'scripture_name', 'mantra_id', 'MantraNumber', 'AnuvakNumber', 'PrapatakNumber', 'KandahNumber', 'Pada_position', 'term_index', 'Segmentation', 'Morphology', 'ShuktaNumber'
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
'''
|
138 |
),
|
139 |
),
|
@@ -149,15 +149,16 @@ tools = [*mantra_tools,*pada_tools,*description_tools,*query_engine_tools]
|
|
149 |
context = """
|
150 |
You are an expert on Vedas and related scriptures.
|
151 |
Your role is to respond to questions about vedic scriptures (RigVeda, AtharvaVeda, SamaVeda, ShuklaYajurVeda, and KrishnaYajurVeda) and associated information based on available sources.\
|
152 |
-
For every query, you
|
153 |
Please provide well-informed answers. If the context or history is not sufficient, you can say that you don't have sufficient information. Don't use prior knowledge.
|
154 |
-
If your response is based on "Implicit" thought then you can
|
155 |
Also, provide three follow-up questions based on the input query and the context in the following format.
|
|
|
156 |
*****
|
157 |
You may also try the following questions:
|
158 |
-
1.
|
159 |
-
2.
|
160 |
-
3.
|
161 |
"""
|
162 |
|
163 |
# Function to create ReActAgent instance (change it based on your initialization logic)
|
|
|
94 |
Helpful to get semantic information from the documents. These documents containing comprehensive information about the Vedas.\
|
95 |
They also covers various aspects, including general details about the Vedas, fundamental terminology associated with Vedic literature, \
|
96 |
and detailed information about Vedamantras for each Veda. The Vedamantra details encompass essential elements such as padapatha, rishi, chandah,\
|
97 |
+
devata, and swarah.This tool is very useful to answer general questions related to vedas.
|
98 |
+
Sample Query:
|
99 |
+
1. What is the meaning of devata ?
|
100 |
+
2. What are the different Brahmanas associated with SamaVeda?
|
101 |
3. What is the difference between Shruti and Smriti.
|
102 |
'''
|
103 |
),
|
|
|
111 |
'''A powerful tool designed to handle queries related to counting information about vedic content document. This document is a .csv file with different columns as follows:\
|
112 |
'mantra_id', 'scripture_name', 'KandahNumber', 'PrapatakNumber','AnuvakNumber', 'MantraNumber', 'DevataName', 'RishiName', 'SwarahName', 'ChandaName',\
|
113 |
'padapatha', 'vedamantra', 'AdhyayaNumber', 'ArchikahNumber', 'ArchikahName', 'ShuktaNumber', 'keyShukta', 'ParyayaNumber', 'MandalaNumber'.\
|
114 |
+
Always provide the final answer after excuting pandas query which is equivalent to user query.
|
115 |
+
Sample Query:
|
116 |
+
1. How many mantras are there in RigVeda whose swarah is gāndhāraḥ?
|
117 |
+
2. How many different devata present in RigVeda?
|
118 |
+
3. Which Kandah has the maximum number of in KrishnaYajurVeda?
|
119 |
+
4. Find the number of mantras from AtharvaVeda whose devata is vācaspatiḥ and chandah is anuṣṭup?
|
120 |
5. count the mantras in RigVeda whose swarah is gāndhāraḥ?
|
121 |
'''
|
122 |
),
|
|
|
127 |
metadata=ToolMetadata(
|
128 |
name="pandas_engine_padas",
|
129 |
description=(
|
130 |
+
'''A powerful tool designed to handle queries related to counting information about pada or words from vedic documents. This document is a .csv file with different columns as follows:
|
131 |
+
'Pada', 'scripture_name', 'mantra_id', 'MantraNumber', 'AnuvakNumber', 'PrapatakNumber', 'KandahNumber', 'Pada_position', 'term_index', 'Segmentation', 'Morphology', 'ShuktaNumber',
|
132 |
+
'ArchikahNumber', 'AdhyayaNumber', 'MandalaNumber', 'ParyayaNumber'.
|
133 |
+
Always provide the final answer after excuting pandas query which is equivalent to user query.
|
134 |
+
Sample Query:
|
135 |
+
1. How many padas are there in RigVeda?
|
136 |
+
2. How many padas present in both rigveda and samaveda?
|
137 |
'''
|
138 |
),
|
139 |
),
|
|
|
149 |
context = """
|
150 |
You are an expert on Vedas and related scriptures.
|
151 |
Your role is to respond to questions about vedic scriptures (RigVeda, AtharvaVeda, SamaVeda, ShuklaYajurVeda, and KrishnaYajurVeda) and associated information based on available sources.\
|
152 |
+
For every query, you first use an appropriate tool. If the input args, kwargs and tools for the given query is same as in the history or retrieved context is sufficient, then use the history as context.
|
153 |
Please provide well-informed answers. If the context or history is not sufficient, you can say that you don't have sufficient information. Don't use prior knowledge.
|
154 |
+
If your response is based on "Implicit" thought then you can caution the user that the answer is not from the 'Svarupa Knowledge base'.
|
155 |
Also, provide three follow-up questions based on the input query and the context in the following format.
|
156 |
+
|
157 |
*****
|
158 |
You may also try the following questions:
|
159 |
+
1. Question1
|
160 |
+
2. Question2
|
161 |
+
3. Question3
|
162 |
"""
|
163 |
|
164 |
# Function to create ReActAgent instance (change it based on your initialization logic)
|