Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files- modules/nodes/init.py +5 -7
- modules/nodes/state.py +2 -1
modules/nodes/init.py
CHANGED
|
@@ -6,14 +6,10 @@ from modules.nodes.state import ChatState
|
|
| 6 |
|
| 7 |
def init_system_prompt_node(state: ChatState) -> ChatState:
|
| 8 |
messages = state["messages"] or []
|
|
|
|
| 9 |
|
| 10 |
# Check if system prompts were already added
|
| 11 |
-
|
| 12 |
-
isinstance(m, SystemMessage) and "format_scripture_answer" in m.content
|
| 13 |
-
for m in messages
|
| 14 |
-
)
|
| 15 |
-
|
| 16 |
-
if not already_has_prompt:
|
| 17 |
scriptures = SanatanConfig().filter_scriptures_fields(
|
| 18 |
fields_to_keep=[
|
| 19 |
"name",
|
|
@@ -87,6 +83,7 @@ You must answer the question using **only** the content from *{collection_name}*
|
|
| 87 |
- Do **not** use verse numbers or line references unless clearly mentioned in the context.
|
| 88 |
|
| 89 |
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**.
|
|
|
|
| 90 |
|
| 91 |
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. I searched using {search_methodology}. Do you want me try to another search like {alternative_searchmethod}?"**
|
| 92 |
|
|
@@ -153,10 +150,11 @@ The following format should be used to show only the most relevant match. Do not
|
|
| 153 |
|
| 154 |
---
|
| 155 |
|
| 156 |
-
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.
|
| 157 |
"""
|
| 158 |
),
|
| 159 |
]
|
|
|
|
| 160 |
state["tool_calls"] = 0
|
| 161 |
state["seen_tool_calls"] = set()
|
| 162 |
state["skip_tool"] = False
|
|
|
|
| 6 |
|
| 7 |
def init_system_prompt_node(state: ChatState) -> ChatState:
|
| 8 |
messages = state["messages"] or []
|
| 9 |
+
initialized = state["initialized"] if "initialized" in state else False
|
| 10 |
|
| 11 |
# Check if system prompts were already added
|
| 12 |
+
if not initialized:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
scriptures = SanatanConfig().filter_scriptures_fields(
|
| 14 |
fields_to_keep=[
|
| 15 |
"name",
|
|
|
|
| 83 |
- Do **not** use verse numbers or line references unless clearly mentioned in the context.
|
| 84 |
|
| 85 |
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**.
|
| 86 |
+
If the answer asks for translation to another language of their choice and you are capable of doing that, you are allowed to do that.
|
| 87 |
|
| 88 |
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. I searched using {search_methodology}. Do you want me try to another search like {alternative_searchmethod}?"**
|
| 89 |
|
|
|
|
| 150 |
|
| 151 |
---
|
| 152 |
|
| 153 |
+
Respond in **Markdown** format only. Ensure native Sanskrit/Tamil verses are always clearly shown and translated. If a section does not apply (e.g. no verses), you may omit it.
|
| 154 |
"""
|
| 155 |
),
|
| 156 |
]
|
| 157 |
+
state["initialized"] = True
|
| 158 |
state["tool_calls"] = 0
|
| 159 |
state["seen_tool_calls"] = set()
|
| 160 |
state["skip_tool"] = False
|
modules/nodes/state.py
CHANGED
|
@@ -8,4 +8,5 @@ class ChatState(TypedDict):
|
|
| 8 |
messages: Annotated[list[str], add_messages]
|
| 9 |
tool_calls: int
|
| 10 |
seen_tool_calls: set[tuple[str, str]] # (tool_name, params_hash)
|
| 11 |
-
skip_tool: bool
|
|
|
|
|
|
| 8 |
messages: Annotated[list[str], add_messages]
|
| 9 |
tool_calls: int
|
| 10 |
seen_tool_calls: set[tuple[str, str]] # (tool_name, params_hash)
|
| 11 |
+
skip_tool: bool
|
| 12 |
+
initialized : bool
|