Skip to content

Commit

Permalink
Merge branch 'dev_fanen' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
AniviaTn authored Jun 13, 2024
2 parents 4fc1dc5 + 050eb94 commit e2ef121
Show file tree
Hide file tree
Showing 56 changed files with 1,434 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Note - Additional remarks regarding the version.
- Added webserver post_fork functionality
- Provides multi-node process intervention capabilities after starting the webserver in agentUniverse
- Introduced SQLDB_WRAPPER wrapper class, offering typical database connection methods
- Through the SQLDB_WRAPPER wrapper class, you can conveniently connect to various databases and storage technologies including SQLite, MySQL, Oracle, PostgreSQL, and others
- Through the SQLDB_WRAPPER wrapper class, you can conveniently connect to various databases and storage technologies including SQLServer, MySQL, Oracle, PostgreSQL, SQLite and others
- Added connection support for Milvus vector database component

For more usage of the above features, please pay attention to the agentUniverse guidebook.
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Note - 对于版本的额外说明。
- 新增webserver post_fork功能
- 开放agentUniverse中webserver启动后的多节点流程干预功能
- 新增SQLDB_WRAPPER包装类,提供典型数据库连接方式
- 通过SQLDB_WRAPPER包装类您可以非常方便的连接如SQLite、MySQL、Oracle、PostgreSQL、SQLite等几十种数据库与存储技术组件。
- 通过SQLDB_WRAPPER包装类您可以非常方便的连接如SQLServer、MySQL、Oracle、PostgreSQL、SQLite等几十种数据库与存储技术组件。
- 新增milvus向量数据库组件连接

上述功能更多用法请关注agentUniverse指导手册部分。
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# agentUniverse
****************************************
Language version: [English](./README.md) | [中文](./README_zh.md)
Language version: [English](./README.md) | [中文](./README_zh.md) | [日本語](./README_jp.md)

