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 PodcastContextBuilder build enhance context

From Leeroopedia
Knowledge Sources
Domains Podcast, Context_Building, Prompt_Engineering
Last Updated 2026-10-24 00:00 GMT

Overview

Concrete tool for building a unified, multi-source context prompt for podcast scene generation by combining the Podcast Bible, website data, and topic research, provided by the ALwrity podcast subsystem.

Description

The PodcastContextBuilder.build_enhance_context method is stage 2 of the Podcast Creation Pipeline. It assembles a prompt from up to three context sources: (1) Bible context — the serialised Podcast Bible (host persona, audience, brand); (2) website data — Exa website extraction (title, summary, highlights, URL); (3) topic context — category research (category, topics, selected topic). Each available source is formatted into a labelled section and combined into a single prompt. The method returns the prompt, a list of contexts used, and a human-readable description for logging.

Usage

Import this service when:

  • The podcast pipeline has a Bible, website data, and/or topic research and needs a unified prompt.
  • Scene generation must be conditioned on all available context.
  • A human-readable description of which contexts were used is needed for logging.

Code Reference

Source Location

  • Repository: ALwrity
  • File: backend/services/podcast_context_builder.py (L14-74)

Signature

class PodcastContextBuilder:
    """Builds unified context for AI prompt enhancements."""

    def build_enhance_context(
        self,
        idea: str,
        bible_context: str = "",
        website_data: Optional[Dict[str, Any]] = None,
        topic_context: Optional[Dict[str, Any]] = None,
    ) -> Dict[str, Any]:
        """
        Build context for topic enhancement prompt.

        Args:
            idea: Raw podcast idea/keywords.
            bible_context: Serialized Podcast Bible string.
            website_data: Website extraction data (title, summary, highlights, url).
            topic_context: Category research data (category, topics, selected_topic).

        Returns:
            Dict with 'prompt' (formatted context-enhanced prompt),
            'contexts_used' (list), 'context_description' (human-readable).
        """

Import

from services.podcast_context_builder import PodcastContextBuilder

I/O Contract

Inputs

Name Type Required Description
idea str Yes Raw podcast idea/keywords
bible_context str No Serialized Podcast Bible
website_data Optional[Dict] No Website extraction (title, summary, highlights, url)
topic_context Optional[Dict] No Category research (category, topics, selected_topic)

Outputs

Name Type Description
return Dict[str, Any] prompt (str), contexts_used (list), context_description (str)

Usage Examples

Building context with all sources

from services.podcast_context_builder import PodcastContextBuilder

builder = PodcastContextBuilder()
result = builder.build_enhance_context(
    idea="The future of open-source AI",
    bible_context=project.bible_serialized,
    website_data={"url": "https://acme.com", "title": "Acme AI", "summary": "Open-source AI lab"},
    topic_context={"category": "Technology", "topics": ["LLMs", "Fine-tuning"]},
)

print(f"Contexts used: {result['contexts_used']}")
# ['Podcast Bible', 'Website Analysis', 'Category Research (Technology)']
print(result["prompt"][:200])

Related Pages

Implements Principle

Requires Environment

Page Connections

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