-
Notifications
You must be signed in to change notification settings - Fork 137
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
Add OpenAPI tool #246
Add OpenAPI tool #246
Conversation
src/tools/openapi.ts
Outdated
description?: string; | ||
openApiSchema?: any; | ||
apiKey?: string; | ||
http_proxy_url?: string; |
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.
Please use camelCase
src/tools/openapi.ts
Outdated
http_proxy_url?: string; | ||
} | ||
|
||
type ToolRunOptions = BaseToolRunOptions; |
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.
Can be removed.
src/tools/openapi.ts
Outdated
} | ||
} | ||
|
||
export class OpenAPI extends Tool<StringToolOutput, OpenAPIOptions, ToolRunOptions> { |
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.
ToolRunOptions
can be removed.
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.
Rename to OpenAPITool
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 response class does not match the reality.
It should be OpenAPIToolOutput
, not StringToolOutput
.
src/tools/openapi.ts
Outdated
//ToolInput<this>, | ||
any, |
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.
Replace with Record<string, any>
src/tools/openapi.ts
Outdated
public readonly emitter: ToolEmitter< | ||
//ToolInput<this>, | ||
any, | ||
StringToolOutput, |
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.
Should be OpenAPIToolOutput
src/tools/openapi.ts
Outdated
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style | ||
const headers: { [key: string]: string } = { Accept: "application/json" }; | ||
if (this.apiKey) { | ||
headers["Authorization"] = `Bearer this.apiKey`; |
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.
This does not work.
You probably wanted to do Bearer ${this.apiKey}
.
src/tools/openapi.ts
Outdated
headers: headers, | ||
signal: AbortSignal.any([AbortSignal.timeout(30_000), run.signal]), | ||
}); | ||
return new StringToolOutput(await response.text()); |
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.
Wrong response type.
src/tools/openapi.ts
Outdated
body: !isEmpty(input.body) ? input.body : undefined, | ||
method: input.method.toLowerCase(), | ||
headers: headers, | ||
signal: AbortSignal.any([AbortSignal.timeout(30_000), run.signal]), |
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.
Remove the AbortSignal.timeout()
because a user can specify it via run parameters.
4118170
to
599387d
Compare
src/tools/openapi.ts
Outdated
} | ||
|
||
protected async _run( | ||
input: any, |
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.
What is the error message?
1e85cb1
to
f718e60
Compare
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
f718e60
to
d574e0e
Compare
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.
Great work! 🚀
Which issue(s) does this pull-request address?
Closes: #105
Description
Checklist
yarn lint
oryarn lint:fix
yarn format
oryarn format:fix
yarn test:unit
yarn test:e2e