[Solved ✅] Error with LINKEDIN_BETA Tool
import json
from crewai_tools.tools.base_tool import BaseTool
from composio_crewai import ComposioToolSet
from pydantic import BaseModel, Field
from typing import Any, Dict
class LinkedInSearchInput(BaseModel):
keywords: str = Field(description="Keywords to search for (e.g., 'real estate development')")
location: str = Field(description="Location to search in (e.g., 'Indiana')")
class LinkedInSearchTool(BaseTool):
def init(self):
super().init(
name="LinkedIn Company Search",
description="""
Use this tool to search for companies on LinkedIn.
Input should be search parameters for finding companies.
For companies in specific locations, include both company type and location.
Example: Search for 'real estate development' companies in 'Indiana'
""",
args_schema=LinkedInSearchInput
)
# Initialize tool-specific components
self._composio_toolset = ComposioToolSet(api_key="tsapwyj4zjlymdg0pku6ko")
self._linkedin_tool = self._composio_toolset.get_tools(actions=['LINKEDIN_BETA_SEARCH'])[0]
def _run(self, tool_input: LinkedInSearchInput) -> str:
"""Execute the LinkedIn search with given parameters"""
try:
results = self._linkedin_tool.run(
tool_input.model_dump()
)
# params = {
# "api": "classic",
# "category": "companies",
# "limit": 50,
# "classic_companies": {
# "keywords": tool_input.dict()["keywords"]
# }
# }
# results = self._linkedin_tool.run(params)
return f"Search Results: {results}"
except Exception as e:
return f"Error in search: {str(e)}"
Create an instance of the tool
linkedin_tools = LinkedInSearchTool()
If i keep the code as it is, I get error: Search Results: {'successfull': False, 'data': {}, 'error': "'dict' object has no attribute 'model_dump'"}
If i put the commented code instead, I get error: composio wrapper tool expects 0 positional arguments but instead got 1
Please help
1 Reply
subsequent-cyan•2mo ago
This is a tool in beta and only works when you have our chrome extension installed.
We wouldn't recommend using this in production yet as this might be not stable.