copilotkit 0.1.75a6__tar.gz → 0.1.75a8__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.75a6 → copilotkit-0.1.75a8}/PKG-INFO +1 -1
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/copilotkit_lg_middleware.py +9 -21
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/langgraph.py +4 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/pyproject.toml +1 -1
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/README.md +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/__init__.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/action.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/agent.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/crewai/__init__.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/crewai/copilotkit_integration.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/crewai/crewai_agent.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/crewai/crewai_sdk.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/exc.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/html.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/integrations/__init__.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/integrations/fastapi.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/langchain.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/langgraph_agent.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/langgraph_agui_agent.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/logging.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/parameter.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/protocol.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/runloop.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/sdk.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/types.py +0 -0
- {copilotkit-0.1.75a6 → copilotkit-0.1.75a8}/copilotkit/utils.py +0 -0
|
@@ -25,30 +25,19 @@ from langchain.agents.middleware import (
|
|
|
25
25
|
)
|
|
26
26
|
from langgraph.runtime import Runtime
|
|
27
27
|
|
|
28
|
-
from .langgraph import
|
|
29
|
-
|
|
30
|
-
class CopilotKitState:
|
|
31
|
-
"""Extended state schema for CopilotKit middleware."""
|
|
32
|
-
|
|
33
|
-
# CopilotKit frontend tools passed via state
|
|
34
|
-
actions: List[Any]
|
|
35
|
-
context: List[CopilotContextItem]
|
|
36
|
-
|
|
37
|
-
# Private state for CopilotKit middleware
|
|
38
|
-
intercepted_tool_calls: Any
|
|
39
|
-
original_ai_message_id: Any
|
|
28
|
+
from .langgraph import CopilotKitProperties
|
|
40
29
|
|
|
41
30
|
class StateSchema(AgentState):
|
|
42
|
-
copilotkit:
|
|
31
|
+
copilotkit: CopilotKitProperties
|
|
43
32
|
|
|
44
33
|
|
|
45
|
-
class CopilotKitMiddleware(AgentMiddleware[
|
|
34
|
+
class CopilotKitMiddleware(AgentMiddleware[StateSchema, Any]):
|
|
46
35
|
"""CopilotKit Middleware for LangGraph agents.
|
|
47
36
|
|
|
48
37
|
Handles frontend tool injection and interception for CopilotKit.
|
|
49
38
|
"""
|
|
50
39
|
|
|
51
|
-
state_schema =
|
|
40
|
+
state_schema = StateSchema
|
|
52
41
|
tools: ClassVar[list] = []
|
|
53
42
|
|
|
54
43
|
@property
|
|
@@ -77,7 +66,6 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
77
66
|
handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
|
|
78
67
|
) -> ModelResponse:
|
|
79
68
|
frontend_tools = request.state.get("copilotkit", {}).get("actions", [])
|
|
80
|
-
print(request.state)
|
|
81
69
|
|
|
82
70
|
if not frontend_tools:
|
|
83
71
|
return await handler(request)
|
|
@@ -90,10 +78,10 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
90
78
|
# Intercept frontend tool calls after model returns, before ToolNode executes
|
|
91
79
|
def after_model(
|
|
92
80
|
self,
|
|
93
|
-
state:
|
|
81
|
+
state: StateSchema,
|
|
94
82
|
runtime: Runtime[Any],
|
|
95
83
|
) -> dict[str, Any] | None:
|
|
96
|
-
frontend_tools = state.get("copilotkit", {}).get("
|
|
84
|
+
frontend_tools = state.get("copilotkit", {}).get("actions", [])
|
|
97
85
|
if not frontend_tools:
|
|
98
86
|
return None
|
|
99
87
|
|
|
@@ -144,7 +132,7 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
144
132
|
|
|
145
133
|
async def aafter_model(
|
|
146
134
|
self,
|
|
147
|
-
state:
|
|
135
|
+
state: StateSchema,
|
|
148
136
|
runtime: Runtime[Any],
|
|
149
137
|
) -> dict[str, Any] | None:
|
|
150
138
|
# Delegate to sync implementation
|
|
@@ -153,7 +141,7 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
153
141
|
# Restore frontend tool calls to AIMessage before agent exits
|
|
154
142
|
def after_agent(
|
|
155
143
|
self,
|
|
156
|
-
state:
|
|
144
|
+
state: StateSchema,
|
|
157
145
|
runtime: Runtime[Any],
|
|
158
146
|
) -> dict[str, Any] | None:
|
|
159
147
|
copilotkit_state = state.get("copilotkit", {})
|
|
@@ -187,7 +175,7 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
187
175
|
|
|
188
176
|
async def aafter_agent(
|
|
189
177
|
self,
|
|
190
|
-
state:
|
|
178
|
+
state: StateSchema,
|
|
191
179
|
runtime: Runtime[Any],
|
|
192
180
|
) -> dict[str, Any] | None:
|
|
193
181
|
# Delegate to sync implementation
|
|
@@ -37,6 +37,10 @@ class CopilotKitProperties(TypedDict):
|
|
|
37
37
|
actions: List[Any]
|
|
38
38
|
context: List[CopilotContextItem]
|
|
39
39
|
|
|
40
|
+
# Private state for CopilotKit middleware
|
|
41
|
+
intercepted_tool_calls: Any
|
|
42
|
+
original_ai_message_id: Any
|
|
43
|
+
|
|
40
44
|
class CopilotKitState(MessagesState):
|
|
41
45
|
"""CopilotKit state"""
|
|
42
46
|
copilotkit: CopilotKitProperties
|
|
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
|