copilotkit 0.1.89a0__tar.gz → 0.1.91__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 (31) hide show
  1. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/PKG-INFO +2 -2
  2. copilotkit-0.1.91/copilotkit/__init__.py +43 -0
  3. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/a2ui.py +4 -6
  4. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/action.py +20 -20
  5. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/agent.py +14 -14
  6. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/copilotkit_lg_middleware.py +286 -203
  7. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/crewai/__init__.py +4 -2
  8. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/crewai/copilotkit_integration.py +134 -56
  9. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/crewai/crewai_agent.py +124 -108
  10. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/crewai/crewai_sdk.py +142 -144
  11. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/exc.py +4 -0
  12. copilotkit-0.1.91/copilotkit/header_propagation.py +59 -0
  13. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/html.py +3 -1
  14. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/integrations/fastapi.py +76 -71
  15. copilotkit-0.1.91/copilotkit/langchain.py +30 -0
  16. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/langgraph.py +84 -77
  17. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/langgraph_agui_agent.py +50 -24
  18. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/logging.py +4 -2
  19. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/parameter.py +23 -15
  20. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/protocol.py +81 -44
  21. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/runloop.py +37 -41
  22. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/sdk.py +27 -32
  23. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/types.py +15 -1
  24. copilotkit-0.1.91/copilotkit/utils.py +5 -0
  25. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/pyproject.toml +1 -1
  26. copilotkit-0.1.89a0/copilotkit/__init__.py +0 -27
  27. copilotkit-0.1.89a0/copilotkit/langchain.py +0 -29
  28. copilotkit-0.1.89a0/copilotkit/utils.py +0 -8
  29. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/README.md +0 -0
  30. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/integrations/__init__.py +0 -0
  31. {copilotkit-0.1.89a0 → copilotkit-0.1.91}/copilotkit/py.typed +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: copilotkit
3
- Version: 0.1.89a0
3
+ Version: 0.1.91
4
4
  Summary: CopilotKit python SDK
5
5
  License: MIT
6
6
  Keywords: copilot,copilotkit,langgraph,langchain,ai,langsmith,langserve
@@ -0,0 +1,43 @@
1
+ """CopilotKit SDK"""
2
+
3
+ from .sdk import (
4
+ CopilotKitRemoteEndpoint,
5
+ CopilotKitContext,
6
+ CopilotKitSDK,
7
+ CopilotKitSDKContext,
8
+ )
9
+ from .action import Action
10
+ from .langgraph import CopilotKitState
11
+ from .parameter import Parameter
12
+ from .agent import Agent
13
+ from .langgraph_agui_agent import LangGraphAGUIAgent
14
+ from .copilotkit_lg_middleware import CopilotKitMiddleware
15
+ from ag_ui_langgraph.middlewares.state_streaming import (
16
+ StateStreamingMiddleware,
17
+ StateItem,
18
+ )
19
+ from .header_propagation import (
20
+ set_forwarded_headers,
21
+ get_forwarded_headers,
22
+ install_httpx_hook,
23
+ )
24
+
25
+
26
+ __all__ = [
27
+ "CopilotKitRemoteEndpoint",
28
+ "CopilotKitSDK",
29
+ "Action",
30
+ "CopilotKitState",
31
+ "Parameter",
32
+ "Agent",
33
+ "CopilotKitContext",
34
+ "CopilotKitSDKContext",
35
+ "CrewAIAgent", # pyright: ignore[reportUnsupportedDunderAll] pylint: disable=undefined-all-variable
36
+ "LangGraphAGUIAgent",
37
+ "CopilotKitMiddleware",
38
+ "StateStreamingMiddleware",
39
+ "StateItem",
40
+ "set_forwarded_headers",
41
+ "get_forwarded_headers",
42
+ "install_httpx_hook",
43
+ ]
@@ -38,7 +38,7 @@ def update_components(
38
38
  "updateComponents": {
39
39
  "surfaceId": surface_id,
40
40
  "components": components,
41
- }
41
+ },
42
42
  }
43
43
 
44
44
 
@@ -54,7 +54,7 @@ def update_data_model(
54
54
  "surfaceId": surface_id,
55
55
  "path": path,
56
56
  "value": data,
57
- }
57
+ },
58
58
  }
59
59
 
60
60
 
@@ -72,7 +72,7 @@ def create_surface(
72
72
  "createSurface": {
73
73
  "surfaceId": surface_id,
74
74
  "catalogId": catalog_id,
75
- }
75
+ },
76
76
  }
77
77
 
78
78
 
@@ -80,9 +80,7 @@ A2UI_OPERATIONS_KEY = "a2ui_operations"
80
80
  """The container key used to wrap A2UI operations for explicit detection."""
81
81
 
82
82
 
