Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ALwrity ALwrity LinkedInService generate linkedin post

From Leeroopedia
Knowledge Sources
Domains LinkedIn, Content_Generation, Social_Media
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for generating grounded LinkedIn posts with research, citations, and quality analysis, provided by the ALwrity LinkedIn subsystem.

Description

The LinkedInService.generate_linkedin_post method is the entry point for the LinkedIn content pipeline. It takes a LinkedInPostRequest (topic, search_engine, research_enabled, grounding level) and a Clerk user ID, then runs a three-stage flow: (1) ResearchHandler.conduct_research gathers sources via the configured search engine (Exa, Google, Tavily); (2) ContentGenerator.generate_grounded_post_content generates the post content conditioned on the research sources and the user's writing persona, with citations managed by CitationManager; (3) the final response is assembled with quality metrics from ContentQualityAnalyzer (factual accuracy, professional tone, industry relevance).

Grounding is mandatory: if research is disabled or no sources are found, the method raises an error rather than generating ungrounded content.

Usage

Import this service when:

  • A user requests a LinkedIn post on a topic with research backing.
  • Citations and source attribution are required in the output.
  • Quality metrics (factual accuracy, tone) must accompany the generated post.
  • Optional publishing via Unipile follows generation.

Code Reference

Source Location

  • Repository: ALwrity
  • File: backend/services/linkedin_service.py (L71-120)

Signature

class LinkedInService:
    @property
    def citation_manager(self) -> "CitationManager": ...
    @property
    def quality_analyzer(self) -> "ContentQualityAnalyzer": ...

    async def generate_linkedin_post(
        self,
        request: LinkedInPostRequest,
        user_id: Optional[str] = None,
    ) -> LinkedInPostResponse:
        """
        Generate a LinkedIn post with enhanced grounding capabilities.

        Args:
            request: LinkedIn post generation request with topic,
                     search_engine, research_enabled, grounding options.
            user_id: Optional Clerk user ID for provider routing.

        Returns:
            LinkedInPostResponse with grounded content, research sources,
            citations, and quality metrics.

        Raises:
            Exception: If grounding is not enabled (research disabled or
                       no sources found).
        """

Import

from services.linkedin_service import LinkedInService

I/O Contract

Inputs

Name Type Required Description
request LinkedInPostRequest Yes topic, search_engine, research_enabled, grounding level
user_id Optional[str] No Clerk user ID for provider routing

Outputs

Name Type Description
return LinkedInPostResponse grounded content, research sources, citations, quality metrics

Usage Examples

Generating a grounded LinkedIn post

from services.linkedin_service import LinkedInService
from models.linkedin_models import LinkedInPostRequest

service = LinkedInService()
request = LinkedInPostRequest(
    topic="The future of open-source LLMs",
    search_engine="exa",
    research_enabled=True,
    grounding_level="high",
)

response = await service.generate_linkedin_post(request, user_id="clerk_user_123")
print(response.content)
print(f"Sources: {len(response.research_sources)}")
print(f"Quality score: {response.quality_metrics}")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment