You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.6 KiB
63 lines
1.6 KiB
"""
|
|
快速测试创作灵感生成功能
|
|
"""
|
|
|
|
import asyncio
|
|
from ai_agent import create_agent
|
|
|
|
|
|
async def quick_test():
|
|
"""快速测试"""
|
|
|
|
print("=" * 80)
|
|
print("创作灵感生成 - 快速测试")
|
|
print("=" * 80)
|
|
print()
|
|
|
|
# 获取用户输入
|
|
print("请输入你的创作需求(或直接回车使用示例):")
|
|
print("示例:我想做一些美食相关的短视频,主要是家常菜的制作教程")
|
|
print()
|
|
|
|
user_input = input("你的需求: ").strip()
|
|
|
|
if not user_input:
|
|
user_input = "我想做一些美食相关的短视频,主要是家常菜的制作教程"
|
|
print(f"使用示例需求: {user_input}")
|
|
|
|
print("\n" + "=" * 80)
|
|
print("正在生成创作灵感...")
|
|
print("=" * 80)
|
|
print()
|
|
|
|
try:
|
|
# 创建Agent
|
|
agent = create_agent()
|
|
|
|
# 运行Agent
|
|
result = await agent.run(
|
|
user_input=user_input,
|
|
system_prompt_file="prompts/agent_prompt.md",
|
|
max_iterations=15
|
|
)
|
|
|
|
print("\n" + "=" * 80)
|
|
print("结果")
|
|
print("=" * 80)
|
|
print()
|
|
|
|
if result["success"]:
|
|
print(result["final_answer"])
|
|
print("\n" + "=" * 80)
|
|
print(f"✓ 成功!共调用了 {len(result['tool_calls'])} 个工具")
|
|
else:
|
|
print(f"✗ 失败: {result['error']}")
|
|
|
|
except Exception as e:
|
|
print(f"\n✗ 出错: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(quick_test())
|
|
|