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

Add OpenAPI tool #246

Merged
merged 1 commit into from
Dec 20, 2024
Merged

Add OpenAPI tool #246

merged 1 commit into from
Dec 20, 2024

Conversation

akihikokuroda
Copy link
Contributor

@akihikokuroda akihikokuroda commented Dec 11, 2024

Which issue(s) does this pull-request address?

Closes: #105

Description

Checklist

  • I have read the contributor guide
  • Linting passes: yarn lint or yarn lint:fix
  • Formatting is applied: yarn format or yarn format:fix
  • Unit tests pass: yarn test:unit
  • E2E tests pass: yarn test:e2e
  • Tests are included
  • Documentation is changed or added
  • Commit messages and PR title follow conventional commits

@akihikokuroda akihikokuroda requested a review from a team as a code owner December 11, 2024 21:46
description?: string;
openApiSchema?: any;
apiKey?: string;
http_proxy_url?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use camelCase

http_proxy_url?: string;
}

type ToolRunOptions = BaseToolRunOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be removed.

}
}

export class OpenAPI extends Tool<StringToolOutput, OpenAPIOptions, ToolRunOptions> {
Copy link
Contributor

Choose a reason for hiding this comment

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

ToolRunOptions can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to OpenAPITool

Copy link
Contributor

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.

Comment on lines 112 to 113
//ToolInput<this>,
any,
Copy link
Contributor

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>

public readonly emitter: ToolEmitter<
//ToolInput<this>,
any,
StringToolOutput,
Copy link
Contributor

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 Show resolved Hide resolved
// 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`;
Copy link
Contributor

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 Show resolved Hide resolved
headers: headers,
signal: AbortSignal.any([AbortSignal.timeout(30_000), run.signal]),
});
return new StringToolOutput(await response.text());
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong response type.

body: !isEmpty(input.body) ? input.body : undefined,
method: input.method.toLowerCase(),
headers: headers,
signal: AbortSignal.any([AbortSignal.timeout(30_000), run.signal]),
Copy link
Contributor

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.

src/tools/openapi.ts Show resolved Hide resolved
src/tools/openapi.ts Show resolved Hide resolved
}

protected async _run(
input: any,
Copy link
Contributor

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?

src/tools/openapi.ts Outdated Show resolved Hide resolved
@akihikokuroda akihikokuroda force-pushed the apitool branch 4 times, most recently from 1e85cb1 to f718e60 Compare December 16, 2024 21:07
src/tools/openapi.ts Outdated Show resolved Hide resolved
src/tools/openapi.ts Outdated Show resolved Hide resolved
src/tools/openapi.ts Show resolved Hide resolved
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
Copy link
Contributor

@Tomas2D Tomas2D left a comment

Choose a reason for hiding this comment

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

Great work! 🚀

@Tomas2D Tomas2D merged commit e10b053 into i-am-bee:main Dec 20, 2024
2 checks passed
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.

OpenAPI tool
2 participants