第六课 Lagent & AgentLego 智能体应用搭建 学习笔记及作业
一、基础理论
1.1 为什么要有智能体
大语言模型毕竟是一个基于一定算法与机器运行基础的模型,存在一定局限性,比如会有幻觉:出现虚假信息。有时效性限制:数据过时时无法反应最新趋势和信息。可靠性得不到保障:在面对复杂任务时,可能频发错误输出现象,影响信任度。这就使得智能体应运而生。
1.2 智能体简介
智能体三要素:感知环境中的动态条件;采取动作影响环境;运用推理能力理解信息、解决问题、产生推断、决定动作。
智能体包括:
大脑:记忆、思考和决策任务。接受来自感知模块的信息,采取相应的动作。
感知:对外部环境的多模态信息进行感知和处理。
动作:利用并执行工具以影响环境。
1.3 智能体范式
1、AutoGPT
2、ReWoo
3、ReAct
1.4 智能体范式
Lagent 和 AgentLego 介绍
Lagent
AgentLego
两者的关系
二、课程实操
2.1 环境配置
2.1.1 创建开发机和 conda 环境
在创建开发机界面选择镜像为 Cuda12.2-conda,并选择 GPU 为30% A100。这里前面几节课已经做过介绍,这里不再赘述。
进入开发机后,为了方便使用,我们需要配置一个环境以同时满足 Lagent 和 AgentLego 运行时所需依赖。在开始配置环境前,我们先创建一个用于存放 Agent 相关文件的目录,可以执行如下命令:
mkdir -p /root/agent
输入如下指令配置 conda 环境:
studio-conda -t agent -o pytorch-2.1.2
经过漫长的等待,出现如下图所示时,conda环境配置成功。
2.1.2 安装 Lagent 和 AgentLego
安装 Lagent 和 AgentLego,可以使用pip安装。这里为了方便使用 Lagent 的 Web Demo 以及 AgentLego 的 WebUI,选择直接从源码进行安装。
执行如下命令进行安装:
cd /root/agent
conda activate agent
git clone https://gitee.com/internlm/lagent.git
cd lagent && git checkout 581d9fb && pip install -e . && cd ..
git clone https://gitee.com/internlm/agentlego.git
cd agentlego && git checkout 7769e0d && pip install -e . && cd ..
如上图, Lagent 和 AgentLego源码通过git clone方法安装成功。
2.1.3 涉及到轻量化的部署应用,安装lmdeploy
执行如下命令安装lmdeploy:
conda activate agent
pip install lmdeploy==0.3.0
安装成功!
2.1.4 准备 Tutorial
由于后续的 Demo 需要用到 tutorial 已经写好的脚本,因此我们需要将 tutorial 通过 git clone 的方法准备好,以备后续使用:
cd /root/agent
git clone -b camp2 https://gitee.com/internlm/Tutorial.git
准备成功。
至此,我们需要的运行环境及依赖的包都准备成功了!
2.2 Lagent:轻量级智能体框架实践
2.2.1. Lagent Web Demo
2.2.1.1 使用 LMDeploy 部署
在 vscode terminal 中执行如下代码使用 LMDeploy 启动一个 api_server。
conda activate agent
lmdeploy serve api_server /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b \
--server-name 127.0.0.1 \
--model-name internlm2-chat-7b \
--cache-max-entry-count 0.1
启动完成。
2.2.1.2 启动并使用 Lagent Web Demo
按照下图指示新建一个 terminal 以启动 Lagent Web Demo。在新建的 terminal 中执行如下指令:
conda activate agent
cd /root/agent/lagent/examples
streamlit run internlm2_agent_web_demo.py --server.address 127.0.0.1 --server.port 7860
如上图及上上图所示,LMDeploy 的 api_server 与 Lagent Web Demo 完全启动后,在本地进行端口映射,将 LMDeploy api_server 的23333端口以及 Lagent Web Demo 的7860端口映射到本地。打开本地PowerShell,执行:
ssh -CNg -L 7860:127.0.0.1:7860 -L 23333:127.0.0.1:23333 root@ssh.intern-ai.org.cn -p 36116
根据开发机的端口及提供的密码(见下图),在PowerShell中建立映射。
出现如下状态,则显示映射成功。
在本地的浏览器页面中打开 http://localhost:7860 以使用 Lagent Web Demo。首先输入模型 IP 为 127.0.0.1:23333,在输入完成后按下回车键以确认。并选择插件为 ArxivSearch,以让模型获得在 arxiv 上搜索论文的能力。
输入“帮我搜索 InternLM2 Technical Report” 以让模型搜索书生·浦语2的技术报告。效果如下图所示,可以看到模型正确输出了 InternLM2 技术报告的相关信息。
2.2.2. 用 Lagent 自定义工具
Lagent 中关于工具部分的介绍文档位于 https://lagent.readthedocs.io/zh-cn/latest/tutorials/action.html 。使用 Lagent 自定义工具主要分为以下几步:
1、继承 BaseAction 类
2、实现简单工具的 run 方法;或者实现工具包内每个子工具的功能
3、简单工具的 run 方法可选被 tool_api 装饰;工具包内每个子工具的功能都需要被 tool_api 装饰
下面我们将实现一个调用和风天气 API 的工具以完成实时天气查询的功能。
2.2.2.1 创建工具文件
首先通过 touch /root/agent/lagent/lagent/actions/weather.py
(大小写敏感)新建工具文件:
复制如下代码进weather.py 文件并保存:
import json
import os
import requests
from typing import Optional, Type
from lagent.actions.base_action import BaseAction, tool_api
from lagent.actions.parser import BaseParser, JsonParser
from lagent.schema import ActionReturn, ActionStatusCode
class WeatherQuery(BaseAction):
"""Weather plugin for querying weather information."""
def __init__(self,
key: Optional[str] = None,
description: Optional[dict] = None,
parser: Type[BaseParser] = JsonParser,
enable: bool = True) -> None:
super().__init__(description, parser, enable)
key = os.environ.get('WEATHER_API_KEY', key)
if key is None:
raise ValueError(
'Please set Weather API key either in the environment '
'as WEATHER_API_KEY or pass it as `key`')
self.key = key
self.location_query_url = 'https://geoapi.qweather.com/v2/city/lookup'
self.weather_query_url = 'https://devapi.qweather.com/v7/weather/now'
@tool_api
def run(self, query: str) -> ActionReturn:
"""一个天气查询API。可以根据城市名查询天气信息。
Args:
query (:class:`str`): The city name to query.
"""
tool_return = ActionReturn(type=self.name)
status_code, response = self._search(query)
if status_code == -1:
tool_return.errmsg = response
tool_return.state = ActionStatusCode.HTTP_ERROR
elif status_code == 200:
parsed_res = self._parse_results(response)
tool_return.result = [dict(type='text', content=str(parsed_res))]
tool_return.state = ActionStatusCode.SUCCESS
else:
tool_return.errmsg = str(status_code)
tool_return.state = ActionStatusCode.API_ERROR
return tool_return
def _parse_results(self, results: dict) -> str:
"""Parse the weather results from QWeather API.
Args:
results (dict): The weather content from QWeather API
in json format.
Returns:
str: The parsed weather results.
"""
now = results['now']
data = [
f'数据观测时间: {now["obsTime"]}',
f'温度: {now["temp"]}°C',
f'体感温度: {now["feelsLike"]}°C',
f'天气: {now["text"]}',
f'风向: {now["windDir"]},角度为 {now["wind360"]}°',
f'风力等级: {now["windScale"]},风速为 {now["windSpeed"]} km/h',
f'相对湿度: {now["humidity"]}',
f'当前小时累计降水量: {now["precip"]} mm',
f'大气压强: {now["pressure"]} 百帕',
f'能见度: {now["vis"]} km',
]
return '\n'.join(data)
def _search(self, query: str):
# get city_code
try:
city_code_response = requests.get(
self.location_query_url,
params={'key': self.key, 'location': query}
)
except Exception as e:
return -1, str(e)
if city_code_response.status_code != 200:
return city_code_response.status_code, city_code_response.json()
city_code_response = city_code_response.json()
if len(city_code_response['location']) == 0:
return -1, '未查询到城市'
city_code = city_code_response['location'][0]['id']
# get weather
try:
weather_response = requests.get(
self.weather_query_url,
params={'key': self.key, 'location': city_code}
)
except Exception as e:
return -1, str(e)
return weather_response.status_code, weather_response.json()
2.2.2.2 获取 API KEY
为了获得稳定的天气查询服务,我们首先要获取 API KEY。首先打开 https://dev.qweather.com/docs/api/ 后,点击右上角控制台。(这里需要注册一下账号哈。同志们自己注册一下)见下图:
输入相关项目名称,选择免费订阅,Web API 以及输入 key 的名称。(项目名称和 key 的名词自由输入即可,如下图所示)
接下来回到项目管理页面,查看我们刚刚创建的 key,并且复制好以供使用。
2.2.2.3 体验自定义工具效果
在两个 terminal 中分别启动 LMDeploy 服务和 Tutorial 已经写好的用于这部分的 Web Demo(注意要关闭之前已经启动的 LMDeploy 和Web Demo 服务):
conda activate agent
lmdeploy serve api_server /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b \
--server-name 127.0.0.1 \
--model-name internlm2-chat-7b \
--cache-max-entry-count 0.1
运行成功后如下图所示:
export WEATHER_API_KEY=94a7b9aa5af64da2a41692b6b82d4af1
# 比如 export WEATHER_API_KEY=在2.2.2.2节获取的API KEY
conda activate agent
cd /root/agent/Tutorial/agent
streamlit run internlm2_weather_web_demo.py --server.address 127.0.0.1 --server.port 7860
运行成功后如下图所示:
并在本地执行如下操作,输入开发机的port口以及密码后,以进行端口映射(参照2.2.1.2):
ssh -CNg -L 7860:127.0.0.1:7860 -L 23333:127.0.0.1:23333 root@ssh.intern-ai.org.cn -p 36116
打开浏览器,输入http://127.0.0.1:7860/网址,加载成功后,模型IP选择127.0.0.1:23333,插件选择WeatherQuery 后,就可以开始体验了。我这里输入“请帮我查询明天苏州的天气情况。”,但是结果只反馈今天的天气情况。如果我指定日期,则查询不到,这也算是个小bug吧。
2.3 AgentLego:组装智能体“乐高”
2.3.1 直接使用 AgentLego
首先下载 demo 文件:
cd /root/agent
wget http://download.openmmlab.com/agentlego/road.jpg
由于 AgentLego 在安装时并不会安装某个特定工具的依赖,因此我们接下来准备安装目标检测工具运行时所需依赖。
AgentLego 所实现的目标检测工具是基于 mmdet (MMDetection) 算法库中的 RTMDet-Large 模型,因此我们首先安装 mim,然后通过 mim 工具来安装 mmdet。这一步所需时间可能会较长,请耐心等待。
conda activate agent
pip install openmim==0.3.9
mim install mmdet==3.3.0
使用 touch /root/agent/direct_use.py
新建一个direct_use.py 以直接使用目标检测工具,代码如下:
import re
import cv2
from agentlego.apis import load_tool
# load tool
tool = load_tool('ObjectDetection', device='cuda')
# apply tool
visualization = tool('/root/agent/road.jpg')
print(visualization)
# visualize
image = cv2.imread('/root/agent/road.jpg')
preds = visualization.split('\n')
pattern = r'(\w+) \((\d+), (\d+), (\d+), (\d+)\), score (\d+)'
for pred in preds:
name, x1, y1, x2, y2, score = re.match(pattern, pred).groups()
x1, y1, x2, y2, score = int(x1), int(y1), int(x2), int(y2), int(score)
cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 1)
cv2.putText(image, f'{name} {score}', (x1, y1), cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 0), 1)
cv2.imwrite('/root/agent/road_detection_direct.jpg', image)
此时文件结构如下图:
执行 python /root/agent/direct_use.py
以进行推理。在等待 RTMDet-Large 权重下载并推理完成后,我们就可以看到如下输出以及一张位于 /root/agent 名为 road_detection_direct.jpg 的图片,输出结果如下图:
2.3.2 作为智能体工具使用
2.3.2.1 修改相关文件
由于 AgentLego 算法库默认使用 InternLM2-Chat-20B 模型,因此我们首先需要修改 /root/agent/agentlego/webui/modules/agents/lagent_agent.py 文件的第 105行位置,将 internlm2-chat-20b 修改为 internlm2-chat-7b,即
def llm_internlm2_lmdeploy(cfg):
url = cfg['url'].strip()
llm = LMDeployClient(
- model_name='internlm2-chat-20b',
+ model_name='internlm2-chat-7b',
url=url,
meta_template=INTERNLM2_META,
top_p=0.8,
top_k=100,
temperature=cfg.get('temperature', 0.7),
repetition_penalty=1.0,
stop_words=['<|im_end|>'])
return llm
修改后如下图:
2.3.2.2 使用 LMDeploy 部署
使用 LMDeploy 部署
由于 AgentLego 的 WebUI 需要用到 LMDeploy 所启动的 api_server,因此我们首先按照下图指示在 vscode terminal 中执行如下代码使用 LMDeploy 启动一个 api_server。
conda activate agent
lmdeploy serve api_server /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b \
--server-name 127.0.0.1 \
--model-name internlm2-chat-7b \
--cache-max-entry-count 0.1
如下图所示,启动成功:
2.3.2.3 启动 AgentLego WebUI
接下来我们按照下图指示新建一个 terminal 以启动 AgentLego WebUI。在新建的 terminal 中执行如下指令:
conda activate agent
cd /root/agent/agentlego/webui
python one_click.py
出现报错:
根据报错,将所需要的库进行修正。执行如下代码:
pip install -U langchain-community
再次:python one_click.py
,执行成功,结果如下:
在本地进行端口映射,打开本地PowerShell,输入如下代码和开发机SSH密码即可
AgentLego WebUI 的7860端口映射到本地。执行:
ssh -CNg -L 7860:127.0.0.1:7860 -L 23333:127.0.0.1:23333 root@ssh.intern-ai.org.cn -p 36116
2.3.2.4 使用 AgentLego WebUI
输入开发机ssh密码后,即可在本地打开127.0.0.1:7860,使用 AgentLego WebUI。此时还需要进行如下配置:
1、点击上方 Agent 进入 Agent 配置页面。(如①所示)
2、点击 Agent 下方框,选择 New Agent。(如②所示)
3、选择 Agent Class 为 lagent.InternLM2Agent。(如③所示)
4、输入模型 URL 为 http://127.0.0.1:23333 。(如④所示)
5、输入 Agent name,自定义即可,图中输入了 internlm2。(如⑤所示)
6、点击 save to 以保存配置,这样在下次使用时只需在第2步时选择 Agent 为 internlm2 后点击 load 以加载就可以了。(如⑥所示)
7、点击 load 以加载配置。(如⑦所示)
然后配置工具,如下图所示。
1、点击上方 Tools 页面进入工具配置页面。(如①所示)
2、点击 Tools 下方框,选择 New Tool 以加载新工具。(如②所示)
3、选择 Tool Class 为 ObjectDetection。(如③所示)
4、点击 save 以保存配置。(如④所示)
如下图所示,此时agent与tools都加载成功了
等待工具加载完成后,点击上方 Chat 以进入对话页面。在页面下方选择工具部分只选择 ObjectDetection 工具,如下图所示。为了确保调用工具的成功率,请在使用时确保仅有这一个工具启用。
我上传了一张包含多艘船舶的图片让其检测,结果总体还可以,(虽然不知道为啥检测出一辆汽车。)
后台给出了检测时间,整体时间都比较短,精准度也还可以(虽然莫名其妙见除了一辆汽车,但也还行吧,见下图)。
2.3.3 用 AgentLego 自定义工具
我们将基于 AgentLego 构建自己的自定义工具。AgentLego 在这方面提供了较为详尽的文档,文档地址为 https://agentlego.readthedocs.io/zh-cn/latest/modules/tool.html 。自定义工具主要分为以下几步:
1、继承 BaseTool 类
2、修改 default_desc 属性(工具功能描述)
3、如有需要,重载 setup 方法(重型模块延迟加载)
4、重载 apply 方法(工具功能实现)
其中第一二四步是必须的步骤。下面我们将实现一个调用 MagicMaker 的 API 以实现图像生成的工具。
MagicMaker 是汇聚了优秀 AI 算法成果的免费 AI 视觉素材生成与创作平台。主要提供图像生成、图像编辑和视频生成三大核心功能,全面满足用户在各种应用场景下的视觉素材创作需求。体验更多功能可以访问 https://magicmaker.openxlab.org.cn/home 。
其中第一二四步是必须的步骤。下面我们将实现一个调用 MagicMaker 的 API 以实现图像生成的工具。
2.3.3.1 创建工具文件
首先通过 touch /root/agent/agentlego/agentlego/tools/magicmaker_image_generation.py
(大小写敏感)的方法新建工具文件。该文件的内容如下:
import json
import requests
import numpy as np
from agentlego.types import Annotated, ImageIO, Info
from agentlego.utils import require
from .base import BaseTool
class MagicMakerImageGeneration(BaseTool):
default_desc = ('This tool can call the api of magicmaker to '
'generate an image according to the given keywords.')
styles_option = [
'dongman', # 动漫
'guofeng', # 国风
'xieshi', # 写实
'youhua', # 油画
'manghe', # 盲盒
]
aspect_ratio_options = [
'16:9', '4:3', '3:2', '1:1',
'2:3', '3:4', '9:16'
]
@require('opencv-python')
def __init__(self,
style='guofeng',
aspect_ratio='4:3'):
super().__init__()
if style in self.styles_option:
self.style = style
else:
raise ValueError(f'The style must be one of {self.styles_option}')
if aspect_ratio in self.aspect_ratio_options:
self.aspect_ratio = aspect_ratio
else:
raise ValueError(f'The aspect ratio must be one of {aspect_ratio}')
def apply(self,
keywords: Annotated[str,
Info('A series of Chinese keywords separated by comma.')]
) -> ImageIO:
import cv2
response = requests.post(
url='https://magicmaker.openxlab.org.cn/gw/edit-anything/api/v1/bff/sd/generate',
data=json.dumps({
"official": True,
"prompt": keywords,
"style": self.style,
"poseT": False,
"aspectRatio": self.aspect_ratio
}),
headers={'content-type': 'application/json'}
)
image_url = response.json()['data']['imgUrl']
image_response = requests.get(image_url)
image = cv2.cvtColor(cv2.imdecode(np.frombuffer(image_response.content, np.uint8), cv2.IMREAD_COLOR),cv2.COLOR_BGR2RGB)
return ImageIO(image)
2.3.3.2 注册新工具
接下来修改 /root/agent/agentlego/agentlego/tools/init.py 文件,将我们的工具注册在工具列表中。如下所示,我们将 MagicMakerImageGeneration 通过 from .magicmaker_image_generation import MagicMakerImageGeneration 导入到了文件中,并且将其加入了 all 列表中。修改后的代码如下,直接全部复制黏贴进去保存即可。
from .base import BaseTool
from .calculator import Calculator
from .func import make_tool
from .image_canny import CannyTextToImage, ImageToCanny
from .image_depth import DepthTextToImage, ImageToDepth
from .image_editing import ImageExpansion, ImageStylization, ObjectRemove, ObjectReplace
from .image_pose import HumanBodyPose, HumanFaceLandmark, PoseToImage
from .image_scribble import ImageToScribble, ScribbleTextToImage
from .image_text import ImageDescription, TextToImage
from .imagebind import AudioImageToImage, AudioTextToImage, AudioToImage, ThermalToImage
from .object_detection import ObjectDetection, TextToBbox
from .ocr import OCR
from .scholar import * # noqa: F401, F403
from .search import BingSearch, GoogleSearch
from .segmentation import SegmentAnything, SegmentObject, SemanticSegmentation
from .speech_text import SpeechToText, TextToSpeech
from .translation import Translation
from .vqa import VQA
from .magicmaker_image_generation import MagicMakerImageGeneration
__all__ = [
'CannyTextToImage', 'ImageToCanny', 'DepthTextToImage', 'ImageToDepth',
'ImageExpansion', 'ObjectRemove', 'ObjectReplace', 'HumanFaceLandmark',
'HumanBodyPose', 'PoseToImage', 'ImageToScribble', 'ScribbleTextToImage',
'ImageDescription', 'TextToImage', 'VQA', 'ObjectDetection', 'TextToBbox', 'OCR',
'SegmentObject', 'SegmentAnything', 'SemanticSegmentation', 'ImageStylization',
'AudioToImage', 'ThermalToImage', 'AudioImageToImage', 'AudioTextToImage',
'SpeechToText', 'TextToSpeech', 'Translation', 'GoogleSearch', 'Calculator',
'BaseTool', 'make_tool', 'BingSearch', 'MagicMakerImageGeneration'
]
3.3.3.3 体验自定义工具效果
与2.3.2.2,2.3.2.3,2.3.2.4类似,我们在两个 terminal 中分别启动 LMDeploy 服务和 AgentLego 的 WebUI 以体验我们自定义的工具的效果。
conda activate agent
lmdeploy serve api_server /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b \
--server-name 127.0.0.1 \
--model-name internlm2-chat-7b \
--cache-max-entry-count 0.1
conda activate agent
cd /root/agent/agentlego/webui
python one_click.py
运行成功后显示如下图:
在本地执行如下操作以进行端口映射:
ssh -CNg -L 7860:127.0.0.1:7860 -L 23333:127.0.0.1:23333 root@ssh.intern-ai.org.cn -p 36116
复制密码输入后,即可在127.0.0.1:7860网页打开
在127.0.0.1:7860, 根据2.3.2.4节,在Agent界面选择已经配置好的internlm2并load,
在 Tool 界面选择 MagicMakerImageGeneration 后点击 save 后,回到 Chat 页面选择 MagicMakerImageGeneration 工具后就可以开始使用了。为了确保调用工具的成功率,请在使用时确保仅有这一个工具启用。
下图是本人使用的例子,可以看到工具确实帮我生成了一副很有意境感的美女图片。哈哈。
2.4 Agent 工具能力微调
2.4.1. OpenAI Function Calling
2.4.1.1介绍
为了让大语言模型连接到外部工具,OpenAI 推出了 Function calling 的功能。在 调用 OpenAI 的 API 时,可以描述函数并让模型智能地选择要输出的 JSON 对象,其中包含传递给一个或多个函数的参数。更多信息可以参考(友情提示,需要科学上网,嘿嘿):https://platform.openai.com/docs/guides/function-calling 。
Chat Completions 的相关 API 并不会调用函数;相反,我们可以在自己的代码中根据模型的输出来实现调用函数的逻辑。大体工作流程如下:
其中,我们将对话数据和工具描述传递给 API 模型。在得到 API 模型的输出后,我们在本地根据输出调用函数,最终得到结果。
2.4.1.2 数据格式
本节介绍 OpenAI Function Calling 所规定的数据格式,以便于使用 XTuner 进行微调时理解数据的结构。
1、对话部分
messages = [
{
"role": "user",
"content": "What's the weather like in San Francisco, Tokyo, and Paris?"
}
]
如上,这是一个简单的对话数据,包含 role 和 content 两个字段,分别表示输入角色和输入内容。
2、工具描述部分
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
},
}
]
如上所示是 OpenAI Function Calling 的工具描述部分。各字段描述如下:
可以看到,工具描述部分详细地描述了函数的名词和输入参数信息,以便于模型能够智能地选择要调用的函数,并且传入正确的参数。
2.4.2. 基于 XTuner 的 Agent 工具能力微调
emmmmm,这节待官方更新,后续有了再补充。
三、作业
3.1 基础作业
完成 Lagent Web Demo 使用,并在作业中上传截图。文档可见 Lagent Web Demo
本部分作业及截图见2.1以及2.2.1节。
完成 AgentLego 直接使用部分,并在作业中上传截图。文档可见 直接使用 AgentLego。
本部分作业及截图见2.1以及2.3.1节。
3.2 进阶作业
完成 AgentLego WebUI 使用,并在作业中上传截图。
本部分作业及截图见2.1以及2.3.2节。
使用 Lagent 或 AgentLego 实现自定义工具并完成调用,并在作业中上传截图。
本部分作业及截图见2.1以及2.2.2;2.3.3节。
3.3 大作业选题(待后续更新)
3.3.1 算法方向(待后续更新)
在 Lagent 或 AgentLego 中实现 RAG 工具,实现智能体与知识库的交互。
基于 Lagent 或 AgentLego 实现工具的多轮调用,完成复杂任务。如:智能体调用翻译工具,再调用搜索工具,最后调用生成工具,完成一个完整的任务。
…
3.3.2 应用方向(待后续更新)
基于 Lagent 或 AgentLego 实现一个客服智能体,帮助用户解决问题。
基于 Lagent 或 AgentLego 实现一个智能体,实现艺术创作,如生成图片、视频、音乐等。
…