Skip to content

Commit

Permalink
Merge pull request #34 from alipay/dev
Browse files Browse the repository at this point in the history
feat: Release version 0.0.6
  • Loading branch information
LandJerry authored May 15, 2024
2 parents d09b75c + b5a002c commit 15000fb
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ Note - Additional remarks regarding the version.
***************************************************

# Version Update History
## [0.0.6] - 2024-05-15
### Added
- Support for the GPT-4o model, with updates to related examples.
- Support for the RPC component gRPC, providing a standard method for service startup.

### Note
- Provide standard Docker images and K8S deployment solutions.
- Some code optimizations and documentation updates.

## [0.0.5] - 2024-05-08
### Added
- The LLM component supports streaming calls.
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Note - 对于版本的额外说明。
***************************************************

# 版本更新记录

## [0.0.6] - 2024-05-15
### Added
- 支持gpt-4o模型, 并更新相关样例
- 支持RPC组件gGpc,并提供标准服务启动方法

### Note
- 提供标准的aU Docker镜像与K8S部署方案,详情见指导手册
- 部分代码优化与文档更新

## [0.0.5] - 2024-05-08
### Added
- LLM组件支持流式调用
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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.4-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.6-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)

![](docs/guidebook/_picture/logo_bar.jpg)
****************************************
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![](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.4-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)
[![Static Badge](https://img.shields.io/badge/pypi-v0.0.6-blue?logo=pypi)](https://pypi.org/project/agentUniverse/)

![](docs/guidebook/_picture/logo_bar.jpg)
****************************************
Expand Down
2 changes: 2 additions & 0 deletions docs/guidebook/en/0_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* 3.1.6 Planner
* 3.2 Technical Components
* 3.2.1 RPC
* 3.2.1.1 [gRPC](3_2_1_gRPC.md)
* 3.2.2 Store
* 3.2.3 Msg
* 3.2.4 Logging
Expand All @@ -50,6 +51,7 @@
**5. Best Practices**
* 5.1 Operations and Deployment
* 5.1.1 [Docker Containerization Solution](5_1_1_Docker_Container_Deployment.md)
* 5.1.2 [K8S Solution](5_1_2_K8S_Deployment.md)

**6. Series of Articles**

Expand Down
123 changes: 123 additions & 0 deletions docs/guidebook/en/3_2_1_gRPC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
## gRPC
In addition to HTTP API, we also provide a built-in GRPC Agent service server.

### Starting gRPC server
If you need to enable GRPC server, you can configure it in the config.toml file as follows:
```toml
[GRPC]
activate = 'true'
max_workers = 10
server_port = 50051
```
- **activate**: The gRPC server starts only when this value is set to `true`.
- **max_workers**: The maximum number of threads in the gRPC server thread pool, with a default of 10.
- **server_port**: The service port of the gRPC server, with a default of 50051.

### Calling the gRPC Service

### Interface Definition
The complete definition file for the gRPC service interface is as follows:
```text
syntax = "proto3";
package agentuniverse;
service AgentUniverseService {
rpc service_run(AgentServiceRequest) returns (AgentServiceResponse);
rpc service_run_async(AgentServiceRequest) returns (AgentServiceResponse);
rpc service_run_result(AgentResultRequest) returns (AgentServiceResponse);
}
message AgentServiceRequest {
string service_id = 1;
string params = 2;
bool saved = 3;
}
message AgentServiceResponse {
string message = 1;
bool success = 2;
string request_id = 3;
string result = 4;
}
message AgentResultRequest {
string request_id = 1;
}
```
\
Similar to the [Web API](2_4_1_Web_Api.md), the gRPC service includes three interfaces:
```text
service AgentUniverseService {
rpc service_run(AgentServiceRequest) returns (AgentServiceResponse);
rpc service_run_async(AgentServiceRequest) returns (AgentServiceResponse);
rpc service_run_result(AgentResultRequest) returns (AgentServiceResponse);
}
```
- **service_run**: Synchronously calls an Agent service, blocking during the call until the Agent returns results.
- **service_run_async**: Asynchronously calls an Agent service, initially returning a `request_id`, and the result of the Agent service can be queried later using the `service_run_result` interface with this ID.
- **service_run_result**: Queries the result of the Agent service.。

\
The request body structure for calling an Agent service is as follows::
```text
message AgentServiceRequest {
string service_id = 1;
string params = 2;
bool saved = 3;
}
```
- **service_id**: The model service id registered in the application.。
- **params**: The service input parameters in JSON String format, which will be parsed by `json.loads` into the form of `**kwargs` passed to the underlying Agent.
- **saved**: Whether to save the result of this request. If the value is `false`, the result of this request cannot be queried in `service_run_result`.

\
The request body structure for querying the result of an Agent service is as follows:
```text
message AgentResultRequest {
string request_id = 1;
}
```
- **request_id**: The request ID to be queried.

\
The structure of the return result is as follows:
```text
message AgentServiceResponse {
string message = 1;
bool success = 2;
string request_id = 3;
string result = 4;
}
```
- **message**: Detailed error information when the request fails.
- **success**: Indicates whether the request was successfully executed.
- **request_id**: The ID of this request.
- **result**: The result of executing the Agent service. It is empty in the asynchronous interface `service_run_async`.

### Call Example
```python
import grpc
from agentuniverse.agent_serve.web.rpc.grpc import agentuniverse_service_pb2, \
agentuniverse_service_pb2_grpc


# Start you server_application first.
def test_run():
with grpc.insecure_channel('localhost:50051') as channel:
stub = agentuniverse_service_pb2_grpc.AgentUniverseServiceStub(channel)
response = stub.service_run(agentuniverse_service_pb2.AgentServiceRequest(
service_id='demo_service',
params='{"input":"(18+3-5)/2*4=?"}',
saved=True
))
print("client received: " + response.request_id)

response = stub.service_run_result(agentuniverse_service_pb2.AgentResultRequest(
request_id=response.request_id
))
print("client received: " + response.result)
```



109 changes: 109 additions & 0 deletions docs/guidebook/en/5_1_2_K8S_Deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# High Availability Deployment with K8S
AgentUniverse provides standard working environment images, designed to support containerized deployments on Kubernetes (K8S) clusters. This guide will show you how to utilize these working environment images to deploy and set up a cluster on K8S.
Official K8S Documentation: [Kubernetes Setup Documentation](https://kubernetes.io/docs/setup/)

## 1. Resource Configuration
First, you need to configure the necessary resource files. Below is an example used to define the required Namespace, Deployment, and Service resources using a YAML configuration file:

```yaml
apiVersion: v1
kind: Namespace
metadata:
name: agent-namespace
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: agentuniverse-deployment
namespace: agent-namespace
labels:
app: agentuniverse
spec:
replicas: 3
selector:
matchLabels:
app: agentuniverse
template:
metadata:
labels:
app: agentuniverse
spec:
containers:
- name: agentuniverse-container
image: registry.cn-hangzhou.aliyuncs.com/agent_universe/agent_universe:0.0.5_centos8_beta
ports:
- containerPort: 8888
command: ["/bin/bash", "-c"]
args: ["git clone [email protected]:alipay/agentUniverse.git; mv agentUniverse/sample_standard_app /usr/local/etc/workspace/project; /bin/bash --login /usr/local/etc/workspace/shell/start.sh"]
# Uncomment and replace "XXX" with your key to configure the agent
# env:
# - name: OPENAI_API_KEY
# value: "XXX"
---
apiVersion: v1
kind: Service
metadata:
name: agentuniverse-service
namespace: agent-namespace
spec:
selector:
app: agentuniverse
ports:
- protocol: TCP
port: 9999
targetPort: 8888
```
### 1.1 Setting Environment Variables for AgentUniverse Project
#### Method 1 (Recommended)
In the resource configuration file, uncomment the `env` section and replace `value` with your key. For additional security considerations, it's recommended to use K8S officially recommended methods, such as ConfigMap. See the [ConfigMap Configuration Documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/).

#### Method 2

Please refer to the description at the beginning of the configuration file: [Quick Start Guide](https://github.com/alipay/agentUniverse/blob/master/docs/guidebook/zh/1_3_快速开始.md)

## 2. Building Resources

Create and apply the aforementioned configuration file:

```
kubectl apply -f agentuniverse.yaml
```

## 3. Verifying Resources

Verify that all resources have been correctly deployed:

```
kubectl get all -n agent-namespace
```

![Resource Deployment Status](../_picture/k8s_resource.png)

## 4. Accessing AgentUniverse Services from Inside the Cluster

To access AgentUniverse services from within the cluster, use the following command line example:

```
kubectl exec -it [Pod Name] -n agent-namespace -- curl http://agentuniverse-service:9999
```

### 4.1 Examples

#### 4.1.1 Connectivity Test

```
kubectl exec -it agentuniverse-deployment-55cfd778d-g7d9d -n agent-namespace -- curl http://agentuniverse-service:9999/echo
```
![Connectivity Test](../_picture/k8s_hello.png)
#### 4.1.2 Q&A Test
```
kubectl exec -it agentuniverse-deployment-55cfd778d-g7d9d -n agent-namespace -- curl -X POST -H "Content-Type: application/json" -d '{"service_id":"demo_service","params":{"input":"(18+3-5)/2*4=?"}}' http://agentuniverse-service:9999/service_run
```
![Q&A Test](../_picture/k8s_question.png)
4 changes: 3 additions & 1 deletion docs/guidebook/zh/0_目录.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* 3.1.6 规划(Planner)
* 3.2 技术组件
* 3.2.1 RPC
* 3.2.1.1 [gRPC](3_2_1_gRPC.md)
* 3.2.2 存储 (Store)
* 3.2.3 消息(Msg)
* 3.2.4 日志(Logging)
Expand All @@ -53,7 +54,8 @@

**5.最佳实践**
* 5.1 运维部署
* 5.1.1 [docker容器化方案](5_1_1_Docker容器化部署.md)
* 5.1.1 [Docker容器化方案](5_1_1_Docker容器化部署.md)
* 5.1.2 [K8S部署方案](5_1_2_K8S部署.md)

**6.系列文章**

Expand Down
Loading

0 comments on commit 15000fb

Please sign in to comment.