Initial commit
This commit is contained in:
43
backend/planner/planning_agent/planner.py
Normal file
43
backend/planner/planning_agent/planner.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# planning_agent/planner.py
|
||||
from pathlib import Path
|
||||
import datetime
|
||||
import textwrap
|
||||
from typing import Optional
|
||||
|
||||
from .langchain_pipeline import generate_natural_plan
|
||||
|
||||
|
||||
def build_plan_from_text(requirement_text: str, source_doc: str = "用户输入", output_dir: str = "") -> str:
|
||||
"""
|
||||
根据输入文本生成自然语言测试规划。
|
||||
直接返回生成的 Markdown 内容(不保存文件)。
|
||||
"""
|
||||
# 调用 LLM 生成规划
|
||||
plan_text = generate_natural_plan(requirement_text)
|
||||
|
||||
if not plan_text:
|
||||
return ""
|
||||
|
||||
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# Markdown 包装模板
|
||||
md_template = f"""
|
||||
# 📘 自动化测试任务规划
|
||||
|
||||
**来源文档:** `{source_doc}`
|
||||
**生成时间:** {timestamp}
|
||||
|
||||
---
|
||||
|
||||
## 📝 测试规划内容
|
||||
|
||||
{plan_text}
|
||||
|
||||
---
|
||||
|
||||
## 📌 说明
|
||||
本规划由智能体自动生成,内容遵循自然语言任务规划格式,可直接用于后续自动化测试代码生成。
|
||||
"""
|
||||
md_content = textwrap.dedent(md_template).strip()
|
||||
|
||||
return md_content
|
||||
Reference in New Issue
Block a user