composio-langchain


Namecomposio-langchain JSON
Version 0.3.30 PyPI version JSON
download
home_pagehttps://github.com/ComposioHQ/composio
SummaryUse Composio to get an array of tools with your LangChain agent.
upload_time2024-07-26 10:44:30
maintainerNone
docs_urlNone
authorKaran
requires_python<4,>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## 🦜🔗 Using Composio With LangChain

Integrate Composio with LangChain agents to allow them to interact seamlessly with external apps, enhancing their functionality and reach.

### Goal

- **Star a repository on GitHub** using natural language commands through a LangChain Agent.

### Installation and Setup

Ensure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.

```bash
# Install Composio LangChain package
pip install composio-langchain

# Connect your GitHub account
composio-cli add github

# View available applications you can connect with
composio-cli show-apps
```

### Usage Steps

#### 1. Import Base Packages

Prepare your environment by initializing necessary imports from LangChain and setting up your agent.

```python
from langchain.agents import create_openai_functions_agent, AgentExecutor
from langchain import hub
from langchain_openai import ChatOpenAI

# Initialize LangChain OpenAI Chat
llm = ChatOpenAI()

# Pull the agent prompt configuration
prompt = hub.pull("hwchase17/openai-functions-agent")
```

#### 2. Fetch GitHub LangChain Tools via Composio

Access GitHub tools provided by Composio for LangChain.

```python
from composio_langchain import ComposioToolset, Action, App

# Initialize the toolset for GitHub
tools = ComposioToolset(apps=[App.GITHUB])
```

#### 3. Execute the Agent

Configure and execute the agent to perform tasks such as starring a repository on GitHub.

```python
task = "Star a repo composiohq/composio on GitHub"

# Create and set up the agent
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

# Execute the task
agent_executor.invoke({"input": task})
```

#### 4. Check Response

Validate the execution and response from the agent to ensure the task was completed successfully.

```bash
> Entering new AgentExecutor chain...
> Invoking: `github_star_repo` with `{'owner': 'composiohq', 'repo': 'composio'}`
> {'execution_details': {'executed': True}, 'response_data': ''}
> I have successfully starred the repository composiohq/composio on GitHub.
```

### Advanced Configuration

- **Filter Specific Actions:** Limit the actions an agent can execute.

```python
# Filter to only allow creating issues on GitHub
toolsGithubCreateIssue = ComposioToolset(actions=[Action.GITHUB_CREATE_ISSUE])
```

- **Filter Specific Apps:** Restrict the tools an agent can use.

