Files
ALwrity/backend/services/research/__init__.py
ajaysi 63a0df2536 feat: LinkedIn LLM alignment - Phase 1-3 complete
Phase 1: Dead Code Cleanup
- Remove GeminiGroundedProvider import and property from linkedin_service.py
- Remove fallback_provider property (gemini_provider imports)
- Fix routers/linkedin.py edit endpoint to use llm_text_gen
- Delete dead LinkedInImageEditor class
- Remove dead _transform_gemini_sources from content_generator.py

Phase 2: Research Infrastructure Alignment
- Add user_id to _conduct_research() for pre-flight validation
- Add validate_exa_research_operations() before Exa/Tavily calls
- Pass user_id to provider.simple_search() for usage tracking
- Inject research content into LLM prompts via _build_research_context()
- Fix Google engine path to fallback to Exa
- Add Exa → Tavily fallback on research failure

Phase 3: Cosmetic Cleanup
- Rename _generate_prompts_with_gemini → _generate_prompts_with_llm
- Rename _build_gemini_prompt → _build_image_prompt
- Rename _parse_gemini_response → _parse_llm_response
- Remove all Gemini references from LinkedIn code (0 remaining)
- Update docstrings and log messages

Additional:
- Research caching using existing ResearchCache
- Shared ExaContentResearchProvider in services/research/
- Persona service uses llm_text_gen instead of gemini_structured_json_response
- LinkedInWriter.tsx ChatMessage → ChatMsg type mapping fix
- RegisterLinkedInActionsEnhanced.tsx content_format_rules typing fix
2026-06-12 18:58:53 +05:30

62 lines
1.7 KiB
Python

"""
Research Services Module for ALwrity
This module provides research and grounding capabilities for content generation,
replacing mock research with real-time industry information.
Available Services:
- GoogleSearchService: Real-time industry research using Google Custom Search API
- ExaService: Competitor discovery and analysis using Exa API
- ExaContentResearchProvider: Shared content research provider for LinkedIn/Blog
- TavilyService: AI-powered web search with real-time information
- Source ranking and credibility assessment
- Content extraction and insight generation
Core Module (v2.0):
- ResearchEngine: Standalone AI research engine for any content tool
- ResearchContext: Unified input schema for research requests
- ParameterOptimizer: AI-driven parameter optimization
Author: ALwrity Team
Version: 2.1
Last Updated: June 2026
"""
from .google_search_service import GoogleSearchService
from .exa_service import ExaService
from .exa_content_research import ExaContentResearchProvider, get_exa_content_provider
from .tavily_service import TavilyService
# Core Research Engine (v2.0)
from .core import (
ResearchEngine,
ResearchContext,
ResearchPersonalizationContext,
ContentType,
ResearchGoal,
ResearchDepth,
ProviderPreference,
ParameterOptimizer,
)
__all__ = [
# Legacy services (still used by blog writer)
"GoogleSearchService",
"ExaService",
"TavilyService",
# Shared content research provider
"ExaContentResearchProvider",
"get_exa_content_provider",
# Core Research Engine (v2.0)
"ResearchEngine",
"ResearchContext",
"ResearchPersonalizationContext",
"ContentType",
"ResearchGoal",
"ResearchDepth",
"ProviderPreference",
"ParameterOptimizer",
]