Skip to content

Commit 4659cb1

Browse files
authored
Merge pull request #17 from ELMOURABEA/copilot/fix-error-and-test-repo
Fix example crashes when monetization blocks research operations
2 parents c03566d + 978c6b4 commit 4659cb1

4 files changed

Lines changed: 30 additions & 12 deletions

File tree

examples/advanced_research.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ async def advanced_research():
3232
print(f"\nResearching: {topic}")
3333
result = await bot.research(topic, depth="deep")
3434

35-
print(f" Platforms: {', '.join(result['platforms_used'])}")
36-
print(f" Findings: {result['synthesis'].get('total_findings', 0)}")
37-
print(f" Sources: {len(result['aggregated_sources'])}")
38-
39-
# Show key insights
40-
if 'key_insights' in result['synthesis']:
41-
print(" Key insights:")
42-
for insight in result['synthesis']['key_insights'][:2]:
43-
print(f" - [{insight['platform']}] {insight['insight'][:60]}...")
35+
if 'error' in result:
36+
print(f" Error: {result['error']}")
37+
else:
38+
print(f" Platforms: {', '.join(result['platforms_used'])}")
39+
print(f" Findings: {result['synthesis'].get('total_findings', 0)}")
40+
print(f" Sources: {len(result.get('aggregated_sources', []))}")
41+
42+
# Show key insights
43+
if 'key_insights' in result['synthesis']:
44+
print(" Key insights:")
45+
for insight in result['synthesis']['key_insights'][:2]:
46+
print(f" - [{insight['platform']}] {insight['insight'][:60]}...")
4447

4548
# Comprehensive workflow
4649
print("\n" + "=" * 80)

examples/basic_usage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ async def basic_example():
3535
print("\n2. Research Example")
3636
print("-" * 80)
3737
research = await bot.research("neural networks", depth="medium")
38-
print(f"Research topic: {research['topic']}")
39-
print(f"Platforms used: {len(research['platforms_used'])}")
40-
print(f"Total findings: {research['synthesis'].get('total_findings', 0)}")
38+
if 'error' in research:
39+
print(f"Research error: {research['error']}")
40+
else:
41+
print(f"Research topic: {research['topic']}")
42+
print(f"Platforms used: {len(research['platforms_used'])}")
43+
print(f"Total findings: {research['synthesis'].get('total_findings', 0)}")
4144

4245
# Example 3: Get status
4346
print("\n3. Bot Status")

examples/monetization_example.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Demonstrates the v1.2.0 monetization and advertising system
44
"""
55
import asyncio
6+
import sys
7+
import os
8+
9+
# Add parent directory to path
10+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11+
612
from megabot import MegaBot, Config, MonetizationManager
713

814

examples/validation_example.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Demonstrates validation and logging features introduced in v1.1.0 and available in v1.2.0
44
"""
55
import asyncio
6+
import sys
7+
import os
8+
9+
# Add parent directory to path
10+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11+
612
from megabot import MegaBot, Config, setup_logging, validate_query, validate_topic
713

814

0 commit comments

Comments
 (0)