```python
# Allow usage of Asana and GitHub only
toolsAsanaGithub = ComposioToolset(apps=[App.ASANA, App.GITHUB])
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ComposioHQ/composio",
    "name": "composio-langchain",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Karan",
    "author_email": "karan@composio.dev",
    "download_url": "https://files.pythonhosted.org/packages/44/b5/793241c6abf88c9d42a4f3efac059d4936f0fc3589f624c5c5c5fdcd3a0a/composio_langchain-0.3.30.tar.gz",
    "platform": null,
    "description": "## \ud83e\udd9c\ud83d\udd17 Using Composio With LangChain\n\nIntegrate Composio with LangChain agents to allow them to interact seamlessly with external apps, enhancing their functionality and reach.\n\n### Goal\n\n- **Star a repository on GitHub** using natural language commands through a LangChain Agent.\n\n### Installation and Setup\n\nEnsure you have the necessary packages installed and connect your GitHub account to allow your agents to utilize GitHub functionalities.\n\n```bash\n# Install Composio LangChain package\npip install composio-langchain\n\n# Connect your GitHub account\ncomposio-cli add github\n\n# View available applications you can connect with\ncomposio-cli show-apps\n```\n\n### Usage Steps\n\n#### 1. Import Base Packages\n\nPrepare your environment by initializing necessary imports from LangChain and setting up your agent.\n\n```python\nfrom langchain.agents import create_openai_functions_agent, AgentExecutor\nfrom langchain import hub\nfrom langchain_openai import ChatOpenAI\n\n# Initialize LangChain OpenAI Chat\nllm = ChatOpenAI()\n\n# Pull the agent prompt configuration\nprompt = hub.pull(\"hwchase17/openai-functions-agent\")\n```\n\n#### 2. Fetch GitHub LangChain Tools via Composio\n\nAccess GitHub tools provided by Composio for LangChain.\n\n```python\nfrom composio_langchain import ComposioToolset, Action, App\n\n# Initialize the toolset for GitHub\ntools = ComposioToolset(apps=[App.GITHUB])\n```\n\n#### 3. Execute the Agent\n\nConfigure and execute the agent to perform tasks such as starring a repository on GitHub.\n\n```python\ntask = \"Star a repo composiohq/composio on GitHub\"\n\n# Create and set up the agent\nagent = create_openai_functions_agent(llm, tools, prompt)\nagent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)\n\n# Execute the task\nagent_executor.invoke({\"input\": task})\n```\n\n#### 4. Check Response\n\nValidate the execution and response from the agent to ensure the task was completed successfully.\n\n```bash\n> Entering new AgentExecutor chain...\n> Invoking: `github_star_repo` with `{'owner': 'composiohq', 'repo': 'composio'}`\n> {'execution_details': {'executed': True}, 'response_data': ''}\n> I have successfully starred the repository composiohq/composio on GitHub.\n```\n\n### Advanced Configuration\n\n- **Filter Specific Actions:** Limit the actions an agent can execute.\n\n```python\n# Filter to only allow creating issues on GitHub\ntoolsGithubCreateIssue = ComposioToolset(actions=[Action.GITHUB_CREATE_ISSUE])\n```\n\n- **Filter Specific Apps:** Restrict the tools an agent can use.\n\n```python\n# Allow usage of Asana and GitHub only\ntoolsAsanaGithub = ComposioToolset(apps=[App.ASANA, App.GITHUB])\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Use Composio to get an array of tools with your LangChain agent.",
    "version": "0.3.30",
    "project_urls": {
        "Homepage": "https://github.com/ComposioHQ/composio"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "716cf6d2f50c41bd97f6044a0fad3af1cd2e887e6ee4bbf97673b9c3927e2f37",
                "md5": "301dd9fbc3f68193693e35a4aabc120b",
                "sha256": "c6c66852871801672582e579203fa49858fb02733a98ae5ced335d8ec01818e0"
            },
            "downloads": -1,
            "filename": "composio_langchain-0.3.30-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "301dd9fbc3f68193693e35a4aabc120b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 4553,
            "upload_time": "2024-07-26T10:44:28",
            "upload_time_iso_8601": "2024-07-26T10:44:28.231546Z",
            "url": "https://files.pythonhosted.org/packages/71/6c/f6d2f50c41bd97f6044a0fad3af1cd2e887e6ee4bbf97673b9c3927e2f37/composio_langchain-0.3.30-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "44b5793241c6abf88c9d42a4f3efac059d4936f0fc3589f624c5c5c5fdcd3a0a",
                "md5": "329f9d9056f549886c10458830086fd4",
                "sha256": "ddbbffb1fd1498f60edbf46c685c492d5c3dce3d6437caff9066c8343d00eba0"
            },
            "downloads": -1,
            "filename": "composio_langchain-0.3.30.tar.gz",
            "has_sig": false,
            "md5_digest": "329f9d9056f549886c10458830086fd4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 4133,
            "upload_time": "2024-07-26T10:44:30",
            "upload_time_iso_8601": "2024-07-26T10:44:30.019438Z",
            "url": "https://files.pythonhosted.org/packages/44/b5/793241c6abf88c9d42a4f3efac059d4936f0fc3589f624c5c5c5fdcd3a0a/composio_langchain-0.3.30.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-26 10:44:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ComposioHQ",
    "github_project": "composio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "composio-langchain"
}
        
Elapsed time: 0.28495s