Skip to content

Commit

Permalink
add multi agent support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Sep 9, 2024
1 parent dc0f9e9 commit c7bfeb3
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 81 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0

- add multi agent supported

## 0.3.1

- Add Dockerfile
Expand Down
75 changes: 38 additions & 37 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,46 @@
- 请求参数:
- 大模型设置:大模型的链接、key、模型名称
- 预置提示词:角色、能力、目标描述
- 能力细节描述:openapi、openmodbus文档描述。其中apiKey根据实际需要可选填写
- 能力细节描述:(可选)openapi、openrpc、openmodbus文档描述。其中apiKey根据实际需要可选填写
- Session列表:(可选)对多Agent做支持。先初始化其他Agent,获得SessionId后,传入这个字段。
- 超时时间:默认3600秒,停止交互后,超过时间则清空上下文
- 请求样例
```json
{
"llmConfig": {
"baseUrl": "<大模型厂商的api入口,例如:https://api.openai.com/v1>",
"apiKey": "<大模型厂商的api的Key,例如:sk-xxxxxxxxxx>",
"model": "<厂商支持的大模型名称,例如:gpt-3.5-turbo,下方的temperature、maxTokens、topP可选传入,下方为默认值>",
"temperature": 0,
"maxTokens": 4096,
"topP": 1
- 请求样例
```json
{
"llmConfig": {
"baseUrl": "<大模型厂商的api入口,例如:https://api.openai.com/v1>",
"apiKey": "<大模型厂商的api的Key,例如:sk-xxxxxxxxxx>",
"model": "<厂商支持的大模型名称,例如:gpt-3.5-turbo,下方的temperature、maxTokens、topP可选传入,下方为默认值>",
"temperature": 0,
"maxTokens": 4096,
"topP": 1
},
"systemPrompt": "<预置的系统提示词,例如扮演什么角色,具有什么能力,需要帮助用户解决哪一类的问题>",
"openSpecList": [
{
"openSpec": "<(可选)spec的json描述文本,目前支持的类型是openapi、openmodbus、openrpc>",
"apiKey": {
"type": "<basic或bearer二选一>",
"apiKey": "<第三方服务的apiKey>"
},
"systemPrompt": "<预置的系统提示词,例如扮演什么角色,具有什么能力,需要帮助用户解决哪一类的问题>",
"openSpecList": [
{
"openSpec": "<(可选)spec的json描述文本,目前支持的类型是openapi、openmodbus、openrpc>",
"apiKey": {
"type": "<basic或bearer二选一>",
"apiKey": "<第三方服务的apiKey>"
},
"protocol": "目前支持openapi、openmodbus、jsonrpcHttp"
},
{
"openSpec": "<(可选)另一段spec的json描述,可以不同类型混用>",
"protocol": "目前支持openapi、openmodbus、jsonrpcHttp"
}
],
"sessionList": [
{
"id": "<Sub Agent sessionId 1>"
},
{
"id": "<Sub Agent sessionId 2>"
}
],
"timeoutSeconds": 3600
}
```
"protocol": "目前支持openapi、openmodbus、jsonrpcHttp"
},
{
"openSpec": "<(可选)另一段spec的json描述,可以不同类型混用>",
"protocol": "目前支持openapi、openmodbus、jsonrpcHttp"
}
],
"sessionList": [
{
"id": "<Sub Agent sessionId 1>"
},
{
"id": "<Sub Agent sessionId 2>"
}
],
"timeoutSeconds": 3600
}
```

- 返回:
- sessionId,用以后续对于该session的消息订阅、stop、clear操作
Expand Down
77 changes: 39 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,46 @@ LLM `AI Agent` multi session HTTP/WebSocket service
- Request body:
- LLM config: baseUrl, apiKey, model
- System Prompt: Agent character, ToDo/NotToDo description
- Tools Description: openapi、openmodbus Spec. According to third APIs in Spec to set `apiKey` or net
- Tools Description: (Optional) openapi, openrpc, openmodbus Spec. According to third APIs in Spec to set `apiKey` or net
- Session List: (Optional) for multi agents supported. Init other agents, and add their sessionIds in this field.
- Timeout:3600 seconds in default. When agent stopped, massages context will be clear
- Sample:
```json
{
"llmConfig": {
"baseUrl": "<LLM API baseUrl, e.g. https://api.openai.com/v1>",
"apiKey": "<LLM API apiKey, e.g. sk-xxxxxxxxxx>",
"model": "<LLM API model name, e.g. gpt-3.5-turbo. And temperature、maxTokens、topP can be changed below >",
"temperature": 0,
"maxTokens": 4096,
"topP": 1
},
"systemPrompt": "<System Prompt. LLM character, capabilities, need to help user fixed what problems>",
"openSpecList": [
{
"openSpec": "<(Optional) tool spec json string, support openapi、openmodbus、openrpc>",
"apiKey": {
"type": "<basic or bearer>",
"apiKey": "<Third APIs apiKey>"
},
"protocol": "Support openapi, openmodbus, jsonrpcHttp"
},
{
"openSpec": "<(Optional) Another spec json string, can be another protocol>",
"protocol": "Support openapi, openmodbus, jsonrpcHttp"
}
],
"sessionList": [
{
"id": "<Sub Agent sessionId 1>"
},
{
"id": "<Sub Agent sessionId 2>"
}
],
"timeoutSeconds": 3600
}
```
- Sample:
```json
{
"llmConfig": {
"baseUrl": "<LLM API baseUrl, e.g. https://api.openai.com/v1>",
"apiKey": "<LLM API apiKey, e.g. sk-xxxxxxxxxx>",
"model": "<LLM API model name, e.g. gpt-3.5-turbo. And temperature、maxTokens、topP can be changed below >",
"temperature": 0,
"maxTokens": 4096,
"topP": 1
},
"systemPrompt": "<System Prompt. LLM character, capabilities, need to help user fixed what problems>",
"openSpecList": [
{
"openSpec": "<(Optional) tool spec json string, support openapi、openmodbus、openrpc>",
"apiKey": {
"type": "<basic or bearer>",
"apiKey": "<Third APIs apiKey>"
},
"protocol": "Support openapi, openmodbus, jsonrpcHttp"
},
{
"openSpec": "<(Optional) Another spec json string, can be another protocol>",
"protocol": "Support openapi, openmodbus, jsonrpcHttp"
}
],
"sessionList": [
{
"id": "<Sub Agent sessionId 1>"
},
{
"id": "<Sub Agent sessionId 2>"
}
],
"timeoutSeconds": 3600
}
```

- Response body:
- sessionId, will be used as session websocket subscribe, stop and clear operations.
Expand Down
8 changes: 4 additions & 4 deletions example/multi_agent_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Future<void> main() async {
return;
}

CapabilityDto capabilityDto = CapabilityDto(llmConfig: llmConfig, systemPrompt: systemPrompt,
sessionList: [sessionDto1, sessionDto2]
);
CapabilityDto capabilityDto = CapabilityDto(llmConfig: llmConfig, systemPrompt: systemPrompt,
sessionList: [sessionDto1, sessionDto2]
);

SessionDto? sessionDto = await initChat(capabilityDto);
SessionDto? sessionDto = await initChat(capabilityDto);

if (sessionDto != null) {
print("[sessionDto] " + sessionDto.toJson().toString());
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: lite_agent_core_dart_server
description: HTTP Server using `Lite Agent core for Dart`
version: 0.3.1
version: 0.4.0
repository: https://github.com/LiteVar/lite_agent_core_dart_server

environment:
Expand All @@ -13,7 +13,7 @@ dependencies:
web_socket_channel: ^3.0.0
logging: ^1.2.0
json_annotation: ^4.9.0
lite_agent_core_dart: ^0.3.0
lite_agent_core_dart: ^0.4.0

dev_dependencies:
opentool_dart: ^0.2.0
Expand Down

0 comments on commit c7bfeb3

Please sign in to comment.