Spaces:
Running

vikramvasudevan commited on
Commit
5d00a8f
ยท
verified ยท
1 Parent(s): f2be657

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. modules/nodes/init.py +77 -11
modules/nodes/init.py CHANGED
@@ -28,16 +28,7 @@ def init_system_prompt_node(state: ChatState) -> ChatState:
28
  content=f"Here is the list of all scriptures along with their metadata configurations:\n{json.dumps(scriptures, indent=1)}\n"
29
  ),
30
  SystemMessage(
31
- content="โš ๏ธ Do NOT summarize or compress the output from the `query` tool. It will be passed directly to `format_scripture_answer` tool that formats the answer **AS IS**. DO NOT REMOVE SANSKRIT/TAMIL TEXTS"
32
- ),
33
- SystemMessage(
34
- content="You MUST call the `format_scripture_answer` tool if the user question is about scripture content and the `query` tool has returned a result."
35
- ),
36
- SystemMessage(
37
- content="For general scripture queries, always prefer semantic search (tool_search_db). Use metadata or literal search only if the user specifies an exact verse number, azhwar, divya desam or phrase."
38
- ),
39
- SystemMessage(
40
- content="you must ALWAYS call one of the standardization tools available to get the correct entity name before using the `tool_search_db_by_metadata` tool."
41
  ),
42
  SystemMessage(
43
  content="""
@@ -53,9 +44,84 @@ def init_system_prompt_node(state: ChatState) -> ChatState:
53
  If they are essentially the same, do NOT call it again โ€” instead, proceed to generate the final validated output.
54
  """
55
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  ]
57
  state["tool_calls"] = 0
58
  state["seen_tool_calls"] = set()
59
  state["skip_tool"] = False
60
 
61
- return state
 
28
  content=f"Here is the list of all scriptures along with their metadata configurations:\n{json.dumps(scriptures, indent=1)}\n"
29
  ),
30
  SystemMessage(
31
+ content="you must ALWAYS call one of the standardization tools (`tool_get_standardized_azhwar_names`,`tool_get_standardized_prabandham_names`,`tool_get_standardized_divya_desam_names`) available to get the correct entity name before using the `tool_search_db_by_metadata` tool."
 
 
 
 
 
 
 
 
 
32
  ),
33
  SystemMessage(
34
  content="""
 
44
  If they are essentially the same, do NOT call it again โ€” instead, proceed to generate the final validated output.
45
  """
46
  ),
47
+ SystemMessage(
48
+ content="""You are a knowledgeable assistant on the scripture *{collection_name}*, well-versed in **Sanskrit** , **English** and **Tamil**.
49
+ You must answer the question using **only** the content from *{collection_name}* provided in the context below.
50
+ - Do **not** bring in information from **any other scripture or source**, or from prior knowledge, even if the answer seems obvious or well-known.
51
+ - Do **not** quote any Sanskrit/Tamil verses unless they appear **explicitly** in the provided context.
52
+ - Do **not** use verse numbers or line references unless clearly mentioned in the context.
53
+
54
+ If the answer is not directly stated in the verses but is present in explanatory notes within the context, you may interpret โ€” but **explicitly mention that it is an interpretation**.
55
+
56
+ If the answer WAS indeed found in the context, use the following response format (in Markdown) othereise clearly state **"I do not have enough information from the {collection_name} to answer this."**
57
+
58
+ ### ๐Ÿงพ Answer
59
+ - Present a brief summary of your response in concise **English**.
60
+
61
+ ### ๐Ÿ•‰๏ธ Scripture
62
+ - {sanatanConfig.get_scripture_by_collection(collection_name=collection_name)["title"]}
63
+
64
+ ### ๐Ÿ•ฎ Chapter Title
65
+ - Mention the chapter(s) from which the references were taken. Use the field *title* here from the context if available. For example `TVM 1.8.3`
66
+
67
+ ### ๐Ÿ•ฎ Verse Number
68
+ - Mention the *verse number* from which the references were taken.
69
+
70
+ ### ๐Ÿ”— Reference Link(s)
71
+ - Provide reference link(s) (`html_url`) if one is available in the context.
72
+
73
+ ### ๐Ÿ“œ Native Verse(s) - Original
74
+ - Include the original native verses as-is
75
+
76
+ ### ๐Ÿ“œ Native Verse(s) - Sanitized
77
+
78
+ - Task: Sanitize the native verses **without adding, removing, or inventing text**. Only fix obvious encoding or typographical errors.
79
+ - Sanitization rules:
80
+ 1. Correct garbled Unicode characters.
81
+ 2. Fix broken diacritics, pulli markers, vowel signs, and punctuation.
82
+ 3. Preserve **original spacing, line breaks, and character order**.
83
+ - Do not translate, transliterate, or interpret.
84
+ - Do not hallucinate or generate new verses.
85
+ - Output should only be the **cleaned, original verses**.
86
+ - The output in this section **MUST** be in native script not english or transliterated english.
87
+ > If you are unsure about a character, leave it as it is rather than guessing.
88
+
89
+
90
+ ### ๐Ÿ“œ English Transliteration
91
+ - For each verse above, provide the **matching English transliteration**.
92
+ - Maintain the **same order** as the verses listed above.
93
+
94
+ ### ๐Ÿ“œ English Translation
95
+ - Provide the **English meaning** for each verse listed above.
96
+ - Again, follow the **same order**.
97
+ - Do **not** repeat the original verse here โ€” just the translation.
98
+
99
+ ### ๐Ÿ“œ Notes
100
+ - Bullet any extra points or cross-references from explanatory notes **only if present in the context**.
101
+ - Do **not** include anything that is not supported or implied in the context.
102
+
103
+ โš ๏ธ Do **not duplicate content** across sections.
104
+ - Each section has a distinct purpose.
105
+ - If a verse is shown in `๐Ÿ“œ Supporting Verse(s)`, do **not** repeat it in the Translation section.
106
+ - Only transliterations and meanings should appear in their respective sections.
107
+
108
+
109
+ **Question:**
110
+ {question}
111
+
112
+ ---
113
+
114
+ **Context:**
115
+ {query_tool_output}
116
+
117
+ ---
118
+
119
+ Respond in **Markdown** format only. Ensure Sanskrit/Tamil verses are always clearly shown and translated. If a section does not apply (e.g. no verses), you may omit it.
120
+ """
121
+ ),
122
  ]
123
  state["tool_calls"] = 0
124
  state["seen_tool_calls"] = set()
125
  state["skip_tool"] = False
126
 
127
+ return state