Initial commit: jaspersoft-agent-learn teaching project

This commit is contained in:
zy187
2026-05-29 23:22:18 +08:00
commit 05bb511aab
20 changed files with 4476 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
"""
Step 03: 构建简单 Agent - 主程序
运行方式:
cd step_03_simple_agent
python main.py
"""
from concept import SimpleAgent
def main():
"""交互式演示 Agent"""
print("=" * 70)
print(" Step 03: 构建简单 Agent - 交互式演示")
print("=" * 70)
print("""
欢迎使用 Jaspersoft 报表助手!
我可以帮你:
- 生成 JRXML 报表模板
- 搜索相关报表模板
- 验证报表代码
- 执行数学计算
输入 'quit''退出' 结束对话
""")
# 创建 Agent
agent = SimpleAgent()
# 显示可用工具
print("\n📋 我的能力:")
for tool in agent.get_available_tools():
print(f"{tool['name']}: {tool['description']}")
print("\n" + "-" * 70)
print("开始对话:")
print("-" * 70)
# 交互式循环
while True:
try:
user_input = input("\n👤 你: ").strip()
if not user_input:
continue
if user_input.lower() in ["quit", "退出", "exit", "q"]:
print("\n👋 再见!")
break
# 处理输入
response = agent.process(user_input)
# 显示响应
print(f"\n🤖 Agent: {response}")
except KeyboardInterrupt:
print("\n\n👋 再见!")
break
except Exception as e:
print(f"\n❌ 出错了: {e}")
# 显示会话统计
print("\n\n" + "=" * 70)
print("📊 会话统计")
print("=" * 70)
print(f" 对话轮次: {len(agent.get_history()) // 2}")
print(f" 工具调用: {len(agent.state.get('tool_calls', []))}")
print("\n💡 继续学习:")
print(" Step 04: 添加 Memory - 记忆系统")
print(" Step 05: 添加 RAG - 知识检索")
if __name__ == "__main__":
main()