chore: fix typos

This commit is contained in:
ooooo
2025-07-20 17:08:45 +08:00
parent e1edeeaecd
commit 2130b47a89
79 changed files with 66 additions and 66 deletions

View File

@@ -4,7 +4,7 @@
# @Time : 2024/8/28 16:54
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: hierarchical_text_spliter.py
# @FileName: hierarchical_text_splitter.py
import re
import uuid
from typing import List, Optional

View File

@@ -4,7 +4,7 @@
# @Time : 2024/8/30 15:13
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: chroma_hierarchichal_store.py
# @FileName: chroma_hierarchical_store.py
from typing import List, Any, Optional
from chromadb.api.models.Collection import Collection

View File

@@ -11,7 +11,7 @@
# @Time : 2025/5/22 16:10
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: sofa_tracer_propogator.py
# @FileName: sofa_tracer_propagator.py
import typing
from opentelemetry import trace

View File

@@ -14,17 +14,17 @@ During the translation process, the priority is to ascertain whether the model's
Implementing this translation in agentUniverse involves the following steps:
1. Define prompts related to translation, with three for short text and three for long text. Relevant files include:
- [Short Text Init Prompt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/translation_init_en.yaml)
- [Short Text Reflection Prompt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/translation_reflection_en.yaml)
- [Short Text Improve Prompt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/translation_improve_en.yaml)
- [Long Text Init Prompt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/multi_translation_init_en.yaml)
- [Long Text Reflection Prompt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
- [Long Text Improve Prompt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
- [Short Text Init Prompt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/translation_init_en.yaml)
- [Short Text Reflection Prompt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/translation_reflection_en.yaml)
- [Short Text Improve Prompt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/translation_improve_en.yaml)
- [Long Text Init Prompt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/multi_translation_init_en.yaml)
- [Long Text Reflection Prompt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
- [Long Text Improve Prompt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
2. Define three agents
- [Short Text Translation Work Agent](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_work_agent.yaml)
- [Short Text Translation Reflection Agent](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_reflection_agent.yaml)
- [Short Text Translation Improvement Agent](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_improve_agent.yaml)
These agents switch their prompts based on whether the task involves translating long or short texts. The specific logic for this switching mechanism is detailed in the [agent file](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.py).
- [Short Text Translation Work Agent](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_work_agent.yaml)
- [Short Text Translation Reflection Agent](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_reflection_agent.yaml)
- [Short Text Translation Improvement Agent](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_improve_agent.yaml)
These agents switch their prompts based on whether the task involves translating long or short texts. The specific logic for this switching mechanism is detailed in the [agent file](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.py).
3. Define the collaborative work process of the three agents
The collaborative process is illustrated in the earlier-mentioned flowchart of multi-agent collaboration.
@@ -32,17 +32,17 @@ The collaborative process is illustrated in the earlier-mentioned flowchart of m
![](../../_picture/translation_execute_flow.png)
For a deeper dive into the processes, refer to the [detailed code file](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_by_token_agent.py).
The [configuration file](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.yaml) for the collaborative agents.
For a deeper dive into the processes, refer to the [detailed code file](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_by_token_agent.py).
The [configuration file](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.yaml) for the collaborative agents.
### Demonstration Code
[Code Link](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/test_translation_agent.py)
[Code Link](../../../../examples/sample_apps/translation_agent_app/intelligence/test/test_translation_agent.py)
[Long Text](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/long_text.txt)
[Short Text](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/short_text.txt)
[Long Text](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/long_text.txt)
[Short Text](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/short_text.txt)
[Translation Of Long Text](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/short_text_result.txt)
[Translation Of Short Text](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/long_text_result.txt)
[Translation Of Long Text](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/short_text_result.txt)
[Translation Of Short Text](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/long_text_result.txt)
### Demonstration Results
We can see that using agentUniverse maintains consistency with the results of the original translation_agent project, which hasa been successfully replicated.

View File

@@ -99,7 +99,7 @@ agentUniverse implements the `@trace_llm` decorator. When an agent calls the cor
#### Demo Effect
When calling the `demo_rag_agent` iin the sample project of agentUniverse, using the gpt-4omodel with a query to analyze the reasons behind Warren Buffett's reduction of his stake in BYD, the model invocation tracking function captures the following data:
When calling the `demo_rag_agent` in the sample project of agentUniverse, using the gpt-4omodel with a query to analyze the reasons behind Warren Buffett's reduction of his stake in BYD, the model invocation tracking function captures the following data:
```json
{

View File

@@ -171,11 +171,11 @@ metadata:
```
This component requires configuring DASHSCOPE_API_KEY in the environment variables.
### [HierarchicalRegexTextSplitter](../../../../../../agentuniverse/agent/action/knowledge/doc_processor/hierarchical_regex_text_spliter.py)
### [HierarchicalRegexTextSplitter](../../../../../../agentuniverse/agent/action/knowledge/doc_processor/hierarchical_regex_text_splitter.py)
This component splits the original text into multiple hierarchical levels using specified regex rules, forming a tree-like document structure. Users need to create a custom definition file, with an example as follows:
```yaml
name: 'hierarchical_regex_text_spliter'
name: 'hierarchical_regex_text_splitter'
description: 'extract keywords from query'
merge_first: True
hierarchical_index:
@@ -189,7 +189,7 @@ llm:
model_name: qwen-plus
metadata:
type: 'DOC_PROCESSOR'
module: 'agentuniverse.agent.action.knowledge.doc_processor.hierarchical_regex_text_spliter'
module: 'agentuniverse.agent.action.knowledge.doc_processor.hierarchical_regex_text_splitter'
class: 'HierarchicalRegexTextSplitter'
```
- merge_first: If set to True, it merges the input List[Document] into a single document before splitting.

View File

@@ -171,12 +171,12 @@ metadata:
```
该组件需要在环境变量中配置`DASHSCOPE_API_KEY`
### [HierarchicalRegexTextSplitter](../../../../../../agentuniverse/agent/action/knowledge/doc_processor/hierarchical_regex_text_spliter.py)
### [HierarchicalRegexTextSplitter](../../../../../../agentuniverse/agent/action/knowledge/doc_processor/hierarchical_regex_text_splitter.py)
该组件使用通过指定的正则规则对原始文本进行多层级的拆分,形成树状的文档结构。
该组件需要用户自行创建定义文件,一个示例定义文件如下:
```yaml
name: 'hierarchical_regex_text_spliter'
name: 'hierarchical_regex_text_splitter'
description: 'extract keywords from query'
merge_first: True
hierarchical_index:
@@ -190,7 +190,7 @@ llm:
model_name: qwen-plus
metadata:
type: 'DOC_PROCESSOR'
module: 'agentuniverse.agent.action.knowledge.doc_processor.hierarchical_regex_text_spliter'
module: 'agentuniverse.agent.action.knowledge.doc_processor.hierarchical_regex_text_splitter'
class: 'HierarchicalRegexTextSplitter'
```
- merge_first: 设置为True的话会将输入的List[Document]合并为一份文档后再进行拆分

View File

@@ -30,7 +30,7 @@ agentUniverse中提供了三种Instrument分别基于LLM、Tool以及Agent维
#### 功能特点
- 在 Span 开始时自动添加Sessison ID 属性,属性名为`au.trace.session.id`
- 在 Span 开始时自动添加 Session ID 属性,属性名为`au.trace.session.id`
- 如果没有会话 ID则设置为 `-1`
### 4. AUSessionPropagator

View File

@@ -2,7 +2,7 @@
## 案例说明
本案例基于ReactAgentTemplate搭建了一个简单可以自动生成python代码并执行的案例。
该案例基于千问大模型和`goolge_search`功能,使用前需要您在环境变量中配置`DASHSCOPE_API_KEY``SERPER_API_KEY`
该案例基于千问大模型和`google_search`功能,使用前需要您在环境变量中配置`DASHSCOPE_API_KEY``SERPER_API_KEY`
## 快速开始
### 配置API密钥

View File

@@ -13,37 +13,37 @@
## 在aU中的实现
在aU中实现该翻译的过程主要分为以下几步
1. 定义翻译相关的prompt短文本翻译三个长文本翻译三个相关文件如下:
[短文本翻译init prmpt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/translation_init_en.yaml)
[短文本翻译reflection prmpt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/translation_reflection_en.yaml)
[短文本翻译improve prmpt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/translation_improve_en.yaml)
[长文本翻译init prmpt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/multi_translation_init_en.yaml)
[长文本翻译reflection prmpt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
[长文本翻译improve prmpt](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
[短文本翻译init prmpt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/translation_init_en.yaml)
[短文本翻译reflection prmpt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/translation_reflection_en.yaml)
[短文本翻译improve prmpt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/translation_improve_en.yaml)
[长文本翻译init prmpt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/multi_translation_init_en.yaml)
[长文本翻译reflection prmpt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
[长文本翻译improve prmpt](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/prompt/translation/multi_translation_improve_en.yaml)
在aU中,可以很容易的通过配置文件定义prompt并统一由PromptManager管理。
2. 定义三个智能体
[短文本翻译智能体](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_work_agent.yaml)
[短文本翻译智能体](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_reflection_agent.yaml)
[短文本翻译智能体](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_improve_agent.yaml)
该智能体当中需要根据执行的时长文本翻译还是短文本翻译切换对应的prompt具体逻辑可参考[代码实现](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.py)
[短文本翻译智能体](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_work_agent.yaml)
[短文本翻译智能体](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_reflection_agent.yaml)
[短文本翻译智能体](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_improve_agent.yaml)
该智能体当中需要根据执行的时长文本翻译还是短文本翻译切换对应的prompt具体逻辑可参考[代码实现](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.py)
由于定义的prompt全部由PromptManager进行管理这里可以很容易的实现prompt的切换
3. 定义三个智能体的协同工作过程
协同过程可参考前面介绍的多智能体协同工作过程的流程图,具体的实现逻辑如图:
![协同工作](../../_picture/translation_execute_flow.png)
更细的流程可以参考[代码文件](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_by_token_agent.py)
协同智能体的[配置文件](../../../../examples/sample_apps/traslation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.yaml)
更细的流程可以参考[代码文件](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_by_token_agent.py)
协同智能体的[配置文件](../../../../examples/sample_apps/translation_agent_app/intelligence/agentic/agent/agent_instance/translation_agent_case/translation_agent.yaml)
### 演示代码
[代码链接](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/test_translation_agent.py)
[代码链接](../../../../examples/sample_apps/translation_agent_app/intelligence/test/test_translation_agent.py)
[长翻译文本](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/long_text.txt)
[短翻译文本](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/short_text.txt)
[长翻译文本](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/long_text.txt)
[短翻译文本](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/short_text.txt)
[短翻译结果](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/short_text_result.txt)
[长翻译结果](../../../../examples/sample_apps/traslation_agent_app/intelligence/test/translation_data/long_text_result.txt)
[短翻译结果](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/short_text_result.txt)
[长翻译结果](../../../../examples/sample_apps/translation_agent_app/intelligence/test/translation_data/long_text_result.txt)
### 演示结果
可以看到使用aU与原本的translation_agent原工程翻译结果保持一致复刻成功。

View File

@@ -4,7 +4,7 @@
# @Time : 2024/7/24 15:35
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: product_boostrap.py
# @FileName: product_application.py
from agentuniverse.base.agentuniverse import AgentUniverse
from agentuniverse_product.agentuniverse_product import AgentUniverseProduct

View File

@@ -4,35 +4,35 @@ appname = 'demo_app'
[CORE_PACKAGE]
# Perform a full component scan and registration for all the paths under this list.
default = ['traslation_agent_app.intelligence.agentic']
default = ['translation_agent_app.intelligence.agentic']
# Scan and register agent components for all paths under this list, with priority over the default.
agent = ['traslation_agent_app.intelligence.agentic.agent']
agent = ['translation_agent_app.intelligence.agentic.agent']
# Scan and register knowledge components for all paths under this list, with priority over the default.
knowledge = ['traslation_agent_app.intelligence.agentic.knowledge']
knowledge = ['translation_agent_app.intelligence.agentic.knowledge']
# Scan and register llm components for all paths under this list, with priority over the default.
llm = ['traslation_agent_app.intelligence.agentic.llm']
llm = ['translation_agent_app.intelligence.agentic.llm']
# Scan and register planner components for all paths under this list, with priority over the default.
planner = []
# Scan and register tool components for all paths under this list, with priority over the default.
tool = ['traslation_agent_app.intelligence.agentic.tool']
tool = ['translation_agent_app.intelligence.agentic.tool']
# Scan and register memory components for all paths under this list, with priority over the default.
memory = ['traslation_agent_app.intelligence.agentic.memory']
memory = ['translation_agent_app.intelligence.agentic.memory']
# Scan and register service components for all paths under this list, with priority over the default.
service = ['traslation_agent_app.intelligence.service.agent_service']
service = ['translation_agent_app.intelligence.service.agent_service']
# Scan and register prompt components for all paths under this list, with priority over the default.
prompt = ['traslation_agent_app.intelligence.agentic.prompt']
prompt = ['translation_agent_app.intelligence.agentic.prompt']
# Scan and register store components for all paths under this list, with priority over the default.
store = ['traslation_agent_app.intelligence.agentic.knowledge.store']
store = ['translation_agent_app.intelligence.agentic.knowledge.store']
# Scan and register rag_router components for all paths under this list, with priority over the default.
rag_router = ['traslation_agent_app.intelligence.agentic.knowledge.rag_router']
rag_router = ['translation_agent_app.intelligence.agentic.knowledge.rag_router']
# Scan and register doc_processor components for all paths under this list, with priority over the default.
doc_processor = ['traslation_agent_app.intelligence.agentic.knowledge.doc_processor']
doc_processor = ['translation_agent_app.intelligence.agentic.knowledge.doc_processor']
# Scan and register query_paraphraser components for all paths under this list, with priority over the default.
query_paraphraser = ['traslation_agent_app.intelligence.agentic.knowledge.query_paraphraser']
query_paraphraser = ['translation_agent_app.intelligence.agentic.knowledge.query_paraphraser']
# Scan and register memory_compressor components for all paths under this list, with priority over the default.
memory_compressor = ['traslation_agent_app.intelligence.agentic.memory.memory_compressor']
memory_compressor = ['translation_agent_app.intelligence.agentic.memory.memory_compressor']
# Scan and register memory_storage components for all paths under this list, with priority over the default.
memory_storage = ['traslation_agent_app.intelligence.agentic.memory.memory_storage']
memory_storage = ['translation_agent_app.intelligence.agentic.memory.memory_storage']
[SUB_CONFIG_PATH]
# Log config file path, an absolute path or a relative path based on the dir where the current config file is located.

View File

@@ -15,5 +15,5 @@ memory:
name: ''
metadata:
type: 'AGENT'
module: 'traslation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_by_token_agent'
module: 'translation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_by_token_agent'
class: 'TranslationAgent'

View File

@@ -14,5 +14,5 @@ memory:
name: ''
metadata:
type: 'AGENT'
module: 'traslation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_agent'
module: 'translation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_agent'
class: 'TranslationAgent'

View File

@@ -14,5 +14,5 @@ memory:
name: ''
metadata:
type: 'AGENT'
module: 'traslation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_agent'
module: 'translation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_agent'
class: 'TranslationAgent'

View File

@@ -14,5 +14,5 @@ memory:
name: ''
metadata:
type: 'AGENT'
module: 'traslation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_agent'
module: 'translation_agent_app.intelligence.agentic.agent.agent_instance.translation_agent_case.translation_agent'
class: 'TranslationAgent'

View File

@@ -8,5 +8,5 @@ tool_type: 'api'
input_keys: ['input']
metadata:
type: 'TOOL'
module: 'traslation_agent_app.intelligence.agentic.tool.google_search_tool'
module: 'translation_agent_app.intelligence.agentic.tool.google_search_tool'
class: 'GoogleSearchTool'