chatomon.connectors.adk
¶
Build an atom into a native Google ADK application.
Install with pip install 'chatomon[adk]'.
Classes:
| Name | Description |
|---|---|
ADKConnector |
Builds an atom into a native |
ADKConnector
¶
ADKConnector(
model: str | BaseLlm,
*,
resolve_model: (
Callable[[str], BaseLlm | str] | None
) = None,
app_kwargs: Mapping[str, Any] | None = None,
**agent_kwargs: Any
)
Bases: Connector['App']
Builds an atom into a native google.adk.apps.App.
The app's root agent is the nucleus, an LlmAgent, and its first plugin is
chatomon's; your own plugins come after it. Run the app with ADK's own
Runner(app=app, ...), adk web or adk run: the agent refuses to run
outside it. The id of the ADK session is the conversation id.
When the atom has output orbitals the nucleus is called without streaming, so a caller that asks for streaming receives each reply whole, once it is checked. Live runs are refused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str | BaseLlm
|
The nucleus model: an ADK |
required |
resolve_model
|
Callable[[str], BaseLlm | str] | None
|
Maps the model id of a JudgeOrbital to an ADK model or to a model name; by default the id is a name for the registry. |
None
|
app_kwargs
|
Mapping[str, Any] | None
|
Passed to |
None
|
**agent_kwargs
|
Any
|
Passed to |
{}
|
Raises:
| Type | Description |
|---|---|
ChatomonConfigError
|
If an argument is set by chatomon from the atom
( |
Examples:
import asyncio
from google.adk.runners import InMemoryRunner
from chatomon import Atom
from chatomon.connectors.adk import ADKConnector
async def main() -> None:
app = Atom(
name="speedypack",
instructions="You are the customer assistant of SpeedyPack.",
connector=ADKConnector("gemini-3.5-flash"),
).build()
runner = InMemoryRunner(app=app)
events = await runner.run_debug("Hello", quiet=True)
print(events[-1].content.parts[0].text)
asyncio.run(main())
Methods:
| Name | Description |
|---|---|
build |
Build the native app with chatomon's plugin and the nucleus as its root agent. |
generate_structured |
Make one structured call straight to an ADK model, with no agent or session. |
Source code in src/chatomon/connectors/adk.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
build
¶
Build the native app with chatomon's plugin and the nucleus as its root agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom
|
Atom[App]
|
The validated atom. |
required |
engine
|
Engine
|
The engine that runs the atom's orbitals. |
required |
Returns:
| Type | Description |
|---|---|
App
|
A |
Raises:
| Type | Description |
|---|---|
ChatomonConfigError
|
If the atom's name is not a valid ADK agent name, or ADK's registry does not know the model's name. |
Source code in src/chatomon/connectors/adk.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
generate_structured
async
¶
Make one structured call straight to an ADK model, with no agent or session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
Model id; passed through |
required |
system
|
str
|
System instruction. |
required |
prompt
|
str
|
User prompt. |
required |
schema
|
type[ModelT]
|
Output type. |
required |
Returns:
| Type | Description |
|---|---|
ModelT
|
The validated output. |
Raises:
| Type | Description |
|---|---|
ChatomonConfigError
|
If the model id resolves to no ADK model. |
ValueError
|
If the model returned an error or no text, or text that
does not match |
Source code in src/chatomon/connectors/adk.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |