Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files- nalayiram_helper.py +12 -1
- tools.py +7 -3
nalayiram_helper.py
CHANGED
|
@@ -8,13 +8,24 @@ class Pasuram:
|
|
| 8 |
azhwar_name: str
|
| 9 |
prabandham_name: str
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def get_standardized_azhwar_names() -> list[Pasuram]:
|
| 13 |
"""
|
| 14 |
Get a list of azhwar names along with the pasurams they have authored in divya_prabandham
|
| 15 |
"""
|
| 16 |
with open("./data/azhwars.json", "r", encoding="utf-8") as f:
|
| 17 |
-
azhwars = json.load(f)
|
| 18 |
header = azhwars[0]
|
| 19 |
rows = azhwars[1:]
|
| 20 |
final_azhwars = [Pasuram(**dict(zip(header, row))) for row in rows]
|
|
|
|
| 8 |
azhwar_name: str
|
| 9 |
prabandham_name: str
|
| 10 |
|
| 11 |
+
def get_standardized_prabandham_names() -> list[Pasuram]:
|
| 12 |
+
"""
|
| 13 |
+
Get a list of prabandham names along with the azhwars who authored them in divya_prabandham
|
| 14 |
+
"""
|
| 15 |
+
with open("./data/azhwars.json", "r", encoding="utf-8") as f:
|
| 16 |
+
azhwars = json.load(f)
|
| 17 |
+
header = azhwars[0]
|
| 18 |
+
rows = azhwars[1:]
|
| 19 |
+
final_azhwars = [Pasuram(**dict(zip(header, row))) for row in rows]
|
| 20 |
+
|
| 21 |
+
return final_azhwars
|
| 22 |
|
| 23 |
def get_standardized_azhwar_names() -> list[Pasuram]:
|
| 24 |
"""
|
| 25 |
Get a list of azhwar names along with the pasurams they have authored in divya_prabandham
|
| 26 |
"""
|
| 27 |
with open("./data/azhwars.json", "r", encoding="utf-8") as f:
|
| 28 |
+
azhwars = json.load(f)
|
| 29 |
header = azhwars[0]
|
| 30 |
rows = azhwars[1:]
|
| 31 |
final_azhwars = [Pasuram(**dict(zip(header, row))) for row in rows]
|
tools.py
CHANGED
|
@@ -6,6 +6,7 @@ from config import SanatanConfig
|
|
| 6 |
from nalayiram_helper import (
|
| 7 |
get_standardized_azhwar_names,
|
| 8 |
get_standardized_divya_desam_names,
|
|
|
|
| 9 |
)
|
| 10 |
from push_notifications_helper import push
|
| 11 |
from serperdev_helper import search as search_web
|
|
@@ -39,13 +40,16 @@ tool_search_db_for_literal = StructuredTool.from_function(
|
|
| 39 |
query_by_literal_text,
|
| 40 |
name="tool_search_db_by_literal_text",
|
| 41 |
description=(
|
| 42 |
-
"
|
| 43 |
-
"
|
|
|
|
|
|
|
| 44 |
f" The collection_name must be one of: {', '.join(allowed_collections)}."
|
| 45 |
),
|
| 46 |
)
|
| 47 |
|
| 48 |
|
|
|
|
| 49 |
tool_search_db_by_metadata = StructuredTool.from_function(
|
| 50 |
query_by_metadata_field,
|
| 51 |
name="tool_search_db_by_metadata",
|
|
@@ -95,7 +99,7 @@ tool_get_standardized_azhwar_names = StructuredTool.from_function(
|
|
| 95 |
)
|
| 96 |
|
| 97 |
tool_get_standardized_prabandham_names = StructuredTool.from_function(
|
| 98 |
-
|
| 99 |
name="tool_get_standardized_prabandham_names",
|
| 100 |
description=(
|
| 101 |
"Get a list of standardized prabandham names."
|
|
|
|
| 6 |
from nalayiram_helper import (
|
| 7 |
get_standardized_azhwar_names,
|
| 8 |
get_standardized_divya_desam_names,
|
| 9 |
+
get_standardized_prabandham_names,
|
| 10 |
)
|
| 11 |
from push_notifications_helper import push
|
| 12 |
from serperdev_helper import search as search_web
|
|
|
|
| 40 |
query_by_literal_text,
|
| 41 |
name="tool_search_db_by_literal_text",
|
| 42 |
description=(
|
| 43 |
+
"🚫 Never use this tool by default."
|
| 44 |
+
" ✅ Only use this tool if the user explicitly requests a 'literal match', 'exact phrase search', or uses words like 'match exactly', 'find the exact string', 'verbatim', or 'literal text'."
|
| 45 |
+
" If the user simply asks for a verse number (e.g., verse 34, pasuram 2.3.5, sahasranamam verse 20), you must NOT use this tool — instead you must use `tool_search_db_by_metadata`."
|
| 46 |
+
" Do not fall back to this tool if semantic or metadata search seems difficult or fails — it is reserved strictly for explicit literal match requests."
|
| 47 |
f" The collection_name must be one of: {', '.join(allowed_collections)}."
|
| 48 |
),
|
| 49 |
)
|
| 50 |
|
| 51 |
|
| 52 |
+
|
| 53 |
tool_search_db_by_metadata = StructuredTool.from_function(
|
| 54 |
query_by_metadata_field,
|
| 55 |
name="tool_search_db_by_metadata",
|
|
|
|
| 99 |
)
|
| 100 |
|
| 101 |
tool_get_standardized_prabandham_names = StructuredTool.from_function(
|
| 102 |
+
get_standardized_prabandham_names,
|
| 103 |
name="tool_get_standardized_prabandham_names",
|
| 104 |
description=(
|
| 105 |
"Get a list of standardized prabandham names."
|