Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Jerry Z H
2025-02-11 20:30:07 +08:00
9 changed files with 113 additions and 30 deletions

View File

@@ -37,7 +37,7 @@ Note - 对于版本的额外说明。
### Changed
- 标准脚手架工程结构改版
脚手架工程结构规范化,您可阅读 [「标准应用工程结构说明」](./docs/guidebook/zh/开始使用/1.标准应用工程结构说明.md) 了解详情。对于旧版本的用户我们为这次改版提供了一些指南说明与工具,详情可阅读 [「aU新老工程迁移指南」](./docs/guidebook/zh/开始使用/7.aU新老工程迁移指南.md)。
脚手架工程结构规范化,您可阅读 [「标准应用工程结构说明」](./docs/guidebook/zh/开始使用/1.标准应用工程结构说明.md) 了解详情。对于旧版本的用户我们为这次改版提供了一些指南说明与工具,详情可阅读 [「aU新老工程迁移指南」](./docs/guidebook/zh/开始使用/6.aU新老工程迁移指南.md)。
### Note
- 新增aU新版记忆机制文档介绍

View File

@@ -80,7 +80,7 @@ pip install agentUniverse
您可以通过 [沉淀与使用智能体模版](./docs/guidebook/zh/开始使用/5.沉淀与使用智能体模版.md) 章节了解如何将有效的智能体模式沉淀成模版,这将大大提升后续智能体的构建效率并便于传播。
#### 常用使用技巧
您可以通过 [常用使用技巧](./docs/guidebook/zh/开始使用/6.常用使用技巧.md) 章节了解智能体应用构建过程中的常用使用技巧例如如何在智能体过程中加入记忆模块、如何有效的管理项目中的prompt等。
您可以通过 [开始章节](./docs/guidebook/zh/开始使用) 下的其他文档了解智能体应用构建过程中的其他进阶技巧例如如何在智能体过程中加入记忆模块、如何有效的管理项目中的prompt等。
### 画布式研发平台搭建

View File

@@ -0,0 +1,76 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2025/2/2 22:00
# @Author : wangyapei
# @FileName: csv_reader.py
import csv
from pathlib import Path
from typing import List, Union, Optional, Dict
from agentuniverse.agent.action.knowledge.reader.reader import Reader
from agentuniverse.agent.action.knowledge.store.document import Document
class CSVReader(Reader):
"""CSV file reader.
Used to read and parse CSV format files, supports local file paths or file objects as input.
"""
def _load_data(self,
file: Union[str, Path],
delimiter: str = ",",
quotechar: str = '"',
ext_info: Optional[Dict] = None) -> List[Document]:
"""Parse CSV file.
Args:
file: CSV file path or file object
delimiter: CSV delimiter, default is comma
quotechar: Quote character, default is double quote
ext_info: Additional metadata information
Returns:
List[Document]: List of documents containing CSV content
Raises:
FileNotFoundError: Raised when file does not exist
ValueError: Raised when file reading fails
"""
try:
if isinstance(file, str):
file = Path(file)
if isinstance(file, Path):
if not file.exists():
raise FileNotFoundError(f"File not found: {file}")
file_content = file.open(newline="", mode="r", encoding="utf-8")
else:
file.seek(0)
file_content = file
csv_content = []
with file_content as csvfile:
csv_reader = csv.reader(csvfile, delimiter=delimiter, quotechar=quotechar)
for row in csv_reader:
# Filter out completely empty rows
if any(cell.strip() for cell in row):
# Remove empty values at the end of row
while row and not row[-1].strip():
row.pop()
# Only add non-empty values to result
csv_content.append(", ".join(filter(None, row)))
# Combine all valid rows into final text
final_content = "\n".join(csv_content)
# Get metadata
metadata = {"file_name": getattr(file, 'name', 'unknown')}
if ext_info:
metadata.update(ext_info)
# print(f"csv_content: {final_content} \n metadata: {metadata}")
return [Document(text=final_content, metadata=metadata)]
except Exception as e:
raise ValueError(f"Failed to read CSV file: {str(e)}") from e

View File

@@ -0,0 +1,6 @@
name: 'default_csv_reader'
description: 'default csv reader'
metadata:
type: 'READER'
module: 'agentuniverse.agent.action.knowledge.reader.file.csv_reader'
class: 'CSVReader'

View File

