AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(blocks): Enrichlayer integration (#9924)
Nicholas Tindledf20b70f44bb
diff --git a/autogpt_platform/CLAUDE.md b/autogpt_platform/CLAUDE.mdindex 879388ab36..5650698e51 100644--- a/autogpt_platform/CLAUDE.md+++ b/autogpt_platform/CLAUDE.md@@ -180,6 +180,11 @@ ex: do the inputs and outputs tie well together?- Fill out the .github/PULL_REQUEST_TEMPLATE.md template as the PR description/- Run the github pre-commit hooks to ensure code quality.+### Reviewing/Revising Pull Requests+- When the user runs /pr-comments or tries to fetch them, also run gh api /repos/Significant-Gravitas/AutoGPT/pulls/[issuenum]/reviews to get the reviews+- Use gh api /repos/Significant-Gravitas/AutoGPT/pulls/[issuenum]/reviews/[review_id]/comments to get the review contents+- Use gh api /repos/Significant-Gravitas/AutoGPT/issues/9924/comments to get the pr specific comments+### Conventional CommitsUse this format for commit messages and Pull Request titles:diff --git a/autogpt_platform/backend/.env.default b/autogpt_platform/backend/.env.defaultindex 8e46c3ed1c..30c7f4eb8f 100644--- a/autogpt_platform/backend/.env.default+++ b/autogpt_platform/backend/.env.default@@ -158,6 +158,7 @@ SMTP_PASSWORD=# Business & Marketing ToolsAPOLLO_API_KEY=+ENRICHLAYER_API_KEY=AYRSHARE_API_KEY=AYRSHARE_JWT_KEY=SMARTLEAD_API_KEY=diff --git a/autogpt_platform/backend/backend/blocks/enrichlayer/_api.py b/autogpt_platform/backend/backend/blocks/enrichlayer/_api.pynew file mode 100644index 0000000000..7d1f0e61f0--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/enrichlayer/_api.py@@ -0,0 +1,408 @@+"""+API module for Enrichlayer integration.++This module provides a client for interacting with the Enrichlayer API,+which allows fetching LinkedIn profile data and related information.+"""++import datetime+import enum+import logging+from json import JSONDecodeError+from typing import Any, Optional, TypeVar++from pydantic import BaseModel, Field++from backend.data.model import APIKeyCredentials+from backend.util.request import Requests++logger = logging.getLogger(__name__)++T = TypeVar("T")+++class EnrichlayerAPIException(Exception):+ """Exception raised for Enrichlayer API errors."""++ def __init__(self, message: str, status_code: int):+ super().__init__(message)+ self.status_code = status_code+++class FallbackToCache(enum.Enum):+ ON_ERROR = "on-error"+ NEVER = "never"+++class UseCache(enum.Enum):+ IF_PRESENT = "if-present"+ NEVER = "never"+++class SocialMediaProfiles(BaseModel):+ """Social media profiles model."""++ twitter: Optional[str] = None+ facebook: Optional[str] = None+ github: Optional[str] = None+++class Experience(BaseModel):+ """Experience model for LinkedIn profiles."""++ company: Optional[str] = None+ title: Optional[str] = None+ description: Optional[str] = None+ location: Optional[str] = None+ starts_at: Optional[dict[str, int]] = None+ ends_at: Optional[dict[str, int]] = None+ company_linkedin_profile_url: Optional[str] = None+++class Education(BaseModel):+ """Education model for LinkedIn profiles."""++ school: Optional[str] = None+ degree_name: Optional[str] = None+ field_of_study: Optional[str] = None+ starts_at: Optional[dict[str, int]] = None+ ends_at: Optional[dict[str, int]] = None+ school_linkedin_profile_url: Optional[str] = None+++class PersonProfileResponse(BaseModel):+ """Response model for LinkedIn person profile.++ This model represents the response from Enrichlayer's LinkedIn profile API.+ The API returns comprehensive profile data including work experience,+ education, skills, and contact information (when available).++ Example API Response:+ {+ "public_identifier": "johnsmith",+ "full_name": "John Smith",+ "occupation": "Software Engineer at Tech Corp",+ "experiences": [+ {+ "company": "Tech Corp",+ "title": "Software Engineer",+ "starts_at": {"year": 2020, "month": 1}+ }+ ],+ "education": [...],+ "skills": ["Python", "JavaScript", ...]+ }+ """++ public_identifier: Optional[str] = None+ profile_pic_url: Optional[str] = None+ full_name: Optional[str] = None+ first_name: Optional[str] = None+ last_name: Optional[str] = None+ occupation: Optional[str] = None+ headline: Optional[str] = None+ summary: Optional[str] = None+ country: Optional[str] = None+ country_full_name: Optional[str] = None+ city: Optional[str] = None+ state: Optional[str] = None+ experiences: Optional[list[Experience]] = None+ education: Optional[list[Education]] = None+ languages: Optional[list[str]] = None+ skills: Optional[list[str]] = None+ inferred_salary: Optional[dict[str, Any]] = None+ personal_email: Optional[str] = None+ personal_contact_number: Optional[str] = None+ social_media_profiles: Optional[SocialMediaProfiles] = None+ extra: Optional[dict[str, Any]] = None+++class SimilarProfile(BaseModel):+ """Similar profile model for LinkedIn person lookup."""++ similarity: float+ linkedin_profile_url: str+++class PersonLookupResponse(BaseModel):+ """Response model for LinkedIn person lookup.++ This model represents the response from Enrichlayer's person lookup API.+ The API returns a LinkedIn profile URL and similarity scores when+ searching for a person by name and company.++ Example API Response:+ {+ "url": "https://www.linkedin.com/in/johnsmith/",+ "name_similarity_score": 0.95,+ "company_similarity_score": 0.88,+ "title_similarity_score": 0.75,+ "location_similarity_score": 0.60+ }+ """++ url: str | None = None+ name_similarity_score: float | None+ company_similarity_score: float | None+ title_similarity_score: float | None+ location_similarity_score: float | None+ last_updated: datetime.datetime | None = None+ profile: PersonProfileResponse | None = None+++class RoleLookupResponse(BaseModel):+ """Response model for LinkedIn role lookup.++ This model represents the response from Enrichlayer's role lookup API.+ The API returns LinkedIn profile data for a specific role at a company.++ Example API Response:+ {+ "linkedin_profile_url": "https://www.linkedin.com/in/johnsmith/",+ "profile_data": {...} // Full PersonProfileResponse data when enrich_profile=True+ }+ """++ linkedin_profile_url: Optional[str] = None+ profile_data: Optional[PersonProfileResponse] = None+++class ProfilePictureResponse(BaseModel):+ """Response model for LinkedIn profile picture.++ This model represents the response from Enrichlayer's profile picture API.+ The API returns a URL to the person's LinkedIn profile picture.++ Example API Response:+ {+ "tmp_profile_pic_url": "https://media.licdn.com/dms/image/..."+ }+ """++ tmp_profile_pic_url: str = Field(+ ..., description="URL of the profile picture", alias="tmp_profile_pic_url"+ )++ @property+ def profile_picture_url(self) -> str:+ """Backward compatibility property for profile_picture_url."""+ return self.tmp_profile_pic_url+++class EnrichlayerClient:+ """Client for interacting with the Enrichlayer API."""++ API_BASE_URL = "https://enrichlayer.com/api/v2"++ def __init__(+ self,+ credentials: Optional[APIKeyCredentials] = None,+ custom_requests: Optional[Requests] = None,+ ):+ """+ Initialize the Enrichlayer client.++ Args:+ credentials: The credentials to use for authentication.+ custom_requests: Custom Requests instance for testing.+ """+ if custom_requests:+ self._requests = custom_requests+ else:+ headers: dict[str, str] = {+ "Content-Type": "application/json",+ }+ if credentials:+ headers["Authorization"] = (+ f"Bearer {credentials.api_key.get_secret_value()}"+ )++ self._requests = Requests(+ extra_headers=headers,+ raise_for_status=False,+ )++ async def _handle_response(self, response) -> Any:+ """+ Handle API response and check for errors.++ Args:+ response: The response object from the request.++ Returns:+ The response data.++ Raises:+ EnrichlayerAPIException: If the API request fails.+ """+ if not response.ok:+ try:+ error_data = response.json()+ error_message = error_data.get("message", "")+ except JSONDecodeError:+ error_message = response.text++ raise EnrichlayerAPIException(+ f"Enrichlayer API request failed ({response.status_code}): {error_message}",+ response.status_code,+ )++ return response.json()++ async def fetch_profile(+ self,+ linkedin_url: str,+ fallback_to_cache: FallbackToCache = FallbackToCache.ON_ERROR,+ use_cache: UseCache = UseCache.IF_PRESENT,+ include_skills: bool = False,+ include_inferred_salary: bool = False,+ include_personal_email: bool = False,+ include_personal_contact_number: bool = False,+ include_social_media: bool = False,+ include_extra: bool = False,+ ) -> PersonProfileResponse:+ """+ Fetch a LinkedIn profile with optional parameters.++ Args:+ linkedin_url: The LinkedIn profile URL to fetch.+ fallback_to_cache: Cache usage if live fetch fails ('on-error' or 'never').+ use_cache: Cache utilization ('if-present' or 'never').+ include_skills: Whether to include skills data.+ include_inferred_salary: Whether to include inferred salary data.+ include_personal_email: Whether to include personal email.+ include_personal_contact_number: Whether to include personal contact number.+ include_social_media: Whether to include social media profiles.+ include_extra: Whether to include additional data.++ Returns:+ The LinkedIn profile data.++ Raises:+ EnrichlayerAPIException: If the API request fails.+ """+ params = {+ "url": linkedin_url,+ "fallback_to_cache": fallback_to_cache.value.lower(),+ "use_cache": use_cache.value.lower(),+ }++ if include_skills:+ params["skills"] = "include"+ if include_inferred_salary:+ params["inferred_salary"] = "include"+ if include_personal_email:+ params["personal_email"] = "include"+ if include_personal_contact_number:+ params["personal_contact_number"] = "include"+ if include_social_media:+ params["twitter_profile_id"] = "include"+ params["facebook_profile_id"] = "include"+ params["github_profile_id"] = "include"+ if include_extra:+ params["extra"] = "include"++ response = await self._requests.get(+ f"{self.API_BASE_URL}/profile", params=params+ )+ return PersonProfileResponse(**await self._handle_response(response))++ async def lookup_person(+ self,+ first_name: str,+ company_domain: str,+ last_name: str | None = None,+ location: Optional[str] = None,+ title: Optional[str] = None,+ include_similarity_checks: bool = False,+ enrich_profile: bool = False,+ ) -> PersonLookupResponse:+ """+ Look up a LinkedIn profile by person's information.++ Args:+ first_name: The person's first name.+ last_name: The person's last name.+ company_domain: The domain of the company they work for.+ location: The person's location.+ title: The person's job title.+ include_similarity_checks: Whether to include similarity checks.+ enrich_profile: Whether to enrich the profile.++ Returns:+ The LinkedIn profile lookup result.++ Raises:+ EnrichlayerAPIException: If the API request fails.+ """+ params = {"first_name": first_name, "company_domain": company_domain}++ if last_name:+ params["last_name"] = last_name+ if location:+ params["location"] = location+ if title:+ params["title"] = title+ if include_similarity_checks:+ params["similarity_checks"] = "include"+ if enrich_profile:+ params["enrich_profile"] = "enrich"++ response = await self._requests.get(+ f"{self.API_BASE_URL}/profile/resolve", params=params+ )+ return PersonLookupResponse(**await self._handle_response(response))++ async def lookup_role(+ self, role: str, company_name: str, enrich_profile: bool = False+ ) -> RoleLookupResponse:+ """+ Look up a LinkedIn profile by role in a company.++ Args:+ role: The role title (e.g., CEO, CTO).+ company_name: The name of the company.+ enrich_profile: Whether to enrich the profile.++ Returns:+ The LinkedIn profile lookup result.++ Raises:+ EnrichlayerAPIException: If the API request fails.+ """+ params = {+ "role": role,+ "company_name": company_name,+ }++ if enrich_profile:+ params["enrich_profile"] = "enrich"++ response = await self._requests.get(+ f"{self.API_BASE_URL}/find/company/role", params=params+ )+ return RoleLookupResponse(**await self._handle_response(response))++ async def get_profile_picture(+ self, linkedin_profile_url: str+ ) -> ProfilePictureResponse:+ """+ Get a LinkedIn profile picture URL.++ Args:+ linkedin_profile_url: The LinkedIn profile URL.++ Returns:+ The profile picture URL.++ Raises:+ EnrichlayerAPIException: If the API request fails.+ """+ params = {+ "linkedin_person_profile_url": linkedin_profile_url,+ }++ response = await self._requests.get(+ f"{self.API_BASE_URL}/person/profile-picture", params=params+ )+ return ProfilePictureResponse(**await self._handle_response(response))diff --git a/autogpt_platform/backend/backend/blocks/enrichlayer/_auth.py b/autogpt_platform/backend/backend/blocks/enrichlayer/_auth.pynew file mode 100644index 0000000000..70413adba4--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/enrichlayer/_auth.py@@ -0,0 +1,34 @@+"""+Authentication module for Enrichlayer API integration.++This module provides credential types and test credentials for the Enrichlayer API.+"""++from typing import Literal++from pydantic import SecretStr++from backend.data.model import APIKeyCredentials, CredentialsMetaInput+from backend.integrations.providers import ProviderName++# Define the type of credentials input expected for Enrichlayer API+EnrichlayerCredentialsInput = CredentialsMetaInput[+ Literal[ProviderName.ENRICHLAYER], Literal["api_key"]+]++# Mock credentials for testing Enrichlayer API integration+TEST_CREDENTIALS = APIKeyCredentials(+ id="1234a567-89bc-4def-ab12-3456cdef7890",+ provider="enrichlayer",+ api_key=SecretStr("mock-enrichlayer-api-key"),+ title="Mock Enrichlayer API key",+ expires_at=None,+)++# Dictionary representation of test credentials for input fields+TEST_CREDENTIALS_INPUT = {+ "provider": TEST_CREDENTIALS.provider,+ "id": TEST_CREDENTIALS.id,+ "type": TEST_CREDENTIALS.type,+ "title": TEST_CREDENTIALS.title,+}diff --git a/autogpt_platform/backend/backend/blocks/enrichlayer/linkedin.py b/autogpt_platform/backend/backend/blocks/enrichlayer/linkedin.pynew file mode 100644index 0000000000..52d593eb0e--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/enrichlayer/linkedin.py@@ -0,0 +1,527 @@+"""+Block definitions for Enrichlayer API integration.++This module implements blocks for interacting with the Enrichlayer API,+which provides access to LinkedIn profile data and related information.+"""++import logging+from typing import Optional++from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema+from backend.data.model import APIKeyCredentials, CredentialsField, SchemaField+from backend.util.type import MediaFileType++from ._api import (+ EnrichlayerClient,+ Experience,+ FallbackToCache,+ PersonLookupResponse,+ PersonProfileResponse,+ RoleLookupResponse,+ UseCache,+)+from ._auth import TEST_CREDENTIALS, TEST_CREDENTIALS_INPUT, EnrichlayerCredentialsInput++logger = logging.getLogger(__name__)+++class GetLinkedinProfileBlock(Block):+ """Block to fetch LinkedIn profile data using Enrichlayer API."""++ class Input(BlockSchema):+ """Input schema for GetLinkedinProfileBlock."""++ linkedin_url: str = SchemaField(+ description="LinkedIn profile URL to fetch data from",+ placeholder="https://www.linkedin.com/in/username/",+ )+ fallback_to_cache: FallbackToCache = SchemaField(+ description="Cache usage if live fetch fails",+ default=FallbackToCache.ON_ERROR,+ advanced=True,+ )+ use_cache: UseCache = SchemaField(+ description="Cache utilization strategy",+ default=UseCache.IF_PRESENT,+ advanced=True,+ )+ include_skills: bool = SchemaField(+ description="Include skills data",+ default=False,+ advanced=True,+ )+ include_inferred_salary: bool = SchemaField(+ description="Include inferred salary data",+ default=False,+ advanced=True,+ )+ include_personal_email: bool = SchemaField(+ description="Include personal email",+ default=False,+ advanced=True,+ )+ include_personal_contact_number: bool = SchemaField(+ description="Include personal contact number",+ default=False,+ advanced=True,+ )+ include_social_media: bool = SchemaField(+ description="Include social media profiles",+ default=False,+ advanced=True,+ )+ include_extra: bool = SchemaField(+ description="Include additional data",+ default=False,+ advanced=True,+ )+ credentials: EnrichlayerCredentialsInput = CredentialsField(+ description="Enrichlayer API credentials"+ )++ class Output(BlockSchema):+ """Output schema for GetLinkedinProfileBlock."""++ profile: PersonProfileResponse = SchemaField(+ description="LinkedIn profile data"+ )+ error: str = SchemaField(description="Error message if the request failed")++ def __init__(self):+ """Initialize GetLinkedinProfileBlock."""+ super().__init__(+ id="f6e0ac73-4f1d-4acb-b4b7-b67066c5984e",+ description="Fetch LinkedIn profile data using Enrichlayer",+ categories={BlockCategory.SOCIAL},+ input_schema=GetLinkedinProfileBlock.Input,+ output_schema=GetLinkedinProfileBlock.Output,+ test_input={+ "linkedin_url": "https://www.linkedin.com/in/williamhgates/",+ "include_skills": True,+ "include_social_media": True,+ "credentials": TEST_CREDENTIALS_INPUT,+ },+ test_output=[+ (+ "profile",+ PersonProfileResponse(+ public_identifier="williamhgates",+ full_name="Bill Gates",+ occupation="Co-chair at Bill & Melinda Gates Foundation",+ experiences=[+ Experience(+ company="Bill & Melinda Gates Foundation",+ title="Co-chair",+ starts_at={"year": 2000},+ )+ ],+ ),+ )+ ],+ test_credentials=TEST_CREDENTIALS,+ test_mock={+ "_fetch_profile": lambda *args, **kwargs: PersonProfileResponse(+ public_identifier="williamhgates",+ full_name="Bill Gates",+ occupation="Co-chair at Bill & Melinda Gates Foundation",+ experiences=[+ Experience(+ company="Bill & Melinda Gates Foundation",+ title="Co-chair",+ starts_at={"year": 2000},+ )+ ],+ ),+ },+ )++ @staticmethod+ async def _fetch_profile(+ credentials: APIKeyCredentials,+ linkedin_url: str,+ fallback_to_cache: FallbackToCache = FallbackToCache.ON_ERROR,+ use_cache: UseCache = UseCache.IF_PRESENT,+ include_skills: bool = False,+ include_inferred_salary: bool = False,+ include_personal_email: bool = False,+ include_personal_contact_number: bool = False,+ include_social_media: bool = False,+ include_extra: bool = False,+ ):+ client = EnrichlayerClient(credentials)+ profile = await client.fetch_profile(+ linkedin_url=linkedin_url,+ fallback_to_cache=fallback_to_cache,+ use_cache=use_cache,+ include_skills=include_skills,+ include_inferred_salary=include_inferred_salary,+ include_personal_email=include_personal_email,+ include_personal_contact_number=include_personal_contact_number,+ include_social_media=include_social_media,+ include_extra=include_extra,+ )+ return profile++ async def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ """+ Run the block to fetch LinkedIn profile data.++ Args:+ input_data: Input parameters for the block+ credentials: API key credentials for Enrichlayer+ **kwargs: Additional keyword arguments++ Yields:+ Tuples of (output_name, output_value)+ """+ try:+ profile = await self._fetch_profile(+ credentials=credentials,+ linkedin_url=input_data.linkedin_url,+ fallback_to_cache=input_data.fallback_to_cache,+ use_cache=input_data.use_cache,+ include_skills=input_data.include_skills,+ include_inferred_salary=input_data.include_inferred_salary,+ include_personal_email=input_data.include_personal_email,+ include_personal_contact_number=input_data.include_personal_contact_number,+ include_social_media=input_data.include_social_media,+ include_extra=input_data.include_extra,+ )+ yield "profile", profile+ except Exception as e:+ logger.error(f"Error fetching LinkedIn profile: {str(e)}")+ yield "error", str(e)+++class LinkedinPersonLookupBlock(Block):+ """Block to look up LinkedIn profiles by person's information using Enrichlayer API."""++ class Input(BlockSchema):+ """Input schema for LinkedinPersonLookupBlock."""++ first_name: str = SchemaField(+ description="Person's first name",+ placeholder="John",+ advanced=False,+ )+ last_name: str | None = SchemaField(+ description="Person's last name",+ placeholder="Doe",+ default=None,+ advanced=False,+ )+ company_domain: str = SchemaField(+ description="Domain of the company they work for (optional)",+ placeholder="example.com",+ advanced=False,+ )+ location: Optional[str] = SchemaField(+ description="Person's location (optional)",+ placeholder="San Francisco",+ default=None,+ )+ title: Optional[str] = SchemaField(+ description="Person's job title (optional)",+ placeholder="CEO",+ default=None,+ )+ include_similarity_checks: bool = SchemaField(+ description="Include similarity checks",+ default=False,+ advanced=True,+ )+ enrich_profile: bool = SchemaField(+ description="Enrich the profile with additional data",+ default=False,+ advanced=True,+ )+ credentials: EnrichlayerCredentialsInput = CredentialsField(+ description="Enrichlayer API credentials"+ )++ class Output(BlockSchema):+ """Output schema for LinkedinPersonLookupBlock."""++ lookup_result: PersonLookupResponse = SchemaField(+ description="LinkedIn profile lookup result"+ )+ error: str = SchemaField(description="Error message if the request failed")++ def __init__(self):+ """Initialize LinkedinPersonLookupBlock."""+ super().__init__(+ id="d237a98a-5c4b-4a1c-b9e3-e6f9a6c81df7",+ description="Look up LinkedIn profiles by person information using Enrichlayer",+ categories={BlockCategory.SOCIAL},+ input_schema=LinkedinPersonLookupBlock.Input,+ output_schema=LinkedinPersonLookupBlock.Output,+ test_input={+ "first_name": "Bill",+ "last_name": "Gates",+ "company_domain": "gatesfoundation.org",+ "include_similarity_checks": True,+ "credentials": TEST_CREDENTIALS_INPUT,+ },+ test_output=[+ (+ "lookup_result",+ PersonLookupResponse(+ url="https://www.linkedin.com/in/williamhgates/",+ name_similarity_score=0.93,+ company_similarity_score=0.83,+ title_similarity_score=0.3,+ location_similarity_score=0.20,+ ),+ )+ ],+ test_credentials=TEST_CREDENTIALS,+ test_mock={+ "_lookup_person": lambda *args, **kwargs: PersonLookupResponse(+ url="https://www.linkedin.com/in/williamhgates/",+ name_similarity_score=0.93,+ company_similarity_score=0.83,+ title_similarity_score=0.3,+ location_similarity_score=0.20,+ )+ },+ )++ @staticmethod+ async def _lookup_person(+ credentials: APIKeyCredentials,+ first_name: str,+ company_domain: str,+ last_name: str | None = None,+ location: Optional[str] = None,+ title: Optional[str] = None,+ include_similarity_checks: bool = False,+ enrich_profile: bool = False,+ ):+ client = EnrichlayerClient(credentials=credentials)+ lookup_result = await client.lookup_person(+ first_name=first_name,+ last_name=last_name,+ company_domain=company_domain,+ location=location,+ title=title,+ include_similarity_checks=include_similarity_checks,+ enrich_profile=enrich_profile,+ )+ return lookup_result++ async def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ """+ Run the block to look up LinkedIn profiles.++ Args:+ input_data: Input parameters for the block+ credentials: API key credentials for Enrichlayer+ **kwargs: Additional keyword arguments++ Yields:+ Tuples of (output_name, output_value)+ """+ try:+ lookup_result = await self._lookup_person(+ credentials=credentials,+ first_name=input_data.first_name,+ last_name=input_data.last_name,+ company_domain=input_data.company_domain,+ location=input_data.location,+ title=input_data.title,+ include_similarity_checks=input_data.include_similarity_checks,+ enrich_profile=input_data.enrich_profile,+ )+ yield "lookup_result", lookup_result+ except Exception as e:+ logger.error(f"Error looking up LinkedIn profile: {str(e)}")+ yield "error", str(e)+++class LinkedinRoleLookupBlock(Block):+ """Block to look up LinkedIn profiles by role in a company using Enrichlayer API."""++ class Input(BlockSchema):+ """Input schema for LinkedinRoleLookupBlock."""++ role: str = SchemaField(+ description="Role title (e.g., CEO, CTO)",+ placeholder="CEO",+ )+ company_name: str = SchemaField(+ description="Name of the company",+ placeholder="Microsoft",+ )+ enrich_profile: bool = SchemaField(+ description="Enrich the profile with additional data",+ default=False,+ advanced=True,+ )+ credentials: EnrichlayerCredentialsInput = CredentialsField(+ description="Enrichlayer API credentials"+ )++ class Output(BlockSchema):+ """Output schema for LinkedinRoleLookupBlock."""++ role_lookup_result: RoleLookupResponse = SchemaField(+ description="LinkedIn role lookup result"+ )+ error: str = SchemaField(description="Error message if the request failed")++ def __init__(self):+ """Initialize LinkedinRoleLookupBlock."""+ super().__init__(+ id="3b9fc742-06d4-49c7-b5ce-7e302dd7c8a7",+ description="Look up LinkedIn profiles by role in a company using Enrichlayer",+ categories={BlockCategory.SOCIAL},+ input_schema=LinkedinRoleLookupBlock.Input,+ output_schema=LinkedinRoleLookupBlock.Output,+ test_input={+ "role": "Co-chair",+ "company_name": "Gates Foundation",+ "enrich_profile": True,+ "credentials": TEST_CREDENTIALS_INPUT,+ },+ test_output=[+ (+ "role_lookup_result",+ RoleLookupResponse(+ linkedin_profile_url="https://www.linkedin.com/in/williamhgates/",+ ),+ )+ ],+ test_credentials=TEST_CREDENTIALS,+ test_mock={+ "_lookup_role": lambda *args, **kwargs: RoleLookupResponse(+ linkedin_profile_url="https://www.linkedin.com/in/williamhgates/",+ ),+ },+ )++ @staticmethod+ async def _lookup_role(+ credentials: APIKeyCredentials,+ role: str,+ company_name: str,+ enrich_profile: bool = False,+ ):+ client = EnrichlayerClient(credentials=credentials)+ role_lookup_result = await client.lookup_role(+ role=role,+ company_name=company_name,+ enrich_profile=enrich_profile,+ )+ return role_lookup_result++ async def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ """+ Run the block to look up LinkedIn profiles by role.++ Args:+ input_data: Input parameters for the block+ credentials: API key credentials for Enrichlayer+ **kwargs: Additional keyword arguments++ Yields:+ Tuples of (output_name, output_value)+ """+ try:+ role_lookup_result = await self._lookup_role(+ credentials=credentials,+ role=input_data.role,+ company_name=input_data.company_name,+ enrich_profile=input_data.enrich_profile,+ )+ yield "role_lookup_result", role_lookup_result+ except Exception as e:+ logger.error(f"Error looking up role in company: {str(e)}")+ yield "error", str(e)+++class GetLinkedinProfilePictureBlock(Block):+ """Block to get LinkedIn profile pictures using Enrichlayer API."""++ class Input(BlockSchema):+ """Input schema for GetLinkedinProfilePictureBlock."""++ linkedin_profile_url: str = SchemaField(+ description="LinkedIn profile URL",+ placeholder="https://www.linkedin.com/in/username/",+ )+ credentials: EnrichlayerCredentialsInput = CredentialsField(+ description="Enrichlayer API credentials"+ )++ class Output(BlockSchema):+ """Output schema for GetLinkedinProfilePictureBlock."""++ profile_picture_url: MediaFileType = SchemaField(+ description="LinkedIn profile picture URL"+ )+ error: str = SchemaField(description="Error message if the request failed")++ def __init__(self):+ """Initialize GetLinkedinProfilePictureBlock."""+ super().__init__(+ id="68d5a942-9b3f-4e9a-b7c1-d96ea4321f0d",+ description="Get LinkedIn profile pictures using Enrichlayer",+ categories={BlockCategory.SOCIAL},+ input_schema=GetLinkedinProfilePictureBlock.Input,+ output_schema=GetLinkedinProfilePictureBlock.Output,+ test_input={+ "linkedin_profile_url": "https://www.linkedin.com/in/williamhgates/",+ "credentials": TEST_CREDENTIALS_INPUT,+ },+ test_output=[+ (+ "profile_picture_url",+ "https://media.licdn.com/dms/image/C4D03AQFj-xjuXrLFSQ/profile-displayphoto-shrink_800_800/0/1576881858598?e=1686787200&v=beta&t=zrQC76QwsfQQIWthfOnrKRBMZ5D-qIAvzLXLmWgYvTk",+ )+ ],+ test_credentials=TEST_CREDENTIALS,+ test_mock={+ "_get_profile_picture": lambda *args, **kwargs: "https://media.licdn.com/dms/image/C4D03AQFj-xjuXrLFSQ/profile-displayphoto-shrink_800_800/0/1576881858598?e=1686787200&v=beta&t=zrQC76QwsfQQIWthfOnrKRBMZ5D-qIAvzLXLmWgYvTk",+ },+ )++ @staticmethod+ async def _get_profile_picture(+ credentials: APIKeyCredentials, linkedin_profile_url: str+ ):+ client = EnrichlayerClient(credentials=credentials)+ profile_picture_response = await client.get_profile_picture(+ linkedin_profile_url=linkedin_profile_url,+ )+ return profile_picture_response.profile_picture_url++ async def run(+ self, input_data: Input, *, credentials: APIKeyCredentials, **kwargs+ ) -> BlockOutput:+ """+ Run the block to get LinkedIn profile pictures.++ Args:+ input_data: Input parameters for the block+ credentials: API key credentials for Enrichlayer+ **kwargs: Additional keyword arguments++ Yields:+ Tuples of (output_name, output_value)+ """+ try:+ profile_picture = await self._get_profile_picture(+ credentials=credentials,+ linkedin_profile_url=input_data.linkedin_profile_url,+ )+ yield "profile_picture_url", profile_picture+ except Exception as e:+ logger.error(f"Error getting profile picture: {str(e)}")+ yield "error", str(e)diff --git a/autogpt_platform/backend/backend/data/block_cost_config.py b/autogpt_platform/backend/backend/data/block_cost_config.pyindex cbcd1bd475..dbc27a2795 100644--- a/autogpt_platform/backend/backend/data/block_cost_config.py+++ b/autogpt_platform/backend/backend/data/block_cost_config.py@@ -5,6 +5,12 @@ from backend.blocks.ai_shortform_video_block import AIShortformVideoCreatorBlockfrom backend.blocks.apollo.organization import SearchOrganizationsBlockfrom backend.blocks.apollo.people import SearchPeopleBlockfrom backend.blocks.apollo.person import GetPersonDetailBlock+from backend.blocks.enrichlayer.linkedin import (+ GetLinkedinProfileBlock,+ GetLinkedinProfilePictureBlock,+ LinkedinPersonLookupBlock,+ LinkedinRoleLookupBlock,+)from backend.blocks.flux_kontext import AIImageEditorBlock, FluxKontextModelNamefrom backend.blocks.ideogram import IdeogramModelBlockfrom backend.blocks.jina.embeddings import JinaEmbeddingBlock@@ -30,6 +36,7 @@ from backend.integrations.credentials_store import (anthropic_credentials,apollo_credentials,did_credentials,+ enrichlayer_credentials,groq_credentials,ideogram_credentials,jina_credentials,@@ -376,6 +383,54 @@ BLOCK_COSTS: dict[Type[Block], list[BlockCost]] = {},)],+ GetLinkedinProfileBlock: [+ BlockCost(+ cost_amount=1,+ cost_filter={+ "credentials": {+ "id": enrichlayer_credentials.id,+ "provider": enrichlayer_credentials.provider,+ "type": enrichlayer_credentials.type,+ }+ },+ )+ ],+ LinkedinPersonLookupBlock: [+ BlockCost(+ cost_amount=2,+ cost_filter={+ "credentials": {+ "id": enrichlayer_credentials.id,+ "provider": enrichlayer_credentials.provider,+ "type": enrichlayer_credentials.type,+ }+ },+ )+ ],+ LinkedinRoleLookupBlock: [+ BlockCost(+ cost_amount=3,+ cost_filter={+ "credentials": {+ "id": enrichlayer_credentials.id,+ "provider": enrichlayer_credentials.provider,+ "type": enrichlayer_credentials.type,+ }+ },+ )+ ],+ GetLinkedinProfilePictureBlock: [+ BlockCost(+ cost_amount=3,+ cost_filter={+ "credentials": {+ "id": enrichlayer_credentials.id,+ "provider": enrichlayer_credentials.provider,+ "type": enrichlayer_credentials.type,+ }+ },+ )+ ],SmartDecisionMakerBlock: LLM_COST,SearchOrganizationsBlock: [BlockCost(diff --git a/autogpt_platform/backend/backend/integrations/credentials_store.py b/autogpt_platform/backend/backend/integrations/credentials_store.pyindex eedb38bf4b..fea6937a04 100644--- a/autogpt_platform/backend/backend/integrations/credentials_store.py+++ b/autogpt_platform/backend/backend/integrations/credentials_store.py@@ -182,6 +182,15 @@ zerobounce_credentials = APIKeyCredentials(expires_at=None,)+enrichlayer_credentials = APIKeyCredentials(+ id="d9fce73a-6c1d-4e8b-ba2e-12a456789def",+ provider="enrichlayer",+ api_key=SecretStr(settings.secrets.enrichlayer_api_key),+ title="Use Credits for Enrichlayer",+ expires_at=None,+)++llama_api_credentials = APIKeyCredentials(id="d44045af-1c33-4833-9e19-752313214de2",provider="llama_api",@@ -203,6 +212,7 @@ DEFAULT_CREDENTIALS = [jina_credentials,unreal_credentials,open_router_credentials,+ enrichlayer_credentials,fal_credentials,exa_credentials,e2b_credentials,@@ -279,6 +289,8 @@ class IntegrationCredentialsStore:all_credentials.append(unreal_credentials)if settings.secrets.open_router_api_key:all_credentials.append(open_router_credentials)+ if settings.secrets.enrichlayer_api_key:+ all_credentials.append(enrichlayer_credentials)if settings.secrets.fal_api_key:all_credentials.append(fal_credentials)if settings.secrets.exa_api_key:diff --git a/autogpt_platform/backend/backend/integrations/providers.py b/autogpt_platform/backend/backend/integrations/providers.pyindex 2db3e19f34..587da16a8c 100644--- a/autogpt_platform/backend/backend/integrations/providers.py+++ b/autogpt_platform/backend/backend/integrations/providers.py@@ -25,6 +25,7 @@ class ProviderName(str, Enum):GROQ = "groq"HTTP = "http"HUBSPOT = "hubspot"+ ENRICHLAYER = "enrichlayer"IDEOGRAM = "ideogram"JINA = "jina"LLAMA_API = "llama_api"diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.pyindex a188254919..d5e1c1abaf 100644--- a/autogpt_platform/backend/backend/util/settings.py+++ b/autogpt_platform/backend/backend/util/settings.py@@ -521,6 +521,7 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):apollo_api_key: str = Field(default="", description="Apollo API Key")smartlead_api_key: str = Field(default="", description="SmartLead API Key")zerobounce_api_key: str = Field(default="", description="ZeroBounce API Key")+ enrichlayer_api_key: str = Field(default="", description="Enrichlayer API Key")# AutoMod API credentialsautomod_api_key: str = Field(default="", description="AutoMod API key")@@ -534,7 +535,6 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):ayrshare_api_key: str = Field(default="", description="Ayrshare API Key")ayrshare_jwt_key: str = Field(default="", description="Ayrshare private Key")# Add more secret fields as needed-model_config = SettingsConfigDict(env_file=".env",env_file_encoding="utf-8",diff --git a/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx b/autogpt_platform/frontend/src/components/integrations/credentials-input.tsxindex 078319189a..e43c411740 100644--- a/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx+++ b/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx@@ -64,6 +64,7 @@ export const providerIcons: Partial<open_router: fallbackIcon,llama_api: fallbackIcon,pinecone: fallbackIcon,+ enrichlayer: fallbackIcon,slant3d: fallbackIcon,screenshotone: fallbackIcon,smtp: fallbackIcon,