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

feat: add api-workflow plugin #1229

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

feat: add api-workflow plugin #1229

wants to merge 4 commits into from

Conversation

lixf311
Copy link

@lixf311 lixf311 commented Aug 19, 2024

Ⅰ. Describe what this PR did

Add ai-workflow plugin,the first version only supports tools.

Ⅱ. Does this pull request fix one issue?

fixes #1225

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@CLAassistant
Copy link

CLAassistant commented Aug 19, 2024

CLA assistant check
All committers have signed the CLA.

@johnlanni
Copy link
Collaborator

@lixf311 上面的CLA要签署一下

@lixf311
Copy link
Author

lixf311 commented Aug 20, 2024

ok~

plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
plugins/wasm-go/extensions/ai-workflow/README.md Outdated Show resolved Hide resolved
@johnlanni
Copy link
Collaborator

@lixf311 加一下我钉钉吧:chengtanzty

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.96%. Comparing base (ef31e09) to head (1085b55).
Report is 49 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1229      +/-   ##
==========================================
+ Coverage   35.91%   35.96%   +0.05%     
==========================================
  Files          69       69              
  Lines       11576     9500    -2076     
==========================================
- Hits         4157     3417     -740     
+ Misses       7104     5767    -1337     
- Partials      315      316       +1     

see 67 files with indirect coverage changes

@@ -0,0 +1,376 @@
## 功能说明
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README的格式可以参考下ai-proxy的方便后续放到官网上

| service_headers | array of header object | 选填 | | 请求的头 | |
| service_body_replace_keys| array of bodyReplaceKeyPair object | 选填| 请求body模板替换键值对 | 用来构造请求| 如果为空,则直接使用service_body_tmpl请求 |
| service_body_tmpl | string | 选填 | | 请求的body模板 | |
| service_type | string | 必填 | | 请求的类型 | static,domain |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要区分service_type,Cluster使用FQDNCluster可以适配所有方式。配置时,如果是static类型,service_name使用xxx.static,如果是dns类型,service_name使用xxx.dns

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来是这样,是我理解的不对,感谢指点,我来改下

func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action {

initHeader := make([][2]string, 0)
//初始化运行状态
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注释格式可以调整下 统一成//后面加个空格

// 初始化运行状态 


initHeader := make([][2]string, 0)
//初始化运行状态
workflowExecStatus, err := initWorkflowExecStatus(config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个初始状态是否可以在parseConfig的时候就定义好,我看这里只用到了config的信息,不涉及每个请求的具体信息

initHeader := make([][2]string, 0)
//初始化运行状态
workflowExecStatus, err := initWorkflowExecStatus(config)
log.Errorf("init status : %v", workflowExecStatus)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日志级别调整下

}
return

}, uint32(maxDepth)*5000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个超时时间最好改为可配置的

*/
type CompareFunc func(a, b float64) bool

var operators = map[string]interface{}{
Copy link
Collaborator

@hanxiantao hanxiantao Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

由于tinygo的一些限制(比如不能使用反射等)不能直接使用类似https://github.com/vulcand/predicate 的go第三方库,我们可以参考下这个库的设计和实现,丰富一些类似And和Or的能力(只是建议,可以优化下代码实现,具体是否丰富功能看当前场景下是否需要)

Comment on lines +189 to +192
w.Task.Cluster = wrapper.FQDNCluster{
FQDN: node.ServiceName,
Port: node.ServicePort,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面README中提到的只保留这个即可

@@ -0,0 +1,21 @@
module github.com/alibaba/higress/plugins/wasm-go/extensions/ai-workflow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module名称叫ai-workflow即可

"github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types"
"github.com/tidwall/gjson"
"net/http"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调整下go import的顺序吧,代码编辑器一般都有这个设置
goland的话可以参考下这个:https://blog.csdn.net/t949500898/article/details/123330231

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

学习了,已经设置,感谢。


var operators = map[string]interface{}{
//CompareFunc 用来比较float64 数据大小:
"eq": func(a, b float64) bool { return a == b },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只支持数值类型的比较吗?这种场景下字符串的比较可能更常见一些

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以加,应该没啥问题,我来想想增加哪些

@johnlanni johnlanni changed the title feat: add ai-workflow plugin feat: add aip-workflow plugin Aug 27, 2024
@johnlanni johnlanni changed the title feat: add aip-workflow plugin feat: add api-workflow plugin Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Higress 可编排工作流 ai-workflow的设计
5 participants