@devries-cameron20 / composio-1 / commits / 871086dcc
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat: add llamaindex provider

angrybayblade committed Aug 28, 2025 at 12:55 UTC 871086dcc1758a6c43855596db10d4178ef6019e
7 files changed +153
python/providers/llamaindex/README.md new
+4
@@ -0,0 +1,4 @@
1 +## Using Composio With LLamaIndex
2 +
3 +Integrate Composio with LLamaIndex Agentic workflows & enable them to interact seamlessly
4 +with external apps, enhancing their functionality and reach.
python/providers/llamaindex/composio_llamaindex/__init__.py new
+3
@@ -0,0 +1,3 @@
1 +from .provider import LlamaIndexProvider
2 +
3 +__all__ = ("LlamaIndexProvider",)
python/providers/llamaindex/composio_llamaindex/provider.py new
+62
@@ -0,0 +1,62 @@
1 +"""ComposioLangChain class definition"""
2 +
3 +import types
4 +import typing as t
5 +from inspect import Signature
6 +
7 +from llama_index.core.tools import FunctionTool
8 +
9 +from composio.core.provider import AgenticProvider, AgenticProviderExecuteFn
10 +from composio.types import Tool
11 +from composio.utils.shared import get_signature_format_from_schema_params
12 +
13 +
14 +class LlamaIndexProvider(
15 + AgenticProvider[FunctionTool, t.List[FunctionTool]],
16 + name="llamaindex",
17 +):
18 + """
19 + Composio toolset for LlamaIndex framework.
20 + """
21 +
22 + def wrap_tool(
23 + self,
24 + tool: Tool,
25 + execute_tool: AgenticProviderExecuteFn,
26 + ) -> FunctionTool:
27 + """
28 + Wrap a tool into a LlamaIndex FunctionTool object.
29 + """
30 +
31 + def function(**kwargs: t.Any) -> t.Dict:
32 + """Wrapper function for composio action."""
33 + return execute_tool(slug=tool.slug, arguments=kwargs)
34 +
35 + action_func = types.FunctionType(
36 + function.__code__,
37 + globals=globals(),
38 + name=tool.slug,
39 + closure=function.__closure__,
40 + )
41 + action_func.__signature__ = Signature( # type: ignore
42 + parameters=get_signature_format_from_schema_params(
43 + schema_params=tool.input_parameters,
44 + skip_default=self.skip_default,
45 + )
46 + )
47 + action_func.__doc__ = tool.description
48 + return FunctionTool.from_defaults(
49 + action_func,
50 + name=tool.slug,
51 + description=tool.description,
52 + )
53 +
54 + def wrap_tools(
55 + self,
56 + tools: t.Sequence[Tool],
57 + execute_tool: AgenticProviderExecuteFn,
58 + ) -> t.List[FunctionTool]:
59 + """
60 + Wrap tools into LlamaIndex FunctionTool objects.
61 + """
62 + return [self.wrap_tool(tool, execute_tool) for tool in tools]
python/providers/llamaindex/composio_llamaindex/py.typed
python/providers/llamaindex/llamaindex_demo.py new
+38
@@ -0,0 +1,38 @@
1 +import asyncio
2 +
3 +import dotenv
4 +from composio_llamaindex import LlamaIndexProvider
5 +from llama_index.core.agent.workflow import FunctionAgent
6 +from llama_index.llms.openai import OpenAI
7 +
8 +from composio import Composio
9 +
10 +# Load environment variables from .env
11 +dotenv.load_dotenv()
12 +
13 +# Setup client
14 +llm = OpenAI(model="gpt-4-turbo")
15 +composio = Composio(provider=LlamaIndexProvider())
16 +
17 +# Get All the tools
18 +tools = composio.tools.get(
19 + user_id="default",
20 + tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],
21 +)
22 +
23 +workflow = FunctionAgent(
24 + tools=tools,
25 + llm=llm,
26 + system_prompt="You are an agent that perform github actions.",
27 +)
28 +
29 +
30 +async def main():
31 + result = await workflow.run(
32 + user_msg="Hello! I would like to star a repo composiohq/composio on GitHub"
33 + )
34 + print(result)
35 +
36 +
37 +if __name__ == "__main__":
38 + asyncio.run(main())
python/providers/llamaindex/pyproject.toml new
+20
@@ -0,0 +1,20 @@
1 +[project]
2 +name = "composio-llamaindex"
3 +version = "0.8.9"
4 +description = "Use Composio to get array of tools with LlamaIndex 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 + "llama_index",
17 +]
18 +
19 +[project.urls]
20 +Homepage = "https://github.com/ComposioHQ/composio"
python/providers/llamaindex/setup.py new
+26
@@ -0,0 +1,26 @@
1 +"""
2 +Setup configuration for Composio LangGraph plugin
3 +"""
4 +
5 +from pathlib import Path
6 +
7 +from setuptools import setup
8 +
9 +setup(
10 + name="composio_llamaindex",
11 + version="0.8.9",
12 + author="composio",
13 + author_email="tech@composio.dev",
14 + description="Use Composio to get array of tools with LlamaIndex Agent Workflows",
15 + long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"),
16 + long_description_content_type="text/markdown",
17 + url="https://github.com/ComposioHQ/composio",
18 + classifiers=[
19 + "Programming Language :: Python :: 3",
20 + "License :: OSI Approved :: Apache Software License",
21 + "Operating System :: OS Independent",
22 + ],
23 + python_requires=">=3.9,<4",
24 + install_requires=["llama-index"],
25 + include_package_data=True,
26 +)