Tools
Integration adapters for optional third-party SDKs.
This module exposes unified wrappers for integrating external tool registries and SDKs with PyAgenity agent graphs. The adapters provide registry-based discovery, function-calling schemas, and normalized execution for supported tool providers.
Exports
ComposioAdapter: Adapter for the Composio Python SDK. LangChainAdapter: Adapter for LangChain tool registry and execution.
Modules:
Name | Description |
---|---|
composio_adapter |
Composio adapter for PyAgenity. |
langchain_adapter |
LangChain adapter for PyAgenity (generic wrapper, registry-based). |
Classes:
Name | Description |
---|---|
ComposioAdapter |
Adapter around Composio Python SDK. |
LangChainAdapter |
Generic registry-based LangChain adapter. |
Attributes¶
Classes¶
ComposioAdapter
¶
Adapter around Composio Python SDK.
Notes on SDK methods used (from docs): - composio.tools.get(user_id=..., tools=[...]/toolkits=[...]/search=..., scopes=..., limit=...) Returns tools formatted for providers or agent frameworks; includes schema. - composio.tools.get_raw_composio_tools(...) Returns raw tool schemas including input_parameters. - composio.tools.execute(slug, arguments, user_id=..., connected_account_id=..., ...) Executes a tool and returns a dict like {data, successful, error}.
Methods:
Name | Description |
---|---|
__init__ |
Initialize the ComposioAdapter. |
execute |
Execute a Composio tool and return a normalized response dict. |
is_available |
Return True if composio SDK is importable. |
list_raw_tools_for_llm |
Return raw Composio tool schemas mapped to function-calling format. |
list_tools_for_llm |
Return tools formatted for LLM function-calling. |
Source code in pyagenity/adapters/tools/composio_adapter.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
Functions¶
__init__
¶
__init__(*, api_key=None, provider=None, file_download_dir=None, toolkit_versions=None)
Initialize the ComposioAdapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str | None
|
Optional API key for Composio. |
None
|
|
Any | None
|
Optional provider integration. |
None
|
|
str | None
|
Directory for auto file handling. |
None
|
|
Any | None
|
Toolkit version overrides. |
None
|
Raises:
Type | Description |
---|---|
ImportError
|
If composio SDK is not installed. |
Source code in pyagenity/adapters/tools/composio_adapter.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
execute
¶
execute(*, slug, arguments, user_id=None, connected_account_id=None, custom_auth_params=None, custom_connection_data=None, text=None, version=None, toolkit_versions=None, modifiers=None)
Execute a Composio tool and return a normalized response dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
Tool slug to execute. |
required |
|
dict[str, Any]
|
Arguments for the tool. |
required |
|
str | None
|
Optional user ID. |
None
|
|
str | None
|
Optional connected account ID. |
None
|
|
dict[str, Any] | None
|
Optional custom auth params. |
None
|
|
dict[str, Any] | None
|
Optional custom connection data. |
None
|
|
str | None
|
Optional text input. |
None
|
|
str | None
|
Optional version. |
None
|
|
Any | None
|
Optional toolkit versions. |
None
|
|
Any | None
|
Optional modifiers. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Normalized response dict with keys: successful, data, error. |
Source code in pyagenity/adapters/tools/composio_adapter.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
is_available
staticmethod
¶
is_available()
Return True if composio SDK is importable.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if composio SDK is available, False otherwise. |
Source code in pyagenity/adapters/tools/composio_adapter.py
83 84 85 86 87 88 89 90 91 |
|
list_raw_tools_for_llm
¶
list_raw_tools_for_llm(*, tool_slugs=None, toolkits=None, search=None, scopes=None, limit=None)
Return raw Composio tool schemas mapped to function-calling format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[str] | None
|
Optional list of tool slugs. |
None
|
|
list[str] | None
|
Optional list of toolkits. |
None
|
|
str | None
|
Optional search string. |
None
|
|
list[str] | None
|
Optional scopes. |
None
|
|
int | None
|
Optional limit on number of tools. |
None
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of raw tool schemas in function-calling format. |
Source code in pyagenity/adapters/tools/composio_adapter.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
list_tools_for_llm
¶
list_tools_for_llm(*, user_id, tool_slugs=None, toolkits=None, search=None, scopes=None, limit=None)
Return tools formatted for LLM function-calling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
User ID for tool discovery. |
required |
|
list[str] | None
|
Optional list of tool slugs. |
None
|
|
list[str] | None
|
Optional list of toolkits. |
None
|
|
str | None
|
Optional search string. |
None
|
|
list[str] | None
|
Optional scopes. |
None
|
|
int | None
|
Optional limit on number of tools. |
None
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of tools in function-calling format. |
Source code in pyagenity/adapters/tools/composio_adapter.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
LangChainAdapter
¶
Generic registry-based LangChain adapter.
Notes
- Avoids importing heavy integrations until needed (lazy default autoload).
- Normalizes schemas and execution results into simple dicts.
- Allows arbitrary tool registration instead of hardcoding a tiny set.
Methods:
Name | Description |
---|---|
__init__ |
Initialize LangChainAdapter. |
execute |
Execute a supported LangChain tool and normalize the response. |
is_available |
Return True if langchain-core is importable. |
list_tools_for_llm |
Return a list of function-calling formatted tool schemas. |
register_tool |
Register a tool instance and return the resolved name used for exposure. |
register_tools |
Register multiple tool instances. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
Functions¶
__init__
¶
__init__(*, autoload_default_tools=True)
Initialize LangChainAdapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
bool
|
Whether to autoload default tools if registry is empty. |
True
|
Raises:
Type | Description |
---|---|
ImportError
|
If langchain-core is not installed. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
execute
¶
execute(*, name, arguments)
Execute a supported LangChain tool and normalize the response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
Name of the tool to execute. |
required |
|
dict[str, Any]
|
Arguments for the tool. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Normalized response dict with keys: successful, data, error. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
is_available
staticmethod
¶
is_available()
Return True if langchain-core is importable.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if langchain-core is available, False otherwise. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
257 258 259 260 261 262 263 264 265 |
|
list_tools_for_llm
¶
list_tools_for_llm()
Return a list of function-calling formatted tool schemas.
If registry is empty and autoload is enabled, attempt to autoload a couple of common tools for convenience (tavily_search, requests_get).
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of tool schemas in function-calling format. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
register_tool
¶
register_tool(tool, *, name=None, description=None)
Register a tool instance and return the resolved name used for exposure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Any
|
Tool instance to register. |
required |
|
str | None
|
Optional override for tool name. |
None
|
|
str | None
|
Optional override for tool description. |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The resolved name used for exposure. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|
register_tools
¶
register_tools(tools)
Register multiple tool instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[Any]
|
List of tool instances to register. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of resolved names for the registered tools. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
Modules¶
composio_adapter
¶
Composio adapter for PyAgenity.
This module provides a thin wrapper around the Composio Python SDK to: - Fetch tools formatted for LLM function calling (matching ToolNode format) - Execute Composio tools directly
The dependency is optional. Install with: pip install pyagenity[composio]
Usage outline
adapter = ComposioAdapter(api_key=os.environ["COMPOSIO_API_KEY"]) # optional key result = adapter.execute( slug="GITHUB_LIST_STARGAZERS", arguments={"owner": "ComposioHQ", "repo": "composio"}, user_id="user-123", )
Classes:
Name | Description |
---|---|
ComposioAdapter |
Adapter around Composio Python SDK. |
Attributes:
Name | Type | Description |
---|---|---|
HAS_COMPOSIO |
|
|
logger |
|
Attributes¶
Classes¶
ComposioAdapter
¶
Adapter around Composio Python SDK.
Notes on SDK methods used (from docs): - composio.tools.get(user_id=..., tools=[...]/toolkits=[...]/search=..., scopes=..., limit=...) Returns tools formatted for providers or agent frameworks; includes schema. - composio.tools.get_raw_composio_tools(...) Returns raw tool schemas including input_parameters. - composio.tools.execute(slug, arguments, user_id=..., connected_account_id=..., ...) Executes a tool and returns a dict like {data, successful, error}.
Methods:
Name | Description |
---|---|
__init__ |
Initialize the ComposioAdapter. |
execute |
Execute a Composio tool and return a normalized response dict. |
is_available |
Return True if composio SDK is importable. |
list_raw_tools_for_llm |
Return raw Composio tool schemas mapped to function-calling format. |
list_tools_for_llm |
Return tools formatted for LLM function-calling. |
Source code in pyagenity/adapters/tools/composio_adapter.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
Functions¶
__init__
¶__init__(*, api_key=None, provider=None, file_download_dir=None, toolkit_versions=None)
Initialize the ComposioAdapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key
¶ |
str | None
|
Optional API key for Composio. |
None
|
provider
¶ |
Any | None
|
Optional provider integration. |
None
|
file_download_dir
¶ |
str | None
|
Directory for auto file handling. |
None
|
toolkit_versions
¶ |
Any | None
|
Toolkit version overrides. |
None
|
Raises:
Type | Description |
---|---|
ImportError
|
If composio SDK is not installed. |
Source code in pyagenity/adapters/tools/composio_adapter.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
execute
¶execute(*, slug, arguments, user_id=None, connected_account_id=None, custom_auth_params=None, custom_connection_data=None, text=None, version=None, toolkit_versions=None, modifiers=None)
Execute a Composio tool and return a normalized response dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slug
¶ |
str
|
Tool slug to execute. |
required |
arguments
¶ |
dict[str, Any]
|
Arguments for the tool. |
required |
user_id
¶ |
str | None
|
Optional user ID. |
None
|
connected_account_id
¶ |
str | None
|
Optional connected account ID. |
None
|
custom_auth_params
¶ |
dict[str, Any] | None
|
Optional custom auth params. |
None
|
custom_connection_data
¶ |
dict[str, Any] | None
|
Optional custom connection data. |
None
|
text
¶ |
str | None
|
Optional text input. |
None
|
version
¶ |
str | None
|
Optional version. |
None
|
toolkit_versions
¶ |
Any | None
|
Optional toolkit versions. |
None
|
modifiers
¶ |
Any | None
|
Optional modifiers. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Normalized response dict with keys: successful, data, error. |
Source code in pyagenity/adapters/tools/composio_adapter.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
is_available
staticmethod
¶is_available()
Return True if composio SDK is importable.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if composio SDK is available, False otherwise. |
Source code in pyagenity/adapters/tools/composio_adapter.py
83 84 85 86 87 88 89 90 91 |
|
list_raw_tools_for_llm
¶list_raw_tools_for_llm(*, tool_slugs=None, toolkits=None, search=None, scopes=None, limit=None)
Return raw Composio tool schemas mapped to function-calling format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_slugs
¶ |
list[str] | None
|
Optional list of tool slugs. |
None
|
toolkits
¶ |
list[str] | None
|
Optional list of toolkits. |
None
|
search
¶ |
str | None
|
Optional search string. |
None
|
scopes
¶ |
list[str] | None
|
Optional scopes. |
None
|
limit
¶ |
int | None
|
Optional limit on number of tools. |
None
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of raw tool schemas in function-calling format. |
Source code in pyagenity/adapters/tools/composio_adapter.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
list_tools_for_llm
¶list_tools_for_llm(*, user_id, tool_slugs=None, toolkits=None, search=None, scopes=None, limit=None)
Return tools formatted for LLM function-calling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id
¶ |
str
|
User ID for tool discovery. |
required |
tool_slugs
¶ |
list[str] | None
|
Optional list of tool slugs. |
None
|
toolkits
¶ |
list[str] | None
|
Optional list of toolkits. |
None
|
search
¶ |
str | None
|
Optional search string. |
None
|
scopes
¶ |
list[str] | None
|
Optional scopes. |
None
|
limit
¶ |
int | None
|
Optional limit on number of tools. |
None
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of tools in function-calling format. |
Source code in pyagenity/adapters/tools/composio_adapter.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
langchain_adapter
¶
LangChain adapter for PyAgenity (generic wrapper, registry-based).
This adapter mirrors the spirit of Google's ADK LangChain wrapper by allowing
you to register any LangChain tool (BaseTool/StructuredTool) or a duck-typed
object that exposes a run
/_run
method, then exposing it to PyAgenity in
the uniform function-calling schema that ToolNode
expects.
Key points:
- Register arbitrary tools at runtime via register_tool
/ register_tools
.
- Tool schemas are derived from tool.args
(when available) or inferred from
the tool's pydantic args_schema
; otherwise, we fallback to a minimal
best-effort schema inferred from the wrapped function signature.
- Execution prefers invoke
(Runnable interface) and falls back to run
/
_run
or calling a wrapped function with kwargs.
Optional install
pip install pyagenity[langchain]
Backward-compat convenience:
- For continuity with prior versions, the adapter can auto-register two common
tools (tavily_search
and requests_get
) if autoload_default_tools
is
True and no user-registered tools exist. You can disable this by passing
autoload_default_tools=False
to the constructor.
Classes:
Name | Description |
---|---|
LangChainAdapter |
Generic registry-based LangChain adapter. |
LangChainToolWrapper |
Wrap a LangChain tool or a duck-typed tool into a uniform interface. |
Attributes:
Name | Type | Description |
---|---|---|
HAS_LANGCHAIN |
|
|
logger |
|
Attributes¶
Classes¶
LangChainAdapter
¶
Generic registry-based LangChain adapter.
Notes
- Avoids importing heavy integrations until needed (lazy default autoload).
- Normalizes schemas and execution results into simple dicts.
- Allows arbitrary tool registration instead of hardcoding a tiny set.
Methods:
Name | Description |
---|---|
__init__ |
Initialize LangChainAdapter. |
execute |
Execute a supported LangChain tool and normalize the response. |
is_available |
Return True if langchain-core is importable. |
list_tools_for_llm |
Return a list of function-calling formatted tool schemas. |
register_tool |
Register a tool instance and return the resolved name used for exposure. |
register_tools |
Register multiple tool instances. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
Functions¶
__init__
¶__init__(*, autoload_default_tools=True)
Initialize LangChainAdapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
autoload_default_tools
¶ |
bool
|
Whether to autoload default tools if registry is empty. |
True
|
Raises:
Type | Description |
---|---|
ImportError
|
If langchain-core is not installed. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
execute
¶execute(*, name, arguments)
Execute a supported LangChain tool and normalize the response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
¶ |
str
|
Name of the tool to execute. |
required |
arguments
¶ |
dict[str, Any]
|
Arguments for the tool. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Normalized response dict with keys: successful, data, error. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
is_available
staticmethod
¶is_available()
Return True if langchain-core is importable.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if langchain-core is available, False otherwise. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
257 258 259 260 261 262 263 264 265 |
|
list_tools_for_llm
¶list_tools_for_llm()
Return a list of function-calling formatted tool schemas.
If registry is empty and autoload is enabled, attempt to autoload a couple of common tools for convenience (tavily_search, requests_get).
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of tool schemas in function-calling format. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
register_tool
¶register_tool(tool, *, name=None, description=None)
Register a tool instance and return the resolved name used for exposure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool
¶ |
Any
|
Tool instance to register. |
required |
name
¶ |
str | None
|
Optional override for tool name. |
None
|
description
¶ |
str | None
|
Optional override for tool description. |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The resolved name used for exposure. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|
register_tools
¶register_tools(tools)
Register multiple tool instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tools
¶ |
list[Any]
|
List of tool instances to register. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of resolved names for the registered tools. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
LangChainToolWrapper
¶
Wrap a LangChain tool or a duck-typed tool into a uniform interface.
Responsibilities
- Resolve execution entrypoint (invoke/run/_run/callable func)
- Provide a function-calling schema {name, description, parameters}
- Execute with dict arguments and return a JSON-serializable result
Methods:
Name | Description |
---|---|
__init__ |
Initialize LangChainToolWrapper. |
execute |
Execute the wrapped tool with the provided arguments. |
to_schema |
Return the function-calling schema for the wrapped tool. |
Attributes:
Name | Type | Description |
---|---|---|
description |
|
|
name |
|
Source code in pyagenity/adapters/tools/langchain_adapter.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
Attributes¶
description
instance-attribute
¶description = description or getattr(tool, 'description', None) or f'LangChain tool wrapper for {__name__}'
Functions¶
__init__
¶__init__(tool, *, name=None, description=None)
Initialize LangChainToolWrapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool
¶ |
Any
|
The LangChain tool or duck-typed object to wrap. |
required |
name
¶ |
str | None
|
Optional override for tool name. |
None
|
description
¶ |
str | None
|
Optional override for tool description. |
None
|
Source code in pyagenity/adapters/tools/langchain_adapter.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
execute
¶execute(arguments)
Execute the wrapped tool with the provided arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arguments
¶ |
dict[str, Any]
|
Arguments to pass to the tool. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Normalized response dict with keys: successful, data, error. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
to_schema
¶to_schema()
Return the function-calling schema for the wrapped tool.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
dict[str, Any]: Function-calling schema with name, description, parameters. |
Source code in pyagenity/adapters/tools/langchain_adapter.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|