Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update latest code #15

Merged
merged 66 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
513c243
docs: modify url in README
LandJerry Apr 26, 2024
31e9980
Merge pull request #3 from alipay/dev_fanen
LandJerry Apr 26, 2024
3f649e2
fix: Fix YAML encoding issues when reading files on Windows systems.
LandJerry Apr 26, 2024
bca4e2a
test: modify test_rag_agent
LandJerry Apr 26, 2024
4d7eb8a
feat: release version 0.0.4
LandJerry Apr 26, 2024
8b595ba
docs: update readme
LandJerry Apr 26, 2024
cc97571
Fix: peer planner log format & prompt split texts issues
EdwinInAu Apr 29, 2024
363d94d
Merge pull request #4 from alipay/dev
LandJerry Apr 29, 2024
ad5a4fc
Fix: the planner concurrecy model assignment issue
EdwinInAu Apr 29, 2024
167c938
docs: add contact docs
LandJerry Apr 29, 2024
89f5639
Merge pull request #6 from alipay/dev_xishang
LandJerry Apr 29, 2024
ff61b1f
Feat: Add default peer agent to the agentUniverse.
EdwinInAu Apr 30, 2024
ba7476d
Improvement: modify the default system package path for agentUniverse…
EdwinInAu Apr 30, 2024
662ae7c
Merge pull request #7 from alipay/dev
LandJerry Apr 30, 2024
fe645b3
Feat: add openai model context length.
EdwinInAu Apr 30, 2024
735843a
Feat: added the peer agents and rag agent test examples
EdwinInAu Apr 30, 2024
b082356
Feat: added the demo rag agent and peer agents to the au example package
EdwinInAu Apr 30, 2024
c264158
Feat: added google search and mock search toolsets to the au example …
EdwinInAu Apr 30, 2024
b031b03
Improvement: delete system rag agent test method in au
EdwinInAu Apr 30, 2024
8b2f33c
Merge pull request #8 from alipay/dev_chongshi
LandJerry Apr 30, 2024
1fd0894
Improvement: modify the the initialization method of the openai embed…
EdwinInAu Apr 30, 2024
e7266f6
Improvement: modify the the initialization method of the openai llm.
EdwinInAu Apr 30, 2024
c7473e7
Merge pull request #9 from alipay/dev_chongshi
LandJerry Apr 30, 2024
7037d08
feat: Initial docs & sample-standard-app
LandJerry Apr 24, 2024
68e2e0e
docs: update doc github url
LandJerry Apr 24, 2024
3e42c7d
Add files via upload
keithkiden Apr 24, 2024
f6fa329
Add files via upload
keithkiden Apr 24, 2024
175430a
Delete docs/guidebook/_picture/agent_universe_ framework.jpg
keithkiden Apr 24, 2024
c5112c9
Rename agent_universe_ framework_resize.jpg to agent_universe_framewo…
keithkiden Apr 24, 2024
8870aeb
Update README_zh.md
keithkiden Apr 24, 2024
9c52728
Update README.md
keithkiden Apr 24, 2024
cc0bd0a
Add agent action module(knowledge and tool) to agentUniverse
EdwinInAu Apr 24, 2024
d87d1ea
Add agent memory module to agentUniverse
EdwinInAu Apr 24, 2024
35a6d2a
Add agent llm module to agentUniverse
EdwinInAu Apr 24, 2024
bbca752
Add agent memory module to agentUniverse
EdwinInAu Apr 24, 2024
1ee83f5
Init extension aliyun sls log, service component and web base module.
AniviaTn Apr 24, 2024
d0f058d
Add webserver
weizjajj Apr 24, 2024
313e4d6
fix: fix version number in pyproject.toml
LandJerry Apr 24, 2024
abd552d
feat: add new feature - prompt manager
LandJerry Apr 26, 2024
1fde53b
docs: modify url in README
LandJerry Apr 26, 2024
1c9af39
Fix: Start a flask server on Windows instead of gunicorn server. Fix …
AniviaTn Apr 26, 2024
9fe99fd
Fix: Start a flask server on Windows instead of gunicorn server. Fix …
AniviaTn Apr 26, 2024
f1ff88b
fix: Fix YAML encoding issues when reading files on Windows systems.
LandJerry Apr 26, 2024
0a0f9ab
test: modify test_rag_agent
LandJerry Apr 26, 2024
88f6adf
feat: release version 0.0.4
LandJerry Apr 26, 2024
bb44df3
Fix: peer planner log format & prompt split texts issues
EdwinInAu Apr 29, 2024
cccb2c4
Fix: the planner concurrecy model assignment issue
EdwinInAu Apr 29, 2024
02b985f
docs: add contact docs
LandJerry Apr 29, 2024
1d7deb3
Feat: Add default peer agent to the agentUniverse.
EdwinInAu Apr 30, 2024
3073355
Improvement: modify the default system package path for agentUniverse…
EdwinInAu Apr 30, 2024
954f4b9
Feat: add openai model context length.
EdwinInAu Apr 30, 2024
ed994f1
Feat: added the peer agents and rag agent test examples
EdwinInAu Apr 30, 2024
bc9e617
Feat: added the demo rag agent and peer agents to the au example package
EdwinInAu Apr 30, 2024
5a9c232
Feat: added google search and mock search toolsets to the au example …
EdwinInAu Apr 30, 2024
11689b1
Improvement: delete system rag agent test method in au
EdwinInAu Apr 30, 2024
2e2da80
Improvement: modify the the initialization method of the openai embed…
EdwinInAu Apr 30, 2024
fa66a99
Improvement: modify the the initialization method of the openai llm.
EdwinInAu Apr 30, 2024
f3db89c
1. The knowledge base store adds update and upsert methods.
goodgood-good Apr 30, 2024
e49716b
Merge remote-tracking branch 'origin/dev' into dev_heji
goodgood-good Apr 30, 2024
0faecb8
Merge pull request #10 from alipay/dev_heji
LandJerry May 1, 2024
43a94de
docs: add API Reference docs
LandJerry May 6, 2024
433faf7
Merge pull request #12 from alipay/dev
LandJerry May 6, 2024
af83fff
docs: add Application Engineering Structure Explanation
LandJerry May 7, 2024
1127d13
Merge pull request #13 from alipay/dev_xishang
LandJerry May 7, 2024
1c5e369
docs: fix guidebook index.md
LandJerry May 7, 2024
57802d2
Merge branch 'dev_xishang'
LandJerry May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ Security - Patches and security improvements.
***************************************************

