3535class APIHubToolset (BaseToolset ):
3636 """APIHubTool generates tools from a given API Hub resource.
3737
38- Examples:
38+ Examples::
3939
40- ```
41- apihub_toolset = APIHubToolset(
42- apihub_resource_name="projects/test-project/locations/us-central1/apis/test-api",
43- service_account_json="...",
44- tool_filter=lambda tool, ctx=None: tool.name in ('my_tool',
45- 'my_other_tool')
46- )
47-
48- # Get all available tools
49- agent = LlmAgent(tools=apihub_toolset)
40+ apihub_toolset = APIHubToolset(
41+ apihub_resource_name="projects/test-project/locations/us-central1/apis/test-api",
42+ service_account_json="...",
43+ tool_filter=lambda tool, ctx=None: tool.name in ('my_tool',
44+ 'my_other_tool')
45+ )
5046
51- ```
47+ # Get all available tools
48+ agent = LlmAgent(tools=apihub_toolset)
5249
5350 **apihub_resource_name** is the resource name from API Hub. It must include
54- API name, and can optionally include API version and spec name.
55- - If apihub_resource_name includes a spec resource name, the content of that
56- spec will be used for generating the tools.
57- - If apihub_resource_name includes only an api or a version name, the
58- first spec of the first version of that API will be used.
51+ API name, and can optionally include API version and spec name.
52+
53+ - If apihub_resource_name includes a spec resource name, the content of that
54+ spec will be used for generating the tools.
55+ - If apihub_resource_name includes only an api or a version name, the
56+ first spec of the first version of that API will be used.
5957 """
6058
6159 def __init__ (
@@ -78,44 +76,45 @@ def __init__(
7876 ):
7977 """Initializes the APIHubTool with the given parameters.
8078
81- Examples:
82- ```
83- apihub_toolset = APIHubToolset(
84- apihub_resource_name="projects/test-project/locations/us-central1/apis/test-api",
85- service_account_json="...",
86- )
79+ Examples::
8780
88- # Get all available tools
89- agent = LlmAgent(tools=[apihub_toolset])
81+ apihub_toolset = APIHubToolset(
82+ apihub_resource_name="projects/test-project/locations/us-central1/apis/test-api",
83+ service_account_json="...",
84+ )
9085
91- apihub_toolset = APIHubToolset(
92- apihub_resource_name="projects/test-project/locations/us-central1/apis/test-api",
93- service_account_json="...",
94- tool_filter = ['my_tool']
95- )
96- # Get a specific tool
97- agent = LlmAgent(tools=[
98- ...,
99- apihub_toolset,
100- ])
101- ```
86+ # Get all available tools
87+ agent = LlmAgent(tools=[apihub_toolset])
88+
89+ apihub_toolset = APIHubToolset(
90+ apihub_resource_name="projects/test-project/locations/us-central1/apis/test-api",
91+ service_account_json="...",
92+ tool_filter = ['my_tool']
93+ )
94+ # Get a specific tool
95+ agent = LlmAgent(tools=[
96+ ...,
97+ apihub_toolset,
98+ ])
10299
103100 **apihub_resource_name** is the resource name from API Hub. It must include
104101 API name, and can optionally include API version and spec name.
102+
105103 - If apihub_resource_name includes a spec resource name, the content of that
106104 spec will be used for generating the tools.
107105 - If apihub_resource_name includes only an api or a version name, the
108106 first spec of the first version of that API will be used.
109107
110108 Example:
109+
111110 * projects/xxx/locations/us-central1/apis/apiname/...
112111 * https://console.cloud.google.com/apigee/api-hub/apis/apiname?project=xxx
113112
114113 Args:
115114 apihub_resource_name: The resource name of the API in API Hub.
116- Example: `projects/test-project/locations/us-central1/apis/test-api`.
117- access_token: Google Access token. Generate with gcloud cli `gcloud auth
118- auth print-access-token`. Used for fetching API Specs from API Hub.
115+ Example: `` projects/test-project/locations/us-central1/apis/test-api` `.
116+ access_token: Google Access token. Generate with gcloud cli
117+ ``gcloud auth auth print-access-token` `. Used for fetching API Specs from API Hub.
119118 service_account_json: The service account config as a json string.
120119 Required if not using default service credential. It is used for
121120 creating the API Hub client and fetching the API Specs from API Hub.
0 commit comments