composio-langgraph 0.5.31__tar.gz → 0.10.3__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.
@@ -1,17 +1,21 @@
1
- Metadata-Version: 2.1
2
- Name: composio_langgraph
3
- Version: 0.5.31
4
- Summary: Use Composio to get array of tools with LnagGraph Agent Workflows
1
+ Metadata-Version: 2.4
2
+ Name: composio-langgraph
3
+ Version: 0.10.3
4
+ Summary: Use Composio to get array of tools with LangGraph Agent Workflows.
5
5
  Home-page: https://github.com/ComposioHQ/composio
6
- Author: Sawradip
7
- Author-email: sawradip@composio.dev
6
+ Author: composio
7
+ Author-email: Composio <tech@composio.dev>
8
+ Project-URL: Homepage, https://github.com/ComposioHQ/composio
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: License :: OSI Approved :: Apache Software License
10
11
  Classifier: Operating System :: OS Independent
11
12
  Requires-Python: >=3.9,<4
12
13
  Description-Content-Type: text/markdown
13
- Requires-Dist: composio_langchain<=0.5.31,>=0.5.30
14
14
  Requires-Dist: langgraph
15
+ Requires-Dist: composio
16
+ Dynamic: author
17
+ Dynamic: home-page
18
+ Dynamic: requires-python
15
19
 
16
20
  ## 🦜🕸️ Using Composio With LangGraph
17
21
 
@@ -0,0 +1,3 @@
1
+ from .provider import LanggraphProvider
2
+
3
+ __all__ = ("LanggraphProvider",)
@@ -0,0 +1,93 @@
1
+ """ComposioLangChain class definition"""
2
+
3
+ import types
4
+ import typing as t
5
+ from inspect import Signature
6
+
7
+ import pydantic
8
+ from langchain_core.tools import StructuredTool as BaseStructuredTool
9
+
10
+ from composio.core.provider import AgenticProvider, AgenticProviderExecuteFn
11
+ from composio.types import Tool
12
+ from composio.utils.pydantic import parse_pydantic_error
13
+ from composio.utils.shared import (
14
+ get_signature_format_from_schema_params,
15
+ json_schema_to_model,
16
+ )
17
+
18
+
19
+ class StructuredTool(BaseStructuredTool): # type: ignore[misc]
20
+ def run(self, *args, **kwargs):
21
+ try:
22
+ return super().run(*args, **kwargs)
23
+ except pydantic.ValidationError as e:
24
+ return {"successful": False, "error": parse_pydantic_error(e), "data": None}
25
+
26
+
27
+ class LanggraphProvider(
28
+ AgenticProvider[StructuredTool, t.List[StructuredTool]],
29
+ name="langgraph",
30
+ ):
31
+ """
32
+ Composio toolset for Langchain framework.
33
+ """
34
+
35
+ def _wrap_action(
36
+ self,
37
+ tool: str,
38
+ description: str,
39
+ schema_params: t.Dict,
40
+ execute_tool: AgenticProviderExecuteFn,
41
+ ):
42
+ def function(**kwargs: t.Any) -> t.Dict:
43
+ """Wrapper function for composio action."""
44
+ return execute_tool(tool, kwargs)
45
+
46
+ action_func = types.FunctionType(
47
+ function.__code__,
48
+ globals=globals(),
49
+ name=tool,
50
+ closure=function.__closure__,
51
+ )
52
+ action_func.__signature__ = Signature( # type: ignore
53
+ parameters=get_signature_format_from_schema_params(
54
+ schema_params=schema_params
55
+ )
56
+ )
57
+ action_func.__doc__ = description
58
+ return action_func
59
+
60
+ def wrap_tool(
61
+ self, tool: Tool, execute_tool: AgenticProviderExecuteFn
62
+ ) -> StructuredTool:
63
+ """Wraps composio tool as Langchain StructuredTool object."""
64
+ return t.cast(
65
+ StructuredTool,
66
+ StructuredTool.from_function(
67
+ name=tool.slug,
68
+ description=tool.description,
69
+ args_schema=json_schema_to_model(
70
+ json_schema=tool.input_parameters,
71
+ skip_default=self.skip_default,
72
+ ),
73
+ return_schema=True,
74
+ func=self._wrap_action(
75
+ tool=tool.slug,
76
+ description=tool.description,
77
+ schema_params=tool.input_parameters,
78
+ execute_tool=execute_tool,
79
+ ),
80
+ handle_tool_error=True,
81
+ handle_validation_error=True,
82
+ ),
83
+ )
84
+
85
+ def wrap_tools(
86
+ self,
87
+ tools: t.Sequence[Tool],
88
+ execute_tool: AgenticProviderExecuteFn,
89
+ ) -> t.List[StructuredTool]:
90
+ """
91
+ Get composio tools wrapped as Langchain StructuredTool objects.
92
+ """
93
+ return [self.wrap_tool(tool=tool, execute_tool=execute_tool) for tool in tools]
File without changes
@@ -1,17 +1,21 @@
1
- Metadata-Version: 2.1
2
- Name: composio_langgraph
3
- Version: 0.5.31
4
- Summary: Use Composio to get array of tools with LnagGraph Agent Workflows
1
+ Metadata-Version: 2.4
2
+ Name: composio-langgraph
3
+ Version: 0.10.3
4
+ Summary: Use Composio to get array of tools with LangGraph Agent Workflows.
5
5
  Home-page: https://github.com/ComposioHQ/composio
