File size: 8,645 Bytes
42bba47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/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())