copilotkit 0.1.75a3__py3-none-any.whl → 0.1.75a5__py3-none-any.whl
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/__init__.py +2 -2
- copilotkit/copilotkit_lg_middleware.py +26 -9
- {copilotkit-0.1.75a3.dist-info → copilotkit-0.1.75a5.dist-info}/METADATA +1 -1
- {copilotkit-0.1.75a3.dist-info → copilotkit-0.1.75a5.dist-info}/RECORD +5 -5
- {copilotkit-0.1.75a3.dist-info → copilotkit-0.1.75a5.dist-info}/WHEEL +0 -0
copilotkit/__init__.py
CHANGED
|
@@ -6,7 +6,7 @@ from .parameter import Parameter
|
|
|
6
6
|
from .agent import Agent
|
|
7
7
|
from .langgraph_agent import LangGraphAgent
|
|
8
8
|
from .langgraph_agui_agent import LangGraphAGUIAgent
|
|
9
|
-
from .copilotkit_lg_middleware import
|
|
9
|
+
from .copilotkit_lg_middleware import CopilotKitMiddleware
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -22,5 +22,5 @@ __all__ = [
|
|
|
22
22
|
'CrewAIAgent', # pyright: ignore[reportUnsupportedDunderAll] pylint: disable=undefined-all-variable
|
|
23
23
|
'LangGraphAgent', # pyright: ignore[reportUnsupportedDunderAll] pylint: disable=undefined-all-variable
|
|
24
24
|
"LangGraphAGUIAgent",
|
|
25
|
-
"
|
|
25
|
+
"CopilotKitMiddleware"
|
|
26
26
|
]
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"""
|
|
2
|
+
CopilotKit Middleware for LangGraph agents.
|
|
3
|
+
|
|
4
|
+
Works with any agent (prebuilt or custom).
|
|
5
|
+
|
|
6
|
+
Example:
|
|
7
|
+
from langchain.agents import create_agent
|
|
8
|
+
from copilotkit import CopilotKitMiddleware
|
|
9
|
+
|
|
10
|
+
agent = create_agent(
|
|
11
|
+
model="openai:gpt-4o",
|
|
12
|
+
tools=[backend_tool],
|
|
13
|
+
middleware=[CopilotKitMiddleware()],
|
|
14
|
+
)
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Any, Callable, Awaitable, ClassVar, List
|
|
18
|
+
from typing_extensions import NotRequired
|
|
3
19
|
|
|
4
20
|
from langchain_core.messages import AIMessage
|
|
5
21
|
from langchain.agents.middleware import (
|
|
@@ -10,8 +26,9 @@ from langchain.agents.middleware import (
|
|
|
10
26
|
)
|
|
11
27
|
from langgraph.runtime import Runtime
|
|
12
28
|
|
|
29
|
+
from .langgraph import CopilotContextItem
|
|
13
30
|
|
|
14
|
-
class CopilotKitState
|
|
31
|
+
class CopilotKitState:
|
|
15
32
|
"""Extended state schema for CopilotKit middleware."""
|
|
16
33
|
|
|
17
34
|
# CopilotKit frontend tools passed via state
|
|
@@ -21,6 +38,9 @@ class CopilotKitState(AgentState):
|
|
|
21
38
|
# Private state for CopilotKit middleware
|
|
22
39
|
copilotkit: NotRequired[dict[str, Any]]
|
|
23
40
|
|
|
41
|
+
class StateSchema(AgentState):
|
|
42
|
+
copilotkit: CopilotKitState
|
|
43
|
+
|
|
24
44
|
|
|
25
45
|
class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
26
46
|
"""CopilotKit Middleware for LangGraph agents.
|
|
@@ -29,7 +49,7 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
29
49
|
"""
|
|
30
50
|
|
|
31
51
|
state_schema = CopilotKitState
|
|
32
|
-
tools = []
|
|
52
|
+
tools: ClassVar[list] = []
|
|
33
53
|
|
|
34
54
|
@property
|
|
35
55
|
def name(self) -> str:
|
|
@@ -41,7 +61,7 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
41
61
|
request: ModelRequest,
|
|
42
62
|
handler: Callable[[ModelRequest], ModelResponse],
|
|
43
63
|
) -> ModelResponse:
|
|
44
|
-
frontend_tools = request.state.get("copilotkit", {}).get("
|
|
64
|
+
frontend_tools = request.state.get("copilotkit", {}).get("actions", [])
|
|
45
65
|
|
|
46
66
|
if not frontend_tools:
|
|
47
67
|
return handler(request)
|
|
@@ -56,7 +76,7 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
56
76
|
request: ModelRequest,
|
|
57
77
|
handler: Callable[[ModelRequest], Awaitable[ModelResponse]],
|
|
58
78
|
) -> ModelResponse:
|
|
59
|
-
frontend_tools = request.state.get("copilotkit", {}).get("
|
|
79
|
+
frontend_tools = request.state.get("copilotkit", {}).get("actions", [])
|
|
60
80
|
|
|
61
81
|
if not frontend_tools:
|
|
62
82
|
return await handler(request)
|
|
@@ -172,6 +192,3 @@ class CopilotKitMiddleware(AgentMiddleware[CopilotKitState, Any]):
|
|
|
172
192
|
# Delegate to sync implementation
|
|
173
193
|
return self.after_agent(state, runtime)
|
|
174
194
|
|
|
175
|
-
|
|
176
|
-
# Pre-created instance for convenience
|
|
177
|
-
copilotkit_middleware = CopilotKitMiddleware()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
copilotkit/__init__.py,sha256=
|
|
1
|
+
copilotkit/__init__.py,sha256=22bUXudklMop9r1DYkecCaTiHbj_m0Wf4txOU-yfSI4,859
|
|
2
2
|
copilotkit/action.py,sha256=bg_bPusEfN8TMQV1B3lVyMLbHyLn1E7yVYAvfE2_PXA,1691
|
|
3
3
|
copilotkit/agent.py,sha256=e-jPsUQo18FOYUPdE3YNmSLcb5FEfWL6ARScOntyvb8,1663
|
|
4
|
-
copilotkit/copilotkit_lg_middleware.py,sha256=
|
|
4
|
+
copilotkit/copilotkit_lg_middleware.py,sha256=LlLlRxX9ws8JDRJAALPnRJVi1-0nBEcRBeO-w0WuixE,5859
|
|
5
5
|
copilotkit/crewai/__init__.py,sha256=RAkBTwDpFuvD5prULUnoWdl5d8W373cm1ZlqOMeSGbY,1034
|
|
6
6
|
copilotkit/crewai/copilotkit_integration.py,sha256=vd1LVhXo-cpA4PQ_-cZHdKgm67MvrHpx4VJweUvCzPE,14550
|
|
7
7
|
copilotkit/crewai/crewai_agent.py,sha256=maoMnl0WIHUnFAK5ALUKD9z0GvjtfNGi31zi37LyyaE,15323
|
|
@@ -21,6 +21,6 @@ copilotkit/runloop.py,sha256=9pBqWeu4QCRPOizz00se1d0_BvCX3ZIABzNeiXhdyNM,10641
|
|
|
21
21
|
copilotkit/sdk.py,sha256=VEQqA9QAXJS5MDLxtJJdtfrApX9EawCHzp-IXnat5vw,11882
|
|
22
22
|
copilotkit/types.py,sha256=_YQluiHpJGGXYB4eWLk0EocDZp5C8rs3ZsMNFhmXEYU,972
|
|
23
23
|
copilotkit/utils.py,sha256=rOAaaFBXgb3iv_cLH9S2steyGwHmnTjaxQTA53qdtQo,203
|
|
24
|
-
copilotkit-0.1.
|
|
25
|
-
copilotkit-0.1.
|
|
26
|
-
copilotkit-0.1.
|
|
24
|
+
copilotkit-0.1.75a5.dist-info/METADATA,sha256=mCEps29kaADNPa1eQwgUtfhn1UpO0L-eY4Mgly9J2VU,2606
|
|
25
|
+
copilotkit-0.1.75a5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
26
|
+
copilotkit-0.1.75a5.dist-info/RECORD,,
|
|
File without changes
|