Spaces:
Sleeping
Sleeping
Refactor system prompt handling in LangGraphAgent and BasicAgent for improved clarity and consistency
Browse files
agent.py
CHANGED
|
@@ -69,14 +69,7 @@ class LangGraphAgent:
|
|
| 69 |
|
| 70 |
def __init__(self, *, model: Optional[object] = None, system_prompt: Optional[str] = None):
|
| 71 |
# Guide the model to use tools and to output a clear final answer.
|
| 72 |
-
|
| 73 |
-
self.system_prompt = (
|
| 74 |
-
base_prompt
|
| 75 |
-
# + "\n\nGuidelines:\n"
|
| 76 |
-
# "- Use tools when they can verify facts or fetch fresh data.\n"
|
| 77 |
-
# "- Think privately; do not reveal chain-of-thought.\n"
|
| 78 |
-
# "- Provide the final user-facing result prefixed exactly with 'FINAL ANSWER:'."
|
| 79 |
-
)
|
| 80 |
|
| 81 |
# Choose an LLM if not provided
|
| 82 |
if model is None:
|
|
|
|
| 69 |
|
| 70 |
def __init__(self, *, model: Optional[object] = None, system_prompt: Optional[str] = None):
|
| 71 |
# Guide the model to use tools and to output a clear final answer.
|
| 72 |
+
self.system_prompt = system_prompt or "You are a helpful assistant. Keep answers concise."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# Choose an LLM if not provided
|
| 75 |
if model is None:
|
app.py
CHANGED
|
@@ -3,16 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
|
| 7 |
-
# --- System Prompt Integration ---
|
| 8 |
-
try:
|
| 9 |
-
from prompt import get_system_prompt as _get_system_prompt # preferred
|
| 10 |
-
except Exception:
|
| 11 |
-
_get_system_prompt = None # type: ignore
|
| 12 |
-
try:
|
| 13 |
-
from prompt import SYSTEM_PROMPT as _SYSTEM_PROMPT # fallback constant
|
| 14 |
-
except Exception:
|
| 15 |
-
_SYSTEM_PROMPT = None # type: ignore
|
| 16 |
|
| 17 |
|
| 18 |
def _load_system_prompt() -> str:
|
|
@@ -20,13 +11,8 @@ def _load_system_prompt() -> str:
|
|
| 20 |
Resolve system prompt from prompt.py:
|
| 21 |
- Prefer get_system_prompt() if available, else SYSTEM_PROMPT, else default.
|
| 22 |
"""
|
| 23 |
-
if
|
| 24 |
-
|
| 25 |
-
return _get_system_prompt() # type: ignore
|
| 26 |
-
except Exception:
|
| 27 |
-
pass
|
| 28 |
-
if isinstance(_SYSTEM_PROMPT, str) and _SYSTEM_PROMPT.strip():
|
| 29 |
-
return _SYSTEM_PROMPT # type: ignore
|
| 30 |
return "You are a helpful assistant. Keep answers concise."
|
| 31 |
|
| 32 |
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from prompt import system_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def _load_system_prompt() -> str:
|
|
|
|
| 11 |
Resolve system prompt from prompt.py:
|
| 12 |
- Prefer get_system_prompt() if available, else SYSTEM_PROMPT, else default.
|
| 13 |
"""
|
| 14 |
+
if system_prompt is not None:
|
| 15 |
+
return system_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
return "You are a helpful assistant. Keep answers concise."
|
| 17 |
|
| 18 |
|