copilotkit 0.1.95a2__tar.gz → 0.1.95a4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/PKG-INFO +1 -1
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/copilotkit_lg_middleware.py +36 -6
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/pyproject.toml +1 -1
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/README.md +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/__init__.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/a2ui.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/action.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/agent.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/crewai/__init__.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/crewai/copilotkit_integration.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/crewai/crewai_agent.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/crewai/crewai_sdk.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/exc.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/header_propagation.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/html.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/integrations/__init__.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/integrations/fastapi.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/langchain.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/langgraph.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/langgraph_agui_agent.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/logging.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/parameter.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/protocol.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/py.typed +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/runloop.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/sdk.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/types.py +0 -0
- {copilotkit-0.1.95a2 → copilotkit-0.1.95a4}/copilotkit/utils.py +0 -0
|
@@ -16,7 +16,7 @@ Example:
|
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
18
|
import re
|
|
19
|
-
from typing import Any, Callable, Awaitable, ClassVar, Iterable, Union
|
|
19
|
+
from typing import Any, Callable, Awaitable, ClassVar, Iterable, Optional, Union
|
|
20
20
|
|
|
21
21
|
from langchain_core.messages import AIMessage, SystemMessage, ToolMessage
|
|
22
22
|
from langchain.agents.middleware import (
|
|
@@ -189,6 +189,9 @@ class StateSchema(AgentState):
|
|
|
189
189
|
copilotkit: CopilotKitProperties
|
|
190
190
|
|
|
191
191
|
|
|
192
|
+
StateSchema.__annotations__["ag-ui"] = CopilotKitProperties
|
|
193
|
+
|
|
194
|
+
|
|
192
195
|
# Internal/framework keys that should never be surfaced to the LLM as
|
|
193
196
|
# user-facing state. These are either reducer-managed message buckets,
|
|
194
197
|
# CopilotKit/AG-UI plumbing, or graph-internal scaffolding.
|
|
@@ -231,6 +234,20 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
|
|
|
231
234
|
- ``list``/``tuple``/``set[str]`` — only surface the named keys.
|
|
232
235
|
Use this when you want explicit control over what the LLM
|
|
233
236
|
sees (e.g. ``["liked", "todos"]``).
|
|
237
|
+
a2ui_params: Optional host overrides for the auto-injected
|
|
238
|
+
``generate_a2ui`` tool, forwarded to ``get_a2ui_tools`` when A2UI
|
|
239
|
+
injection fires. An ``A2UIToolParams``-shaped dict: ``guidelines``
|
|
240
|
+
(``generation_guidelines`` / ``design_guidelines`` /
|
|
241
|
+
``composition_guide``), ``default_catalog_id``,
|
|
242
|
+
``default_surface_id``, ``tool_name``, ``recovery``, etc. Lets a
|
|
243
|
+
host steer the subagent (e.g. override the default design
|
|
244
|
+
guidelines to favor a repeating-card layout) on the auto-inject
|
|
245
|
+
path, which otherwise only ever uses the toolkit defaults.
|
|
246
|
+
|
|
247
|
+
The middleware always injects ``model`` from the bound request
|
|
248
|
+
model (the host cannot supply the live, header-hooked model), and
|
|
249
|
+
folds the registered catalog id + component schema into the params
|
|
250
|
+
unless the host already set them — so host values win.
|
|
234
251
|
"""
|
|
235
252
|
|
|
236
253
|
state_schema = StateSchema
|
|
@@ -240,12 +257,18 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
|
|
|
240
257
|
self,
|
|
241
258
|
*,
|
|
242
259
|
expose_state: Union[bool, Iterable[str]] = False,
|
|
260
|
+
a2ui_params: "Optional[A2UIToolParams]" = None,
|
|
243
261
|
):
|
|
244
262
|
super().__init__()
|
|
245
263
|
if isinstance(expose_state, bool):
|
|
246
264
|
self._expose_state: Union[bool, frozenset[str]] = expose_state
|
|
247
265
|
else:
|
|
248
266
|
self._expose_state = frozenset(expose_state)
|
|
267
|
+
# Host-supplied A2UI tool overrides (guidelines, catalog id, tool name,
|
|
268
|
+
# recovery, ...). Copied so later mutation of the caller's dict can't
|
|
269
|
+
# bleed into the middleware. ``model`` + the registered catalog are
|
|
270
|
+
# layered in at build time; everything here is host-owned and wins.
|
|
271
|
+
self._a2ui_params: dict = dict(a2ui_params or {})
|
|
249
272
|
|
|
250
273
|
@property
|
|
251
274
|
def name(self) -> str:
|
|
@@ -422,15 +445,22 @@ class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
|
|
|
422
445
|
component_schema, catalog_id = resolved if resolved else (None, None)
|
|
423
446
|
|
|
424
447
|
# Shared A2UIToolParams: a single params object owned by the toolkit.
|
|
425
|
-
#
|
|
426
|
-
#
|
|
427
|
-
|
|
428
|
-
|
|
448
|
+
# Start from the host overrides (guidelines / catalog id / tool name /
|
|
449
|
+
# recovery) so a host can steer the subagent, then layer in only what
|
|
450
|
+
# the host cannot know — the bound model, and the registered catalog id
|
|
451
|
+
# + component schema — without clobbering any host-set value.
|
|
452
|
+
params: "A2UIToolParams" = dict(self._a2ui_params)
|
|
453
|
+
params["model"] = request.model
|
|
454
|
+
if catalog_id and "default_catalog_id" not in params:
|
|
429
455
|
params["default_catalog_id"] = catalog_id
|
|
430
456
|
# Feed the registered component schema to the subagent so it composes
|
|
431
457
|
# only catalog components (the toolkit appends this to its prompt).
|
|
458
|
+
# Merge into any host ``guidelines`` bag; a host-set composition_guide
|
|
459
|
+
# wins, and host generation/design overrides are preserved.
|
|
432
460
|
if component_schema:
|
|
433
|
-
params
|
|
461
|
+
guidelines = dict(params.get("guidelines") or {})
|
|
462
|
+
guidelines.setdefault("composition_guide", component_schema)
|
|
463
|
+
params["guidelines"] = guidelines
|
|
434
464
|
|
|
435
465
|
tool = get_a2ui_tools(params)
|
|
436
466
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|