# Version Update History
## [0.0.4] - 2024-04-26
### Added
- Add version management capability to the prompt.

### Fixed
- Fixed compatibility issues on Windows
* Due to compatibility issues of Gunicorn with Windows systems, automatically identify the kernel version to select the web startup method.
* Specified YAML reading as UTF-8 encoding method.

## [0.0.3] - 2024-04-19
### Init
- The official release version of AgentUniverse has been initialized. Enjoy using it!
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ Security - 补丁与安全改进。
***************************************************

# 版本更新记录
## [0.0.4] - 2024-04-26
### Added
- 新增prompt版本管理能力

### Fixed
- Windows版本下的兼容问题修复
* 由于Gunicore对于windows系统的兼容问题,自动识别内核版本自动选择web启动方式
* yaml读取指定为utf-8 encode方式

## [0.0.3] - 2024-04-19
### Init
- agentUniverse正式外发版本初始化,祝您使用愉快!
Expand Down
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Language version: [English](./README.md) | [中文](./README_zh.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.3-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.4-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)

![](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/_picture/logo_bar.png)
![](docs/guidebook/_picture/logo_bar.jpg)
****************************************

## Overview
Expand All @@ -24,10 +24,10 @@ This pattern consists of three agents: Data-fining agent, which is designed to s

More patterns are coming soon...

![](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/_picture/agent_universe_framework_resize.jpg)
![](docs/guidebook/_picture/agent_universe_framework_resize.jpg)

## agentUniverseSample Project
[agentUniverse Sample Project](https://github.com/alipay/agentUniverse/blob/master/sample_standard_app/README.md)
[agentUniverse Sample Project](sample_standard_app/README.md)

## Quick Installation
Using pip:
Expand All @@ -42,7 +42,20 @@ We will show you how to:
* Use pattern components to complete multi-agent collaboration
* Test and optimize the performance of the agent
* Quickly serve the agent
For details, please read [Quick Start](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/en/1_3_Quick_Start.md).
For details, please read [Quick Start](docs/guidebook/en/1_3_Quick_Start.md).

## Guidebook
For more detailed information, please refer to the [Guidebook](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/en/0_index.md).
For more detailed information, please refer to the [Guidebook](docs/guidebook/en/0_index.md).

## API Reference
[readthedocs](https://agentuniverse.readthedocs.io/en/latest/)

## More Ways to Contact Us
* 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 Official Account: agentUniverse智多星
* DingTalk Group:
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
25 changes: 19 additions & 6 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
![](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.3-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.4-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)

![](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/_picture/logo_bar.png)
![](docs/guidebook/_picture/logo_bar.jpg)
****************************************

## 项目介绍
Expand All @@ -25,11 +25,11 @@

更多模式组件持续推出中...

![](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/_picture/agent_universe_framework_resize.jpg)
![](docs/guidebook/_picture/agent_universe_framework_resize.jpg)


## agentUniverse 示例项目
[agentUniverse 示例项目](https://github.com/alipay/agentUniverse/tree/master/sample_standard_app)
[agentUniverse 示例项目](sample_standard_app/README_zh.md)

## 快速安装
使用pip:
Expand All @@ -45,7 +45,20 @@ pip install agentUniverse
* 对agent执行效果进行测试调优
* 对agent进行快速服务化

详情请阅读[快速开始](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/zh/1_3_%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B.md) 。
详情请阅读[快速开始](docs/guidebook/zh/1_3_%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B.md) 。

## 用户指南
更多详细信息,请参阅[指南](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/zh/0_%E7%9B%AE%E5%BD%95.md) 。
更多详细信息,请参阅[指南](docs/guidebook/zh/0_%E7%9B%AE%E5%BD%95.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
* 微信公众号: agentUniverse智多星
* 钉钉答疑群:
![](./docs/guidebook/_picture/dingtalk_util20250429.png)
12 changes: 2 additions & 10 deletions agentuniverse/agent/action/knowledge/embedding/openai_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ class OpenAIEmbedding(Embedding):
async_client: Any = None
dimensions: Optional[int] = None

def __init__(self, **kwargs):
"""Initialize the openai embedding class."""
super().__init__(**kwargs)
if self.client is None:
self.client = OpenAI(api_key=self.openai_api_key, **self.openai_client_args or {})
if self.async_client is None:
self.async_client = AsyncOpenAI(api_key=self.openai_api_key, **self.openai_client_args or {})

def get_embeddings(self, texts: List[str]) -> List[List[float]]:
"""Get the OpenAI embeddings.

Expand All @@ -48,7 +40,7 @@ def get_embeddings(self, texts: List[str]) -> List[List[float]]:
Raises:
ValueError: If texts exceed the embedding model token limit or missing some required parameters.
"""

self.client = OpenAI(api_key=self.openai_api_key, **self.openai_client_args or {})
if self.embedding_model_name is None:
raise ValueError("Must provide `embedding_model_name`")
try:
Expand Down Expand Up @@ -81,7 +73,7 @@ async def async_get_embeddings(self, texts: List[str]) -> List[List[float]]:
Raises:
ValueError: If texts exceed the embedding model token limit or missing some required parameters.
"""

self.async_client = AsyncOpenAI(api_key=self.openai_api_key, **self.openai_client_args or {})
if self.embedding_model_name is None:
raise ValueError("Must provide `embedding_model_name`")
try:
Expand Down
26 changes: 26 additions & 0 deletions agentuniverse/agent/action/knowledge/store/chroma_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,32 @@ def insert_documents(self, documents: List[Document], **kwargs: Any):
ids=[document.id]
)

def upsert_document(self, documents: List[Document], **kwargs):
"""Upsert document into the store."""
for document in documents:
embedding = document.embedding
if self.embedding_model is not None and len(embedding) == 0:
embedding = self.embedding_model.get_embeddings([document.text])[0]
self.collection.upsert(
documents=[document.text],
metadatas=[document.metadata],
embeddings=[embedding] if embedding is not None else None,
ids=[document.id]
)

def update_document(self, documents: List[Document], **kwargs):
"""Update document into the store."""
for document in documents:
embedding = document.embedding
if self.embedding_model is not None and len(embedding) == 0:
embedding = self.embedding_model.get_embeddings([document.text])[0]
self.collection.update(
documents=[document.text],
metadatas=[document.metadata],
embeddings=[embedding] if embedding is not None else None,
ids=[document.id]
)

@staticmethod
def to_documents(query_result: QueryResult) -> List[Document]:
"""Convert the query results of ChromaDB to the AgentUniverse(AU) document format."""
Expand Down
11 changes: 9 additions & 2 deletions agentuniverse/agent/action/knowledge/store/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Dict, Any, Optional, List

from langchain_core.documents.base import Document as LCDocument
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, model_validator


class Document(BaseModel):
Expand All @@ -21,11 +21,18 @@ class Document(BaseModel):
embedding (List[float]): Embedding data associated with the document
"""

id: str = Field(default_factory=lambda: str(uuid.uuid4()))
id: str = None
text: Optional[str] = ""
metadata: Optional[Dict[str, Any]] = None
embedding: List[float] = Field(default_factory=list)

@model_validator(mode='before')
def create_id(cls, values):
text: str = values.get('text', '')
if not values.get('id'):
values['id'] = str(uuid.uuid5(uuid.NAMESPACE_URL, text))
return values

def as_langchain(self) -> LCDocument:
"""Convert to LangChain document format."""
metadata = self.metadata or {}
Expand Down
16 changes: 16 additions & 0 deletions agentuniverse/agent/action/knowledge/store/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,19 @@ def delete_document(self, document_id: str, **kwargs):
async def async_delete_document(self, document_id: str, **kwargs):
"""Asynchronously delete the specific document by the document id."""
raise NotImplementedError

def upsert_document(self, documents: List[Document], **kwargs):
"""Upsert document into the store."""
raise NotImplementedError

async def async_upsert_document(self, documents: List[Document], **kwargs):
"""Asynchronously upsert documents into the store."""
raise NotImplementedError

def update_document(self, documents: List[Document], **kwargs):
"""Update document into the store."""
raise NotImplementedError

async def async_update_document(self, documents: List[Document], **kwargs):
"""Asynchronously update documents into the store."""
raise NotImplementedError
43 changes: 43 additions & 0 deletions agentuniverse/agent/default/peer_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-

# @Time : 2024/4/29 16:00
# @Author : wangchongshi
# @Email : [email protected]
# @FileName: peer_agent.py
from agentuniverse.agent.agent import Agent
from agentuniverse.agent.input_object import InputObject


class PeerAgent(Agent):
"""Peer Agent class."""

def input_keys(self) -> list[str]:
"""Return the input keys of the Agent."""
return ['input']

def output_keys(self) -> list[str]:
"""Return the output keys of the Agent."""
return ['output']

def parse_input(self, input_object: InputObject, planner_input: dict) -> dict:
"""Planner parameter parsing.

Args:
input_object(InputObject): agent parameter object
planner_input(dict): Planner input
Returns:
dict: Planner input
"""
planner_input['input'] = input_object.get_data('input')
return planner_input

def parse_result(self, planner_result: dict) -> dict:
"""Planner result parser.

Args:
planner_result(dict): Planner result
Returns:
dict: Agent result object.
"""
return {"output": planner_result.get('result')[0].get('expressing_result').get_data('output')}
16 changes: 16 additions & 0 deletions agentuniverse/agent/default/peer_agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
info:
name: 'PeerAgent'
description: 'peer agent'
plan:
planner:
name: 'peer_planner'
eval_threshold: 60
retry_count: 2
planning: 'PlanningAgent'
executing: 'ExecutingAgent'
expressing: 'ExpressingAgent'
reviewing: 'ReviewingAgent'
metadata:
type: 'AGENT'
module: 'agentuniverse.agent.default.peer_agent'
class: 'PeerAgent'
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
# @FileName: executing_planner.py
"""Execution planner module."""
import asyncio

from langchain.chains import LLMChain
from langchain_core.memory import BaseMemory
from langchain_core.prompts import PromptTemplate

from agentuniverse.agent.agent_model import AgentModel
from agentuniverse.agent.input_object import InputObject
from agentuniverse.agent.plan.planner.planner import Planner
Expand Down Expand Up @@ -39,21 +40,21 @@ def invoke(self, agent_model: AgentModel, planner_input: dict, input_object: Inp

llm: LLM = self.handle_llm(agent_model)

self.handle_prompt(agent_model, planner_input)
prompt: Prompt = self.handle_prompt(agent_model, planner_input)

llm_chain = LLMChain(llm=llm.as_langchain(),
prompt=self.prompt.as_langchain(),
prompt=prompt.as_langchain(),
output_key=self.output_key, memory=memory)
return asyncio.run(llm_chain.acall(inputs=planner_input))

def handle_prompt(self, agent_model: AgentModel, planner_input: dict):
def handle_prompt(self, agent_model: AgentModel, planner_input: dict) -> Prompt:
"""Prompt module processing.

Args:
agent_model (AgentModel): Agent model object.
planner_input (dict): Planner input object.
Returns:
PromptTemplate: The prompt template.
Prompt: The prompt instance.
"""
expert_framework = planner_input.pop('expert_framework', '') or ''

Expand All @@ -74,6 +75,7 @@ def handle_prompt(self, agent_model: AgentModel, planner_input: dict):
target=prompt.target,
instruction=expert_framework + prompt.instruction)

self.prompt.build_prompt(user_prompt_model, system_prompt_model,
self.prompt_assemble_order)
process_llm_token(self.prompt.as_langchain(), profile, planner_input)
prompt: Prompt = Prompt().build_prompt(user_prompt_model, system_prompt_model,
self.prompt_assemble_order)
process_llm_token(prompt.as_langchain(), profile, planner_input)
return prompt
Loading