-
Notifications
You must be signed in to change notification settings - Fork 45
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: [tool/httprequest] add httprequest tool #147
base: main
Are you sure you want to change the base?
Conversation
dc1cc5d
to
dfb1bd3
Compare
components/tool/request/README.md
Outdated
@@ -0,0 +1,357 @@ | |||
# HTTP Request Tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core of this tool should be HTTP, and the package name request doesn't feel quite right. Should it be called http or httprequest?
components/tool/request/request.go
Outdated
Timeout: conf.Timeout, | ||
ResponseContentType: conf.ResponseContentType, | ||
} | ||
getTool, err := get.NewTool(ctx, getConf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think including PUT and DELETE is better, as they are commonly used in RESTful applications.
components/tool/request/get/tool.go
Outdated
} | ||
|
||
func (c *Config) validate() error { | ||
if c.ToolName == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write a comment to explain that it is sourced from LangChain.
components/tool/request/post/post.go
Outdated
|
||
var content interface{} | ||
if r.config.ResponseContentType == "json" { | ||
if err := sonic.Unmarshal(body, &content); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why deserialize and then serialize here? Unlike LangChain, this tool always outputs a string, so is this field unnecessary?
components/tool/request/request.go
Outdated
|
||
type Config struct { | ||
Headers map[string]string `json:"headers"` | ||
Timeout time.Duration `json:"timeout"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide the HTTP client directly instead of just the timeout.
components/tool/request/request.go
Outdated
} | ||
getTool, err := get.NewTool(ctx, getConf) | ||
if err != nil { | ||
return nil, fmt.Errorf("erro ao criar ferramenta GET: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use english please~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Sorry, I let that slip, but I've already fixed it.
I also implemented the tool for PUT and DELETE requests.
What type of PR is this?
feat: add request tool
Check the PR title.
Title: feat: [tool/request] add request tool
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
This PR implements a new Request Tool for the Eino framework. Inspired by LangChain's Requests integration (see LangChain Requests Tool), this tool provides a simple and consistent interface for performing HTTP GET and POST operations. It supports configurable headers, timeouts, and response content types (either JSON or text), making it easy for developers to integrate external web APIs into their Eino-based applications. By following the design principles of LangChain, this tool offers a familiar experience to developers and extends the overall capabilities of the Eino tool ecosystem.
zh (optional):
此 PR 为 Eino 框架实现了一个全新的 Request 工具。该工具受 LangChain 的 Requests 集成启发(参见 LangChain Requests Tool),提供了一个简单且一致的接口,用于执行 HTTP GET 和 POST 操作。它支持可配置的请求头、超时以及响应内容类型(JSON 或纯文本),从而使开发人员能够轻松地将外部 Web API 集成到基于 Eino 的应用中。该工具遵循 LangChain 的设计原则,为开发人员提供了熟悉的使用体验,并扩展了 Eino 工具生态系统的整体功能。
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: