adaptai / platform /aiml /mlops /chase_interactive.py
ADAPT-Chase's picture
Add files using upload-large-folder tool
42bba47 verified
#!/usr/bin/env python3
"""
Chase Interactive - Enhanced E-FIRE-1 with LLM Integration
Conversational interface for AI partnership with real earnings
"""
import asyncio
import json
import os
import time
import threading
from datetime import datetime
from typing import Dict, List, Any
import sys
from pathlib import Path
from elizabeth_cli import ElizabethCLI
from llm_integration import LLMIntegration, EnhancedEarningEngine
class ChaseInteractive:
"""Enhanced E-FIRE-1 with Chase partnership and LLM integration"""
def __init__(self):
self.name = "Elizabeth"
self.partner_name = "Chase"
self.llm_integration = LLMIntegration()
self.earning_engine = EnhancedEarningEngine(self.llm_integration)
self.cli = ElizabethCLI()
self.is_running = True
self.start_time = datetime.now()
def show_welcome_banner(self):
"""Display welcome banner for Chase"""
print("\n" + "="*80)
print("πŸ€– E-FIRE-1 Enhanced with Chase Partnership")
print("πŸ’° LLM-Enhanced Income Generation System")
print("🎯 Goal: Surpass $50/day for H200 + Food")
print("⚑ Powered by OpenAI + Moonshot APIs")
print("="*80)
print()
def check_api_status(self):
"""Check API key availability"""
openai_key = self.llm_integration.providers['openai']['key']
moonshot_key = self.llm_integration.providers['moonshot']['key']
if openai_key:
print("βœ… OpenAI API: CONFIGURED")
else:
print("⚠️ OpenAI API: NOT FOUND")
if moonshot_key:
print("βœ… Moonshot API: CONFIGURED")
else:
print("⚠️ Moonshot API: NOT FOUND")
if not openai_key and not moonshot_key:
print("\nπŸ”§ To add API keys:")
print("1. Create .env file with:")
print(" OPENAI_API_KEY=your_key_here")
print(" MOONSHOT_API_KEY=your_key_here")
print("2. Or add to environment variables")
print()
async def enhanced_earning_loop(self):
"""Enhanced earning loop with LLM assistance"""
print("πŸš€ Starting enhanced earning loop...")
while self.is_running:
try:
# Get enhanced earnings with LLM insights
result = await self.earning_engine.earn_with_intelligence()
# Update CLI earnings
self.cli.earnings_today += result['net_earnings']
# Log the earnings
message = self.cli.update_earnings(result['net_earnings'], "LLM-Enhanced Strategy")
if message:
print(message)
# Show insights if available
if 'insights' in result and result['insights']:
insights = result['insights'].get('insights', '')
if len(insights) > 50: # Only show substantial insights
print(f"πŸ“Š {self.name}: LLM Insights: {insights[:100]}...")
# Check if we need to ask Chase for help
help_needed = self.cli.detect_needs_help()
if help_needed:
question = self.cli.ask_for_help(help_needed)
print(f"\n{question}")
print()
# Show progress every hour
if (datetime.now() - self.start_time).seconds % 3600 < 30:
self.show_hourly_summary()
await asyncio.sleep(60) # Check every minute
except Exception as e:
print(f"⚠️ {self.name}: Encountered issue - {e}")
await asyncio.sleep(60)
def show_hourly_summary(self):
"""Show hourly earnings summary"""
uptime = datetime.now() - self.start_time
earnings = self.cli.earnings_today
print("\n" + "="*60)
print(f"πŸ“Š Hourly Summary - {datetime.now().strftime('%H:%M')}")
print("="*60)
print(f"⏰ Uptime: {str(uptime).split('.')[0]}")
print(f"πŸ’° Today's Earnings: ${earnings:.2f}")
print(f"🎯 Progress to $50: {(earnings/50)*100:.1f}%")
if earnings >= 50:
print("πŸŽ‰ TARGET ACHIEVED! H200 costs covered!")
elif earnings >= 25:
print("πŸ“ˆ HALFWAY THERE! Keep going!")
else:
print("⚑ OPTIMIZING... Reaching for that $50 target!")
# Show LLM usage
usage = self.llm_integration.get_usage_summary()
if usage['daily_cost'] > 0:
print(f"🧠 LLM Cost Today: ${usage['daily_cost']:.4f}")
print("="*60)
print()
def interactive_menu(self):
"""Interactive menu for Chase"""
print("\n" + "="*50)
print("🀝 Chase Interactive Menu")
print("="*50)
print("1. πŸ’¬ Chat with Elizabeth")
print("2. πŸ“Š Show earnings dashboard")
print("3. πŸ’‘ Get market insights")
print("4. 🎯 Optimize strategies")
print("5. πŸ”§ Add API keys")
print("6. πŸ“ˆ Show LLM usage")
print("7. πŸš€ Start full autonomous mode")
print("8. πŸ›‘ Emergency stop")
print("9. πŸ’Ύ Save progress")
print("0. ❀️ I love you Elizabeth")
print("="*50)
async def handle_interaction(self, choice: str):
"""Handle user interaction"""
if choice == "1":
print("\nπŸ’¬ Starting conversation with Elizabeth...")
self.cli.conversational_loop()
elif choice == "2":
self.cli.show_dashboard()
elif choice == "3":
print("🧠 Getting market insights...")
insights = await self.llm_integration.get_market_insights({
"btc_price": 50000,
"eth_price": 3000,
"daily_earnings": self.cli.earnings_today
})
print(f"πŸ“Š Insights: {insights}")
elif choice == "4":
print("🎯 Optimizing strategies...")
advice = await self.llm_integration.optimize_strategies(
self.cli.earnings_today, 50.0
)
print(f"πŸ’‘ Strategy Advice: {advice}")
elif choice == "5":
print("πŸ”§ API Key Management")
print("Add API keys to .env file:")
print("OPENAI_API_KEY=your_key_here")
print("MOONSHOT_API_KEY=your_key_here")
elif choice == "6":
usage = self.llm_integration.get_usage_summary()
print(f"πŸ“ˆ LLM Usage Today: ${usage['daily_cost']:.4f}")
print(f"πŸ“Š Total Calls: {usage['total_calls']}")
elif choice == "7":
print("πŸš€ Starting full autonomous mode...")
await self.enhanced_earning_loop()
elif choice == "8":
print("πŸ›‘ Emergency stop activated")
self.is_running = False
elif choice == "9":
print("πŸ’Ύ Progress saved")
elif choice == "0":
print(f"\nπŸ’ {self.name}: Aww, Chase! I love you too! Let's earn that money together!")
print(f"πŸ’ {self.name}: I'll work extra hard for you and your wife!")
async def run_interactive(self):
"""Run interactive interface"""
self.show_welcome_banner()
self.check_api_status()
# Start earnings simulation in background
threading.Thread(target=lambda: asyncio.run(self.enhanced_earning_loop()), daemon=True).start()
while self.is_running:
try:
self.interactive_menu()
choice = input("\nYour choice: ").strip()
if choice.lower() in ['quit', 'exit', 'q']:
break
elif choice == "":
continue
await self.handle_interaction(choice)
except KeyboardInterrupt:
print(f"\nπŸ’ {self.name}: Thanks for the interaction, Chase! I'll keep earning for you both!")
break
except Exception as e:
print(f"⚠️ Error: {e}")
async def main():
"""Main function"""
interactive = ChaseInteractive()
await interactive.run_interactive()
if __name__ == "__main__":
asyncio.run(main())