83
- def render(
84
- operations: list[dict[str, Any]]
85
- ) -> str:
83
+ def render(operations: list[dict[str, Any]]) -> str:
86
84
  """Wrap operations in the a2ui_operations container and serialize to JSON.
87
85
 
88
86
  Args:
@@ -5,26 +5,32 @@ from inspect import iscoroutinefunction
5
5
  from typing import Optional, List, Callable, TypedDict, Any, cast
6
6
  from .parameter import Parameter, normalize_parameters
7
7
 
8
+
8
9
  class ActionDict(TypedDict):
9
10
  """Dict representation of an action"""
11
+
10
12
  name: str
11
13
  description: str
12
14
  parameters: List[Parameter]
13
15
 
16
+
14
17
  class ActionResultDict(TypedDict):
15
18
  """Dict representation of an action result"""
19
+
16
20
  result: Any
17
21
 
22
+
18
23
  class Action: # pylint: disable=too-few-public-methods
19
24
  """Action class for CopilotKit"""
25
+
20
26
  def __init__(
21
- self,
22
- *,
23
- name: str,
24
- handler: Callable,
25
- description: Optional[str] = None,
26
- parameters: Optional[List[Parameter]] = None,
27
- ):
27
+ self,
28
+ *,
29
+ name: str,
30
+ handler: Callable,
31
+ description: Optional[str] = None,
32
+ parameters: Optional[List[Parameter]] = None,
33
+ ):
28
34
  self.name = name
29
35
  self.description = description
30
36
  self.parameters = parameters
@@ -32,26 +38,20 @@ class Action: # pylint: disable=too-few-public-methods
32
38
 
33
39
  if not re.match(r"^[a-zA-Z0-9_-]+$", name):
34
40
  raise ValueError(
35
- f"Invalid action name '{name}': " +
36
- "must consist of alphanumeric characters, underscores, and hyphens only"
41
+ f"Invalid action name '{name}': "
42
+ + "must consist of alphanumeric characters, underscores, and hyphens only"
37
43
  )
38
44
 
39
- async def execute(
40
- self,
41
- *,
42
- arguments: dict
43
- ) -> ActionResultDict:
45
+ async def execute(self, *, arguments: dict) -> ActionResultDict:
44
46
  """Execute the action"""
45
47
  result = self.handler(**arguments)
46
48
 
47
- return {
48
- "result": await result if iscoroutinefunction(self.handler) else result
49
- }
49
+ return {"result": await result if iscoroutinefunction(self.handler) else result}
50
50
 
51
51
  def dict_repr(self) -> ActionDict:
52
52
  """Dict representation of the action"""
53
53
  return {
54
- 'name': self.name,
55
- 'description': self.description or '',
56
- 'parameters': normalize_parameters(cast(Any, self.parameters)),
54
+ "name": self.name,
55
+ "description": self.description or "",
56
+ "parameters": normalize_parameters(cast(Any, self.parameters)),
57
57
  }
@@ -7,30 +7,34 @@ from .types import Message
7
7
  from .action import ActionDict
8
8
  from .types import MetaEvent
9
9
 
10
+
10
11
  class AgentDict(TypedDict):
11
12
  """Agent dictionary"""
13
+
12
14
  name: str
13
15
  description: Optional[str]
14
16
 
17
+
15
18
  class Agent(ABC):
16
19
  """Agent class for CopilotKit"""
20
+
17
21
  def __init__(
18
- self,
19
- *,
20
- name: str,
21
- description: Optional[str] = None,
22
- ):
22
+ self,
23
+ *,
24
+ name: str,
25
+ description: Optional[str] = None,
26
+ ):
23
27
  self.name = name
24
28
  self.description = description
25
29
 
26
30
  if not re.match(r"^[a-zA-Z0-9_-]+$", name):
27
31
  raise ValueError(
28
- f"Invalid agent name '{name}': " +
29
- "must consist of alphanumeric characters, underscores, and hyphens only"
32
+ f"Invalid agent name '{name}': "
33
+ + "must consist of alphanumeric characters, underscores, and hyphens only"
30
34
  )
31
35
 
32
36
  @abstractmethod
33
- def execute( # pylint: disable=too-many-arguments
37
+ def execute( # pylint: disable=too-many-arguments
34
38
  self,
35
39
  *,
36
40
  state: dict,
@@ -54,13 +58,9 @@ class Agent(ABC):
54
58
  "threadId": thread_id or "",
55
59
  "threadExists": False,
56
60
  "state": {},
57
- "messages": []
61
+ "messages": [],
58
62
  }
59
63
 
60
-
61
64
  def dict_repr(self) -> AgentDict:
62
65
  """Dict representation of the action"""
63
- return {
64
- 'name': self.name,
65
- 'description': self.description or ''
66
- }
66
+ return {"name": self.name, "description": self.description or ""}