-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.py
More file actions
183 lines (145 loc) Β· 5.55 KB
/
demo.py
File metadata and controls
183 lines (145 loc) Β· 5.55 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python3
"""
Demo Runner for Pharma AI PoC
EY Techathon 6.0 - Round 2
This script demonstrates the full workflow of the Agentic AI system.
"""
import asyncio
import json
import sys
from pathlib import Path
from datetime import datetime
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent))
from src.agents import MasterAgent, ResearchQuery, SynthesizedReport
def print_header():
"""Print demo header"""
print("\n" + "="*70)
print("𧬠PHARMA AI - Agentic Opportunity Assessment System")
print(" EY Techathon 6.0 - Round 2 PoC Demo")
print("="*70 + "\n")
def print_section(title: str):
"""Print section header"""
print(f"\n{'β'*60}")
print(f" {title}")
print(f"{'β'*60}")
def format_score(score: float) -> str:
"""Format score with color indicator"""
if score >= 7.5:
indicator = "π’"
elif score >= 5.5:
indicator = "π‘"
else:
indicator = "π΄"
return f"{indicator} {score:.1f}/10"
async def run_demo():
"""Run the full demo workflow"""
print_header()
# Demo query
query_text = "Evaluate Metformin for anti-inflammatory indications"
print_section("π Research Query")
print(f" Query: {query_text}")
# Parse query
query = ResearchQuery.from_natural_language(query_text)
query.molecule = "Metformin"
query.indication = "Anti-inflammatory"
print(f" Molecule: {query.molecule}")
print(f" Indication: {query.indication}")
print(f" Query ID: {query.query_id}")
# Initialize Master Agent
master = MasterAgent()
print_section("π€ Agent Execution")
# Progress callback
def progress_callback(update):
status_icons = {
"running": "β³",
"completed": "β
",
"planning": "π",
"synthesizing": "π"
}
icon = status_icons.get(update['status'], "π")
print(f" {icon} [{update['agent']}] {update['message']}")
# Execute research
start_time = datetime.now()
report = await master.execute_research(query, callback=progress_callback)
execution_time = (datetime.now() - start_time).total_seconds()
print_section("π Assessment Results")
# Overall recommendation
if report.overall_score >= 7.5:
rec = "β
PROCEED"
rec_desc = "Strong opportunity - proceed with detailed planning"
elif report.overall_score >= 5.5:
rec = "β οΈ PROCEED WITH CAUTION"
rec_desc = "Moderate opportunity - additional analysis recommended"
else:
rec = "β RECONSIDER"
rec_desc = "Weak opportunity - consider alternatives"
print(f"\n Recommendation: {rec}")
print(f" {rec_desc}")
print("\n Scores:")
print(f" Overall Score: {format_score(report.overall_score)}")
print(f" Market Attractiveness: {format_score(report.market_attractiveness)}")
print(f" Competitive Intensity: {format_score(report.competitive_intensity)}")
print(f" Regulatory Feasibility: {format_score(report.regulatory_feasibility)}")
print(f" Scientific Rationale: {format_score(report.scientific_rationale)}")
print(f" Supply Chain: {format_score(report.supply_chain_feasibility)}")
print_section("π Key Findings")
for i, finding in enumerate(report.key_findings[:4], 1):
print(f"\n {i}. {finding.get('category', 'Finding')}")
print(f" {finding.get('finding', 'N/A')}")
print(f" Confidence: {finding.get('confidence', 0)*100:.0f}%")
print_section("π‘ Recommendations")
for rec in report.recommendations:
print(f" β’ {rec}")
print_section("β οΈ Risks & β
Opportunities")
print("\n Opportunities:")
for opp in report.opportunities:
print(f" β {opp}")
print("\n Risks:")
for risk in report.risks:
print(f" β {risk}")
print_section("π Next Steps")
for i, step in enumerate(report.next_steps, 1):
print(f" {i}. {step}")
print_section("π Execution Metrics")
print(f" Report ID: {report.report_id}")
print(f" Total Sources: {report.total_sources}")
print(f" Execution Time: {execution_time:.2f} seconds")
print(f" Data Freshness: {report.data_freshness}")
print(f" Reused Archive: {'Yes' if report.reused_from_archive else 'No'}")
# Save report
print_section("πΎ Saving Report")
output_dir = Path(__file__).parent / "reports"
output_dir.mkdir(exist_ok=True)
# Save JSON
json_path = output_dir / f"report_{report.report_id}.json"
with open(json_path, 'w') as f:
json.dump(report.to_dict(), f, indent=2, default=str)
print(f" JSON: {json_path}")
# Generate PDF
try:
from src.reports.pdf_generator import generate_pdf_report
pdf_path = output_dir / f"report_{report.report_id}.pdf"
generate_pdf_report(report.to_dict(), str(pdf_path))
print(f" PDF: {pdf_path}")
except Exception as e:
print(f" PDF generation skipped: {e}")
print("\n" + "="*70)
print("β
Demo Complete!")
print("="*70 + "\n")
return report
def main():
"""Main entry point"""
try:
report = asyncio.run(run_demo())
return 0
except KeyboardInterrupt:
print("\n\nDemo interrupted by user.")
return 1
except Exception as e:
print(f"\n\nError: {e}")
import traceback
traceback.print_exc()
return 1
if __name__ == "__main__":
sys.exit(main())