copilotkit 0.1.75a3__tar.gz → 0.1.75a5__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.
Files changed (26) hide show
  1. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/PKG-INFO +1 -1
  2. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/__init__.py +2 -2
  3. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/copilotkit_lg_middleware.py +26 -9
  4. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/pyproject.toml +1 -1
  5. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/README.md +0 -0
  6. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/action.py +0 -0
  7. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/agent.py +0 -0
  8. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/crewai/__init__.py +0 -0
  9. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/crewai/copilotkit_integration.py +0 -0
  10. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/crewai/crewai_agent.py +0 -0
  11. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/crewai/crewai_sdk.py +0 -0
  12. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/exc.py +0 -0
  13. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/html.py +0 -0
  14. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/integrations/__init__.py +0 -0
  15. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/integrations/fastapi.py +0 -0
  16. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/langchain.py +0 -0
  17. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/langgraph.py +0 -0
  18. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/langgraph_agent.py +0 -0
  19. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/langgraph_agui_agent.py +0 -0
  20. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/logging.py +0 -0
  21. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/parameter.py +0 -0
  22. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/protocol.py +0 -0
  23. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/runloop.py +0 -0
  24. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/sdk.py +0 -0
  25. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/types.py +0 -0
  26. {copilotkit-0.1.75a3 → copilotkit-0.1.75a5}/copilotkit/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: copilotkit
3
- Version: 0.1.75a3
3
+ Version: 0.1.75a5
4
4
  Summary: CopilotKit python SDK
5
5
  License: MIT
6
6
  Keywords: copilot,copilotkit,langgraph,langchain,ai,langsmith,langserve
@@ -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 copilotkit_middleware
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
- "copilotkit_middleware"
25
+ "CopilotKitMiddleware"
26
26
  ]
@@ -1,5 +1,21 @@
1
- from typing import Any, Callable, Awaitable, Annotated
2
- from typing_extensions import TypedDict, NotRequired
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(AgentState):
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("tools", [])
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("tools", [])
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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "copilotkit"
3
- version = "0.1.75-alpha.3"
3
+ version = "0.1.75-alpha.5"
4
4
  description = "CopilotKit python SDK"
5
5
  authors = ["Markus Ecker <markus.ecker@gmail.com>"]
6
6
  license = "MIT"
File without changes