Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

modify spo app save yaml

xiangjinyu084d522f0b88
diff --git a/metagpt/ext/spo/app.py b/metagpt/ext/spo/app.py
index 5e4f1d7d6..7d026a4a3 100644
--- a/metagpt/ext/spo/app.py
+++ b/metagpt/ext/spo/app.py
@@ -25,11 +25,11 @@ def save_yaml_template(template_path, data):
template_format = {
"prompt": str(data.get("prompt", "")),
"requirements": str(data.get("requirements", "")),
- "count": data.get("count"),
+ "count": data.get("count"), # 保持None值
"faq": [
{
- "question": str(faq.get("question", "")),
- "answer": str(faq.get("answer", ""))
+ "question": str(faq.get("question", "")).strip(),
+ "answer": str(faq.get("answer", "")).strip()
}
for faq in data.get("faq", [])
]
@@ -38,11 +38,20 @@ def save_yaml_template(template_path, data):
template_path.parent.mkdir(parents=True, exist_ok=True)
with open(template_path, 'w', encoding='utf-8') as f:
- yaml.dump(template_format, f, allow_unicode=True, sort_keys=False)
+ yaml.dump(
+ template_format,
+ f,
+ allow_unicode=True,
+ sort_keys=False,
+ default_flow_style=False,
+ indent=2
+ )
+
def main():
- st.title("SPO Prompt Optimizer")
+
+ st.title("SPO | Self-Supervised Prompt Optimization 🤖")
# Sidebar for configurations
with st.sidebar: