{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 项目名称\n", "\n", "## 项目简介\n", "简要介绍项目的目标和功能\n", "\n", "## 作者信息\n", "- 姓名:XXX\n", "- GitHub:@XXX\n", "- 日期:2025-XX-XX" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 第1部分:环境配置" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 安装依赖(如果需要)\n", "# !pip install -q hello-agents[all]\n", "\n", "# 导入必要的库\n", "from hello_agents import SimpleAgent, HelloAgentsLLM\n", "from hello_agents.tools import BaseTool\n", "import os\n", "from dotenv import load_dotenv\n", "\n", "# 加载环境变量\n", "load_dotenv()\n", "\n", "print(\"✅ 环境配置完成\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 第2部分:工具定义" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "class CustomTool(BaseTool):\n", " \"\"\"自定义工具类\"\"\"\n", " \n", " name = \"tool_name\"\n", " description = \"工具描述\"\n", " \n", " def run(self, query: str) -> str:\n", " \"\"\"工具执行逻辑\"\"\"\n", " # 实现你的工具逻辑\n", " return f\"处理结果:{query}\"\n", "\n", "print(\"✅ 工具定义完成\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 第3部分:智能体构建" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 创建LLM\n", "llm = HelloAgentsLLM()\n", "\n", "# 定义系统提示词\n", "system_prompt = \"\"\"你是一个智能助手。\n", "\n", "你的任务是:\n", "1. 理解用户的需求\n", "2. 使用合适的工具\n", "3. 提供有帮助的回答\n", "\"\"\"\n", "\n", "# 创建智能体\n", "agent = SimpleAgent(\n", " name=\"示例智能体\",\n", " llm=llm,\n", " system_prompt=system_prompt\n", ")\n", "\n", "# 添加工具\n", "agent.add_tool(CustomTool())\n", "\n", "print(\"✅ 智能体构建完成\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 第4部分:功能演示" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 示例1:基础功能\n", "print(\"=== 示例1:基础功能 ===\")\n", "result = agent.run(\"你的测试输入\")\n", "print(result)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 示例2:复杂场景\n", "print(\"\\n=== 示例2:复杂场景 ===\")\n", "result = agent.run(\"更复杂的测试输入\")\n", "print(result)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 第5部分:性能评估(可选)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 评估代码\n", "# 例如:测试准确率、响应时间等\n", "\n", "print(\"✅ 评估完成\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 第6部分:总结与展望\n", "\n", "### 项目总结\n", "\n", "#### 实现的功能\n", "- 功能1\n", "- 功能2\n", "\n", "#### 遇到的挑战\n", "- 挑战1及解决方案\n", "- 挑战2及解决方案\n", "\n", "#### 未来改进方向\n", "- 改进1\n", "- 改进2" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.0" } }, "nbformat": 4, "nbformat_minor": 4 }