This repository was archived by the owner on Oct 26, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
89 lines (71 loc) · 2.48 KB
/
Copy path__init__.py
File metadata and controls
89 lines (71 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
"""
Agent Middleware API — Framework Integrations
================================================
Integration packages for popular agent frameworks:
- LangGraph
- CrewAI
- AutoGen
- LlamaIndex
## Installation
No PyPI package is published; import this module from a checkout of the
repository after `python -m pip install -r requirements.txt`.
## Quick Start
```python
from framework_integrations import B2AClient, get_langgraph_tools, get_llamaindex_tools
# Initialize client
client = B2AClient(
api_url="http://localhost:8000",
api_key="your-api-key",
wallet_id="your-wallet-id"
)
# Get tools for your framework (async tools: drive them with ainvoke / acall)
langgraph_tools = get_langgraph_tools(client)
llamaindex_tools = get_llamaindex_tools(client)
```
`get_crewai_tools` raises `NotImplementedError`: CrewAI runs each async tool
on a fresh event loop, which the async `B2AClient` cannot survive between
calls. Use the governed `CrewAIB2ATool` in `wrappers/crewai-agent-middleware`.
## Framework-Specific Guides
See individual README files for each framework:
- README.langgraph.md
- README.crewai.md
- README.autogen.md
- README.llamaindex.md
"""
__version__ = "0.4.1"
from .client import B2AClient, B2AConfig
from .tools import (
get_langgraph_tools,
get_crewai_tools,
get_autogen_tools,
get_llamaindex_tools,
)
# Governed middleware surfaces (permit-verified in-process validation over the
# b2a_sdk governed loop). Exported lazily via PEP 562 so importing this
# package keeps working when the b2a_sdk sources are not on the path (the
# legacy client/tools above need only httpx) — and the middleware modules
# themselves import pydantic_ai / langgraph only inside their as_*_tool
# functions, so neither framework needs to be installed either.
_LAZY_ATTRS = {
"LangGraphGovernedTools": "langgraph_middleware",
"PydanticAIGovernedTools": "pydantic_ai_middleware",
}
def __getattr__(name):
module_name = _LAZY_ATTRS.get(name)
if module_name is None:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
import importlib
module = importlib.import_module(f".{module_name}", __name__)
value = getattr(module, name)
globals()[name] = value # cache so later access is a plain attribute lookup
return value
__all__ = [
"B2AClient",
"B2AConfig",
"LangGraphGovernedTools",
"PydanticAIGovernedTools",
"get_langgraph_tools",
"get_crewai_tools",
"get_autogen_tools",
"get_llamaindex_tools",
]