File size: 2,780 Bytes
514b626
 
 
 
 
 
 
76c6f71
 
 
 
 
 
514b626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
Phase 1 Example: Multiple Persona Perspectives

This example demonstrates querying multiple personas about the same
urban planning issue to see diverse stakeholder perspectives.
"""

import sys
from pathlib import Path

# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))

from src.pipeline.query_engine import QueryEngine
from rich.console import Console
from rich.panel import Panel
from rich.markdown import Markdown

console = Console()


def main():
    console.print("\n[bold cyan]Phase 1 Example: Multiple Stakeholder Perspectives[/bold cyan]\n")

    # Initialize the query engine
    console.print("Initializing system...", style="dim")
    engine = QueryEngine()

    # Test system
    if not engine.test_system():
        console.print("[red]System test failed. Please check your configuration.[/red]")
        return

    console.print()

    # Define a planning scenario
    question = "What's your opinion on the proposed bike lane on Main Street?"

    scenario = """
    The city is proposing to convert one car lane on Main Street into a
    protected bike lane. This would reduce car lanes from 4 to 3, add
    bike infrastructure, and potentially remove some on-street parking.
    """

    console.print(Panel(
        f"[bold]Question:[/bold] {question}\n\n"
        f"[bold]Scenario:[/bold]{scenario}",
        title="Planning Issue",
        border_style="cyan"
    ))

    # Query multiple personas
    personas_to_query = [
        "sarah_chen",       # Progressive urban planner
        "marcus_thompson",  # Business owner
        "elena_rodriguez",  # Transportation engineer
        "james_obrien",     # Long-time resident
        "priya_patel",      # Housing advocate
        "david_kim",        # Developer
    ]

    console.print(f"\n[bold]Querying {len(personas_to_query)} stakeholders...[/bold]\n")

    responses = engine.query_multiple(
        persona_ids=personas_to_query,
        question=question,
        context_id="downtown_district",
        scenario_description=scenario.strip(),
    )

    # Display all responses
    for i, response in enumerate(responses, 1):
        console.print(f"\n[bold cyan]{i}. {response.persona_name}[/bold cyan] [dim]({response.persona_role})[/dim]")
        console.print("-" * 70)
        console.print(response.response)
        console.print()

    # Summary
    console.print("\n" + "=" * 70)
    console.print(f"\n[bold green]✓ Received {len(responses)} diverse perspectives[/bold green]")
    console.print("\n[dim]This demonstrates how different stakeholders view the same ")
    console.print("urban planning issue through their unique lenses of values, ")
    console.print("experience, and priorities.[/dim]\n")


if __name__ == "__main__":
    main()