6
- Author: Sawradip
7
- Author-email: sawradip@composio.dev
6
+ Author: composio
7
+ Author-email: Composio <tech@composio.dev>
8
+ Project-URL: Homepage, https://github.com/ComposioHQ/composio
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: License :: OSI Approved :: Apache Software License
10
11
  Classifier: Operating System :: OS Independent
11
12
  Requires-Python: >=3.9,<4
12
13
  Description-Content-Type: text/markdown
13
- Requires-Dist: composio_langchain<=0.5.31,>=0.5.30
14
14
  Requires-Dist: langgraph
15
+ Requires-Dist: composio
16
+ Dynamic: author
17
+ Dynamic: home-page
18
+ Dynamic: requires-python
15
19
 
16
20
  ## 🦜🕸️ Using Composio With LangGraph
17
21
 
@@ -1,7 +1,9 @@
1
1
  README.md
2
+ pyproject.toml
2
3
  setup.py
3
4
  composio_langgraph/__init__.py
4
- composio_langgraph/toolset.py
5
+ composio_langgraph/provider.py
6
+ composio_langgraph/py.typed
5
7
  composio_langgraph.egg-info/PKG-INFO
6
8
  composio_langgraph.egg-info/SOURCES.txt
7
9
  composio_langgraph.egg-info/dependency_links.txt
