Spaces:
Sleeping
Sleeping
Update prompts/prompts.py
Browse files- prompts/prompts.py +17 -0
prompts/prompts.py
CHANGED
|
@@ -31,8 +31,21 @@ def load_prompts():
|
|
| 31 |
|
| 32 |
def print_default_prompt_templates(agent):
|
| 33 |
import tempfile, pathlib, yaml, json, inspect
|
|
|
|
|
|
|
| 34 |
from dataclasses import is_dataclass, asdict
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def safe_get(obj, attr, default=None):
|
| 37 |
try:
|
| 38 |
return getattr(obj, attr)
|
|
@@ -63,6 +76,10 @@ def print_default_prompt_templates(agent):
|
|
| 63 |
print("agent type:", type(agent))
|
| 64 |
print("has prompt_templates:", hasattr(agent, "prompt_templates"))
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
try:
|
| 67 |
pt = safe_get(agent, "prompt_templates", None)
|
| 68 |
print("prompt_templates object:", pt)
|
|
|
|
| 31 |
|
| 32 |
def print_default_prompt_templates(agent):
|
| 33 |
import tempfile, pathlib, yaml, json, inspect
|
| 34 |
+
import tempfile, pathlib
|
| 35 |
+
|
| 36 |
from dataclasses import is_dataclass, asdict
|
| 37 |
|
| 38 |
+
|
| 39 |
+
with tempfile.TemporaryDirectory() as td:
|
| 40 |
+
agent.save(td)
|
| 41 |
+
for fname in ("prompt.yaml","prompts.yaml","prompt.yml","prompts.yml"):
|
| 42 |
+
p = pathlib.Path(td)/fname
|
| 43 |
+
if p.exists():
|
| 44 |
+
print(f"\n== {fname} ==\n")
|
| 45 |
+
print(p.read_text(encoding="utf-8"))
|
| 46 |
+
break
|
| 47 |
+
|
| 48 |
+
|
| 49 |
def safe_get(obj, attr, default=None):
|
| 50 |
try:
|
| 51 |
return getattr(obj, attr)
|
|
|
|
| 76 |
print("agent type:", type(agent))
|
| 77 |
print("has prompt_templates:", hasattr(agent, "prompt_templates"))
|
| 78 |
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
try:
|
| 84 |
pt = safe_get(agent, "prompt_templates", None)
|
| 85 |
print("prompt_templates object:", pt)
|