![](https://img.shields.io/badge/framework-agentUniverse-pink)
![](https://img.shields.io/badge/python-3.10%2B-blue?logo=Python)
Expand Down Expand Up @@ -58,4 +58,4 @@ For more detailed information, please refer to the [Guidebook](docs/guidebook/en
* Discord: https://discord.gg/VfhEvJzQ
* WeChat Official Account: agentUniverse智多星
* DingTalk Group:
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
60 changes: 60 additions & 0 deletions README_jp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# agentUniverse
****************************************
言語バージョン: [英語](./README.md) | [中国語](./README_zh.md) | [日本語](./README_jp.md)

![](https://img.shields.io/badge/framework-agentUniverse-pink)
![](https://img.shields.io/badge/python-3.10%2B-blue?logo=Python)
[![](https://img.shields.io/badge/%20license-Apache--2.0-yellow)](LICENSE)
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.8-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)

![](docs/guidebook/_picture/logo_bar.jpg)
****************************************

## 概要
agentUniverseは、大規模言語モデルに基づくマルチエージェントアプリケーションを開発するためのフレームワークです。単一エージェントの構築に必要なすべての基本コンポーネントと、マルチエージェントのコラボレーションメカニズムを提供します。これにより、開発者はマルチエージェントアプリケーションを簡単に構築し、異なる技術およびビジネス分野からのパターンプラクティスを共有することができます。

フレームワークには、実際のビジネスシナリオで効果が証明されたいくつかのプリインストールされたマルチエージェントコラボレーションパターンが含まれており、今後も豊富になる予定です。現在リリース予定のパターンには以下が含まれます:

- PEERパターン:
このパターンは、Plan(計画)、Execute(実行)、Express(表現)、Review(レビュー)の4つの異なるエージェントの役割を利用して、複雑なタスクを多段階に分解し、順次実行します。また、評価フィードバックに基づいて自律的な反復を行い、推論および分析タスクのパフォーマンスを向上させます。

- DOEパターン:
このパターンは、Data-fining(データ精製)、Opinion-inject(意見注入)、Express(表現)の3つのエージェントで構成され、データ集約型および高計算精度のタスクを解決し、事前に収集および構造化された専門家の意見と組み合わせることで、最終結果を生成します。

これからもっと多くのパターンが登場します...

![](docs/guidebook/_picture/agent_universe_framework_resize.jpg)

## agentUniverseサンプルプロジェクト
[agentUniverse サンプルプロジェクト](sample_standard_app/README.md)

## クイックインストール
pipを使用:
```shell
pip install agentUniverse
```

## クイックスタート
以下の内容をご紹介します:
* 環境とアプリケーションプロジェクトの準備
* シンプルなエージェントの構築
* パターンコンポーネントを使用してマルチエージェントのコラボレーションを完了する
* エージェントのパフォーマンスをテストおよび最適化する
* エージェントを迅速に提供する
詳細は、[クイックスタート](docs/guidebook/en/1_3_Quick_Start.md)をご覧ください。

## ガイドブック
詳細情報については、[ガイドブック](docs/guidebook/en/0_index.md)を参照してください。

## APIリファレンス
[readthedocs](https://agentuniverse.readthedocs.io/en/latest/)

## お問い合わせ
* github: https://github.com/alipay/agentUniverse
* gitee: https://gitee.com/agentUniverse/agentUniverse
* gitcode: https://gitcode.com/agentUniverse
* Stack Overflow: https://stackoverflowteams.com/c/agentuniverse/questions
* Discord: https://discord.gg/VfhEvJzQ
* WeChat公式アカウント: agentUniverse智多星
* DingTalkグループ:
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# agentUniverse
****************************************
语言版本: [English](./README.md) | [中文](./README_zh.md)
语言版本: [English](./README.md) | [中文](./README_zh.md) | [日本語](./README_jp.md)

![](https://img.shields.io/badge/framework-agentUniverse-pink)
![](https://img.shields.io/badge/python-3.10%2B-blue?logo=Python)
Expand Down Expand Up @@ -61,4 +61,4 @@ pip install agentUniverse
* Discord: https://discord.gg/VfhEvJzQ
* 微信公众号: agentUniverse智多星
* 钉钉答疑群:
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
Binary file added docs/guidebook/_picture/law_agent_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions docs/guidebook/en/0_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
* 2.2.3 [Tool](2_2_3_Tool.md)
* 2.2.3.1 [Create And Use](2_2_3_Tool_Create_And_Use.md)
* 2.2.3.2 [Related Domain Objects](2_2_3_Tool_Related_Domain_Objects.md)
* 2.2.4 Knowledge
* 2.2.5 Memory
* 2.2.6 Planner
* 2.2.4 [Knowledge](2_2_4_Knowledge.md)
* 2.2.4.1 [Define And Use](2_2_4_Knowledge_Define_And_Use.md)
* 2.2.4.2 [Related Domain Objects](2_2_4_Knowledge_Related_Domain_Objects.md)
* 2.2.5 [Memory](2_2_5_Memory.md)
* 2.2.5.1 [Define And Use](2_2_5_Memory_Define_And_Use.md)
* 2.2.5.2 [Related Domain Objects](2_2_5_Memory_Related_Domain_Objects.md)
* 2.2.6 [Planner](2_2_6_Planner.md)
* 2.2.5.1 [Define And Use](2_2_6_Planner_Define_And_Use.md)
* 2.2.5.2 [Related Domain Objects](2_2_6_Planner_Related_Domain_Objects.md)
* 2.3 Technical Components
* 2.4 Others
* 2.4.1 Service
Expand Down
7 changes: 6 additions & 1 deletion docs/guidebook/en/2_2_3_Tool_Create_And_Use.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def execute(self, tool_input: ToolInput):
#### An actual example of a tool object definition.
```python
from langchain_community.utilities.google_serper import GoogleSerperAPIWrapper
from antfinagentframework.agent.action.tool.tool import Tool, ToolInput
from agentuniverse.agent.action.tool.tool import Tool, ToolInput
class GoogleSearchTool(Tool):
"""The demo google search tool.
Expand Down Expand Up @@ -85,6 +85,11 @@ tool = ['sample_standard_app.app.core.tool']
```

# How to Use the Tool Component
## Configure for use in an Agent
You can set up any tool you have created in the tool of your agent according to the contents of [Agent Creation and Usage section](2_2_1_Agent_Create_And_Use.md).

Refer to the example: `demo_rag_agent`, with the specific file path being `sample_standard_app/app/core/agent/rag_agent_case/demo_rag_agent.yaml`.

## Using the Tool Manager
You can obtain the instance of the tool with the corresponding name through the `.get_instance_obj(xx_tool_name)` method in the Tool manager, and call it using the `run` method.

Expand Down
11 changes: 11 additions & 0 deletions docs/guidebook/en/2_2_4_Knowledge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Knowledge
Data, information, and knowledge are terms that are often confused when mentioned together. Simply put, these three words have a progressively deeper relationship, with knowledge being the most abstract and requiring a high degree of stability and reliability in its content.

We all know that both traditional machine learning models and large language models require a vast amount of data during the training process, and we always hope that this data is of high quality and reliability. Although many existing large language models already include an impressive collection of data and instructions, similar to how no human can become omniscient and omnipotent, these models often have "knowledge" blind spots.

By loading additional knowledge content, agents can learn and master parts of the knowledge that their original LLMs are not proficient in. Just like humans learn knowledge, agents can make themselves more knowledgeable through this method.

agentUniverse defines a standard knowledge format, which includes various knowledge data loading methods, and connections to diverse knowledge storage systems. You can define any form of knowledge data into standard knowledge components for agents and other components to use.

# Conclusion
By now, you should have a basic understanding of the design principles behind knowledge components. In the next section, we will introduce you to the standard definitions of knowledge components, how to customize and create your own knowledge, and how to utilize knowledge.
177 changes: 177 additions & 0 deletions docs/guidebook/en/2_2_4_Knowledge_Define_And_Use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# How to Define the Knowledge Component
Based on the design features of agentUniverse domain components, creating a knowledge definition involves two parts:

* knowledge_xx.yaml
* knowledge_xx.py

The `knowledge_xx.yaml` file contains important information about the knowledge component such as its name, description, loading method, storage method, etc., while the `knowledge_xx.py` file contains the specific definitions of the knowledge. Understanding this principle, let's delve into how to create these two parts.

## Creating the Knowledge Configuration - knowledge_xx.yaml
We will detail the various components in the configuration.

### Setting Basic Attributes of Knowledge
* `name`: The name of the knowledge, which you can set to any name you prefer.
* `description`: A description of the knowledge, filled according to your actual needs.
* `store`: The storage medium for the knowledge (e.g., ChromaStore, RedisStore, FaissStore, etc.)
* `reader`: Represents the method of reading the knowledge (e.g., FileReader, UrlReader, etc.)
* `ext_info`: Extended parameters

### Setting Knowledge Component Metadata
**`metadata` - Component Metadata**
* `type` : Component type, 'KNOWLEDGE'
* `module`: The package path of the knowledge entity
* `class`: The class name of the knowledge entity

### A Sample Knowledge Configuration
```yaml
name: 'demo_knowledge'
description: 'demo knowledge'
metadata:
type: 'KNOWLEDGE'
module: 'sample_standard_app.app.core.knowledge.demo_knowledge'
class: 'DemoKnowledge'
```
The above is an actual sample of a Knowledge configuration.
Besides, the standard configuration items introduced above, you can find more knowledge configuration YAML samples in our sample project under the path `sample_standard_app.app.core.knowledge`.

Additionally, agentUniverse does not restrict users from extending the knowledge YAML configuration content. You can create any custom configuration keys according to your requirements, but please be mindful not to use the same names as the default configuration keywords mentioned above.

## Creating the Knowledge Domain Behavior Definition - knowledge_xx.py

### Creating a Knowledge Class Object
Create the corresponding Knowledge class object and inherit the base class Knowledge from the agentUniverse framework.

### Setting Up the Reader Module
The Reader module is responsible for reading the knowledge, and this part is optional. agentUniverse currently has built-in Readers for the following data formats:

* DocxReader
* PdfReader
* PptxReader
* WebPdfReader
* FileReader

Their paths are located under `agentuniverse.agent.action.knowledge.reader.file`. The Reader module supports customization, and you can write your own Reader's loading methods.

### Setting Up the Store Module
The Store module is responsible for the persistence interaction of the knowledge, performing operations like insertion, reading, deletion, and updating of the knowledge. This part is optional as well. agentUniverse currently has built-in Stores for the following data formats:

* ChromaStore
* MilvusStore

Their paths are located under `agentuniverse.agent.action.knowledge.store`. The Store module supports customization, and you can write your own Store's loading methods.

### Defining the query_knowledge Method
This method is responsible for querying the corresponding knowledge. Its default implementation uses the Store function queries, but users can override it based on their actual needs.

```python
def query_knowledge(self, **kwargs) -> List[Document]:
"""Query the knowledge.
Query documents from the store and return the results.
"""
query = Query(**kwargs)
return self.store.query(query)
```

### Defining the insert_knowledge Method
This method is responsible for adding new pieces of knowledge, with its default implementation utilizing the insertion operation of the Store function. Users have the flexibility to override this behavior based on their specific requirements.

```python
def insert_knowledge(self, **kwargs) -> None:
"""Insert the knowledge.
Load data by the reader and insert the documents into the store.
"""
document_list: List[Document] = self.reader.load_data()
self.store.insert_documents(document_list, **kwargs)
```

#### A Sample Knowledge Object Definition
```python
from agentuniverse.agent.action.knowledge.embedding.openai_embedding import OpenAIEmbedding
from agentuniverse.agent.action.knowledge.knowledge import Knowledge
from agentuniverse.agent.action.knowledge.reader.file.web_pdf_reader import WebPdfReader
from agentuniverse.agent.action.knowledge.store.chroma_store import ChromaStore
from agentuniverse.agent.action.knowledge.store.document import Document
from langchain.text_splitter import TokenTextSplitter
SPLITTER = TokenTextSplitter(chunk_size=800, chunk_overlap=100)
class DemoKnowledge(Knowledge):
"""The demo knowledge."""
def __init__(self, **kwargs):
"""The __init__ method.
Some parameters, such as name and description,
are injected into this class by the demo_knowledge.yaml configuration.
Args:
name (str): Name of the knowledge.
description (str): Description of the knowledge.
store (Store): Store of the knowledge, store class is used to store knowledge
and provide retrieval capabilities, such as ChromaDB store or Redis Store,
demo knowledge uses ChromaDB as the knowledge storage.
reader (Reader): Reader is used to load data,
the demo knowledge uses WebPdfReader to load pdf files from web.
"""
super().__init__(**kwargs)
self.store = ChromaStore(collection_name="chroma_store", embedding_model=OpenAIEmbedding(
embedding_model_name='text-embedding-3-small'), dimensions=1056)
self.reader = WebPdfReader()
# initialize the knowledge
# self.insert_knowledge()
def insert_knowledge(self, **kwargs) -> None:
"""Insert the knowledge into the knowledge store.
Step1: Load data from the web using WebPdfReader.
Step2: Split the data into chunks using TokenTextSplitter().
Step3: Insert the data into the ChromaStore.
Note:
To avoid that the token in the embedding process exceeds the limit, the document needs to be split.
"""
doc_list = self.reader.load_data('https://www.sfu.ca/~poitras/BUFFET.pdf')
lc_doc_list = SPLITTER.split_documents(Document.as_langchain_list(doc_list))
self.store.insert_documents(Document.from_langchain_list(lc_doc_list))
```

## Take Note of the Path Where Your Knowledge Is Located
With the above Knowledge configuration and definition steps, you have mastered all the steps for creating knowledge. Next, we will use this knowledge. Before use, please ensure that the created Knowledge is in the correct package scan path.

In the config.toml file of the agentUniverse project, you need to configure the package corresponding to the Knowledge configuration. Please reconfirm whether the package path of the created file is under the `CORE_PACKAGE`'s `knowledge` path or its subpaths.

For example, in the configuration of the sample project, it is as follows:
```yaml
[CORE_PACKAGE]
# Scan and register knowledge components for all paths under this list, with priority over the default.
knowledge = ['sample_standard_app.app.core.knowledge']
```

# How to Use the Knowledge Component
## Configuring Use in the Agent
Based on the content in [Creating and Using Agents](2_2_1_Agent_Create_And_Use.md), you can set any created knowledge under the knowledge action in the agent.

## Using the Knowledge Manager
You can obtain the Knowledge instance corresponding to the name via the `.get_instance_obj(xx_knowledge_name)` method in the Knowledge Manager, and call it using the `query_knowledge` method.

```python
from agentuniverse.agent.action.knowledge.knowledge_manager import KnowledgeManage
knowledge = KnowledgeManager().get_instance_obj(knowledge_name)
knowledge.query_knowledge(**query_input)
```

# Learn More About Existing Knowledge
For more knowledge examples provided by the framework, you can check the `sample_standard_app.app.core.knowledge` package path.

# Conclusion
Now you have mastered the definition and use of the Knowledge component. Go ahead and try creating and using your knowledge.
17 changes: 17 additions & 0 deletions docs/guidebook/en/2_2_4_Knowledge_Related_Domain_Objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Knowledge and Related Domain Objects
In this chapter, we will focus on listing the Knowledge and related core domain objects. We have omitted their corresponding code parts. If you would like to learn more, please refer to the [API Reference Section](4_1_API_Reference.md).

## Knowledge Base Class
Package Path:`agentuniverse.agent.action.knowledge.knowledge.Knowledge`

## Knowledge Manager
Package Path:`agentuniverse.agent.action.knowledge.knowledge_manager.KnowledgeManager`

## Embedding Object Base Class
Package Path:`agentuniverse.agent.action.knowledge.embedding.embedding.Embedding`

## Reader Object Base Class
Package Path:`agentuniverse.agent.action.knowledge.reader.reader.Reader`

## Store Object Base Class
Package Path:`agentuniverse.agent.action.knowledge.store.store.Store`
Loading

0 comments on commit e2ef121

Please sign in to comment.