@@ -0,0 +1,2 @@
1
+ langgraph
2
+ composio
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "composio-langgraph"
3
+ version = "0.10.3"
4
+ description = "Use Composio to get array of tools with LangGraph Agent Workflows."
5
+ readme = "README.md"
6
+ requires-python = ">=3.9,<4"
7
+ authors = [
8
+ { name = "Composio", email = "tech@composio.dev" }
9
+ ]
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "License :: OSI Approved :: Apache Software License",
13
+ "Operating System :: OS Independent",
14
+ ]
15
+ dependencies = [
16
+ "langgraph",
17
+ "composio",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/ComposioHQ/composio"
@@ -6,13 +6,12 @@ from pathlib import Path
6
6
 
7
7
  from setuptools import setup
8
8
 
9
-
10
9
  setup(
11
10
  name="composio_langgraph",
12
- version="0.5.31",
13
- author="Sawradip",
14
- author_email="sawradip@composio.dev",
15
- description="Use Composio to get array of tools with LnagGraph Agent Workflows",
11
+ version="0.10.3",
12
+ author="composio",
13
+ author_email="tech@composio.dev",
14
+ description="Use Composio to get array of tools with LangGraph Agent Workflows",
16
15
  long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"),
17
16
  long_description_content_type="text/markdown",
18
17
  url="https://github.com/ComposioHQ/composio",
@@ -22,9 +21,6 @@ setup(
22
21
  "Operating System :: OS Independent",
23
22
  ],
24
23
  python_requires=">=3.9,<4",
25
- install_requires=[
26
- "composio_langchain>=0.5.30,<=0.5.31",
27
- "langgraph",
28
- ],
24
+ install_requires=["langgraph", "composio"],
29
25
  include_package_data=True,
30
26
  )
@@ -1,13 +0,0 @@
1
- from composio import Action, App, Tag, Trigger, WorkspaceType
2
-
3
- from .toolset import ComposioToolSet
4
-
5
-
6
- __all__ = (
7
- "Action",
8
- "App",
9
- "Tag",
10
- "Trigger",
11
- "WorkspaceType",
12
- "ComposioToolSet",
13
- )
@@ -1,95 +0,0 @@
1
- from composio_langchain import ComposioToolSet as BaseComposioToolSet
2
-
3
-
4
- class ComposioToolSet(
5
- BaseComposioToolSet,
6
- runtime="langgraph",
7
- description_char_limit=1024,
8
- ):
9
- """
10
- Composio toolset for LangGraph framework.
11
-
12
- Example:
13
- ```python
14
- import json
15
- import operator
16
- from typing import Annotated, TypedDict, Sequence
17
-
18
- from langchain_openai import ChatOpenAI
19
- from langchain_core.utils.function_calling import convert_to_openai_function
20
- from langchain_core.messages import BaseMessage, HumanMessage, FunctionMessage
21
-
22
- from langgraph.graph import StateGraph, END
23
- from langgraph.prebuilt import ToolInvocation, ToolExecutor
24
- from composio_langgraph import Action, ComposioToolSet
25
-
26
- composio_toolset = ComposioToolSet()
27
- tools = composio_toolset.get_actions(
28
- actions=[Action.GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER]
29
- )
30
- tool_executor = ToolExecutor(tools)
31
- functions = [convert_to_openai_function(t) for t in tools]
32
-
33
- model = ChatOpenAI(temperature=0, streaming=True)
34
- model = model.bind_functions(functions)
35
-
36
-
37
- def function_1(state):
38
- messages = state['messages']
39
- response = model.invoke(messages)
40
- return {"messages": [response]}
41
-
42
-
43
- def function_2(state):
44
- messages = state['messages']
45
- last_message = messages[-1]
46
- parsed_function_call = last_message.additional_kwargs["function_call"]
47
-
48
- action = ToolInvocation(
49
- tool=parsed_function_call["name"],
50
- tool_input=json.loads(parsed_function_call["arguments"]),
51
- )
52
-
53
- # We call the tool_executor and get back a response
54
- response = tool_executor.invoke(action)
55
-
56
- # We use the response to create a FunctionMessage
57
- function_message = FunctionMessage(
58
- content=str(response),
59
- name=action.tool
60
- )
61
-
62
- return {"messages": [function_message]}
63
-
64
-
65
- def where_to_go(state):
66
- messages = state['messages']
67
- last_message = messages[-1]
68
-
69
- if "function_call" in last_message.additional_kwargs:
70
- return "continue"
71
- else:
72
- return "end"
73
-
74
-
75
- class AgentState(TypedDict):
76
- messages: Annotated[Sequence[BaseMessage], operator.add]
77
-
78
-
79
- workflow = StateGraph(AgentState)
80
- workflow.add_node("agent", function_1)
81
- workflow.add_node("tool", function_2)
82
- workflow.add_conditional_edges(
83
- "agent",
84
- where_to_go,
85
- {
86
- "continue": "tool",
87
- "end": END
88
- }
89
- )
90
- workflow.add_edge('tool', 'agent')
91
- workflow.set_entry_point("agent")
92
-
93
- app = workflow.compile()
94
- ```
95
- """
@@ -1,2 +0,0 @@
1
- composio_langchain<=0.5.31,>=0.5.30
2
- langgraph