@@ -1,27 +0,0 @@
# 文档说明
在本例中我们将进一步向大家介绍一些agentUniverse常用的使用技巧。
# 在智能体中加入记忆模块
在智能体使用过程中,我们需要使用智能体记忆这一能力,我们在样例工程中建立了一个使用记忆的案例。
样例地址:[demo_startup_app_with_single_agent_and_memory](../../../../examples/startup_app/demo_startup_app_with_single_agent_and_memory)
在AU智能体中记忆的使用同样通过配置挂载即可我们可以参考智能体[insurance_agent](../../../../examples/startup_app/demo_startup_app_with_single_agent_and_memory/intelligence/agentic/agent/agent_instance/insurance_agent.yaml)配置中`memory`部分。
在该案例中我们配置demo_memory作为记忆实例类型我们进一步在demo_memory.yaml(路径agentUniverse/examples/startup_app/demo_startup_app_with_single_agent_and_memory/intelligence/agentic/memory/demo_memory.yaml)中查看该实例的具体配置。
## 测试记忆模块
通过[insurance_agent_test.py](../../../../examples/startup_app/demo_startup_app_with_single_agent_and_memory/intelligence/test/insurance_agent_test.py)测试入口可以看到智能体加入记忆模块后的使用情况。
![](../../_picture/demo_startup_agent_with_memory.png)
# 使用prompt管理模块
样例地址:[demo_startup_app_with_agent_templates](../../../../examples/startup_app/demo_startup_app_with_agent_templates)
在实际搭建多智能体应用的过程中我们面临大量prompt设置这些prompt将存在于各个yaml中。随着应用的内容增多越来越的prompt将变得难以管理。我们使用prompt管理模块将每一个prompt赋予唯一的prompt_version进行管理与使用。
以demo_startup_app_with_agent_templates工程中的智能体[insurance_consult_pro_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_agent_templates/intelligence/agentic/agent/agent_instance/insurance_consult_pro_agent.yaml)为例,在配置项中我们可以看到 prompt_version 配置为insurance_consult.cn我们可以在 [prompt目录](../../../../examples/startup_app/demo_startup_app_with_agent_templates/intelligence/agentic/prompt)中找到其实际的prompt文件[insurance_multi_agent_cn.yaml](../../../../examples/startup_app/demo_startup_app_with_agent_templates/intelligence/agentic/prompt/insurance_multi_agent_cn.yaml)。
通过这种方式我们可以将大量prompt单独管理并复用起来。
# 其他
更多的使用技巧文档正在补充中...

View File

@@ -0,0 +1,16 @@
# 文档说明
在本例中我们将进一步向大家介绍如何在智能体中加入记忆模块。
# 在智能体中加入记忆模块
在智能体使用过程中,我们需要使用智能体记忆这一能力,我们在样例工程中建立了一个使用记忆的案例。
样例地址:[demo_startup_app_with_single_agent_and_memory](../../../../examples/startup_app/demo_startup_app_with_single_agent_and_memory)
在AU智能体中记忆的使用同样通过配置挂载即可我们可以参考智能体[insurance_agent](../../../../examples/startup_app/demo_startup_app_with_single_agent_and_memory/intelligence/agentic/agent/agent_instance/insurance_agent.yaml)配置中`memory`部分。
在该案例中我们配置demo_memory作为记忆实例类型我们进一步在demo_memory.yaml(路径agentUniverse/examples/startup_app/demo_startup_app_with_single_agent_and_memory/intelligence/agentic/memory/demo_memory.yaml)中查看该实例的具体配置。
## 测试记忆模块
通过[insurance_agent_test.py](../../../../examples/startup_app/demo_startup_app_with_single_agent_and_memory/intelligence/test/insurance_agent_test.py)测试入口可以看到智能体加入记忆模块后的使用情况。
![](../../_picture/demo_startup_agent_with_memory.png)

View File

@@ -0,0 +1,10 @@
# 文档说明
在本例中我们将进一步向大家介绍如何使用prompt管理模块。
# 使用prompt管理模块
样例地址:[demo_startup_app_with_agent_templates](../../../../examples/startup_app/demo_startup_app_with_agent_templates)
在实际搭建多智能体应用的过程中我们面临大量prompt设置这些prompt将存在于各个yaml中。随着应用的内容增多越来越的prompt将变得难以管理。我们使用prompt管理模块将每一个prompt赋予唯一的prompt_version进行管理与使用。
以demo_startup_app_with_agent_templates工程中的智能体[insurance_consult_pro_agent.yaml](../../../../examples/startup_app/demo_startup_app_with_agent_templates/intelligence/agentic/agent/agent_instance/insurance_consult_pro_agent.yaml)为例,在配置项中我们可以看到 prompt_version 配置为insurance_consult.cn我们可以在 [prompt目录](../../../../examples/startup_app/demo_startup_app_with_agent_templates/intelligence/agentic/prompt)中找到其实际的prompt文件[insurance_multi_agent_cn.yaml](../../../../examples/startup_app/demo_startup_app_with_agent_templates/intelligence/agentic/prompt/insurance_multi_agent_cn.yaml)。
通过这种方式我们可以将大量prompt单独管理并复用起来。

View File

@@ -18,7 +18,9 @@
* 1.7 [沉淀与使用智能体模版](开始使用/5.沉淀与使用智能体模版.md)
* 1.8 [常用使用技巧](开始使用/6.常用使用技巧.md)
* 1.8 进阶使用技巧
* 1.8.1 [进阶技巧:记忆的使用](开始使用/7.进阶技巧:记忆的使用.md)
* 1.8.2 [进阶技巧:prompt管理](开始使用/8.进阶技巧:prompt管理.md)
**2.原理介绍**