-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpipeline.py
More file actions
71 lines (57 loc) · 2.62 KB
/
pipeline.py
File metadata and controls
71 lines (57 loc) · 2.62 KB
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
#!/usr/bin/env python3
"""Demo pipeline showing how to create and use a podcast flow."""
import json
from pathlib import Path
# Import the custom flow
from flows.podcast_flow.flow import PodcastFlow
from quantmind.config.settings import load_config
def main():
"""Run the podcast flow demo."""
print("=== Custom Flow Demo: Podcast Flow ===")
print()
# Step 1: Load configuration from YAML using QuantMind settings
config_path = Path(__file__).parent / "config.yaml"
settings = load_config(config_path)
# Step 2: Get the podcast flow configuration and convert to PodcastFlowConfig
config = settings.flows["podcast_flow"]
print(f"📁 Flow name: {config.name}")
print(f"📁 Templates path: {config.prompt_templates_path}")
print(f"✓ Loaded {len(config.prompt_templates)} prompt templates")
print(f"✓ Configured {len(config.llm_blocks)} LLM blocks")
print()
# Step 3: Initialize the flow
try:
flow = PodcastFlow(config)
print("✓ Flow initialized successfully")
except Exception as e:
print(f"✗ Flow initialization failed: {e}")
print("This is expected without proper API configuration")
return
# Step 4: Run the flow with sample data
sample_inputs = [
{
"summary": "Artificial Intelligence is transforming healthcare in unprecedented ways. Machine learning algorithms can now diagnose diseases with accuracy rates exceeding human doctors. AI-powered imaging systems detect early-stage cancers that might be missed by traditional methods.",
}
]
for i, input_data in enumerate(sample_inputs, 1):
print(f"\n--- Processing Podcast {i}: {input_data['summary']} ---")
try:
result = flow.run(summary=input_data["summary"])
assert isinstance(
result, dict
), "Flow output should be a dictionary"
with open(f"podcast_script_{i}.json", "w") as f:
json.dump(result, f, indent=4)
print(f"✓ Podcast script saved to podcast_script_{i}.json")
except Exception as e:
print(f"✗ Flow execution failed: {e}")
print("This is expected without proper API keys")
print("\n=== Demo Complete ===")
print("\nKey takeaways from this example:")
print("• Podcast flow configuration with dataclass")
print("• YAML-based prompt templates for main")
print("• Multiple LLM blocks for different content types")
print("• Python-based orchestration logic")
print("• Easy to customize and extend for different podcast styles")
if __name__ == "__main__":
main()