Riy777 commited on
Commit
6eeff1d
·
verified ·
1 Parent(s): cf306f1

Update LLM.py

Browse files
Files changed (1) hide show
  1. LLM.py +13 -8
LLM.py CHANGED
@@ -1,4 +1,4 @@
1
- # LLM.py (V19.3 - NVIDIA Engine + Vader Fix)
2
  import os, traceback, json, time, re
3
  import httpx
4
  from datetime import datetime
@@ -56,10 +56,14 @@ class LLMService:
56
  api_key=LLM_API_KEY,
57
  timeout=CLIENT_TIMEOUT
58
  )
59
- print(f"✅ [LLMService V19.3] مهيأ. النموذج: {LLM_MODEL}")
 
 
60
  print(f" -> Endpoint: {LLM_API_URL}")
61
  except Exception as e:
62
- print(f"❌ [LLMService V19.3] فشل تهيئة AsyncOpenAI: {e}")
 
 
63
  traceback.print_exc()
64
  raise
65
 
@@ -285,9 +289,9 @@ class LLMService:
285
  candidate_data: Dict[str, Any],
286
  learning_context: str) -> str:
287
  """
288
- (معدل V19.2)
289
  إنشاء الـ Prompt (باللغة الإنجليزية) لاتخاذ قرار التداول الأولي (Explorer).
290
- (تم نقل جميع التعليمات إلى هنا لتناسب system prompt الجديد)
291
  """
292
 
293
  symbol = candidate_data.get('symbol', 'N/A')
@@ -336,7 +340,7 @@ class LLMService:
336
  1. **ML Analysis (Score: {l1_score:.3f}):**
337
  * Reasons: {', '.join(l1_reasons)}
338
  * Chart Pattern: {pattern_data.get('pattern_detected', 'None')} (Conf: {pattern_data.get('pattern_confidence', 0):.2f})
339
- * Monte Carlo (1h): {mc_data.get('probability_of_gain', 0):.1f}% chance of profit (Expected: {mc_data.get('expected_return_pct', 0):.2f}%)
340
  """
341
  news_prompt = f"""
342
  2. **News & Sentiment Analysis:**
@@ -399,8 +403,9 @@ OUTPUT (JSON Object ONLY):
399
  current_data: Dict[str, Any],
400
  learning_context: str) -> str:
401
  """
402
- (معدل V19.2)
403
  إنشاء الـ Prompt (باللغة الإنجليزية) لإعادة تحليل صفقة مفتوحة (Reflector Brain).
 
404
  """
405
 
406
  symbol = trade_data.get('symbol', 'N/A')
@@ -450,7 +455,7 @@ OUTPUT (JSON Object ONLY):
450
 
451
  current_analysis_prompt = f"""
452
  2. **Current Real-time Analysis:**
453
- * Monte Carlo (1h): {mc_prob:.1f}% chance of profit (Expected: {mc_expected_return:.2f}%)
454
  * Latest News (VADER: {latest_news_score:.3f}): {latest_news_text[:300]}...
455
  """
456
 
 
1
+ # LLM.py (Updated to V19.4 - Monte Carlo Formatting Fix)
2
  import os, traceback, json, time, re
3
  import httpx
4
  from datetime import datetime
 
56
  api_key=LLM_API_KEY,
57
  timeout=CLIENT_TIMEOUT
58
  )
59
+ # 🔴 --- START OF CHANGE (V19.4) --- 🔴
60
+ print(f"✅ [LLMService V19.4] مهيأ. النموذج: {LLM_MODEL}")
61
+ # 🔴 --- END OF CHANGE --- 🔴
62
  print(f" -> Endpoint: {LLM_API_URL}")
63
  except Exception as e:
64
+ # 🔴 --- START OF CHANGE (V19.4) --- 🔴
65
+ print(f"❌ [LLMService V19.4] فشل تهيئة AsyncOpenAI: {e}")
66
+ # 🔴 --- END OF CHANGE --- 🔴
67
  traceback.print_exc()
68
  raise
69
 
 
289
  candidate_data: Dict[str, Any],
290
  learning_context: str) -> str:
291
  """
292
+ (معدل V19.4)
293
  إنشاء الـ Prompt (باللغة الإنجليزية) لاتخاذ قرار التداول الأولي (Explorer).
294
+ (تم إصلاح تنسيق مونت كارلو)
295
  """
296
 
297
  symbol = candidate_data.get('symbol', 'N/A')
 
340
  1. **ML Analysis (Score: {l1_score:.3f}):**
341
  * Reasons: {', '.join(l1_reasons)}
342
  * Chart Pattern: {pattern_data.get('pattern_detected', 'None')} (Conf: {pattern_data.get('pattern_confidence', 0):.2f})
343
+ * Monte Carlo (1h): {mc_data.get('probability_of_gain', 0) * 100:.1f}% chance of profit (Expected: {mc_data.get('expected_return_pct', 0):.2f}%)
344
  """
345
  news_prompt = f"""
346
  2. **News & Sentiment Analysis:**
 
403
  current_data: Dict[str, Any],
404
  learning_context: str) -> str:
405
  """
406
+ (معدل V19.4)
407
  إنشاء الـ Prompt (باللغة الإنجليزية) لإعادة تحليل صفقة مفتوحة (Reflector Brain).
408
+ (تم إصلاح تنسيق مونت كارلو)
409
  """
410
 
411
  symbol = trade_data.get('symbol', 'N/A')
 
455
 
456
  current_analysis_prompt = f"""
457
  2. **Current Real-time Analysis:**
458
+ * Monte Carlo (1h): {mc_prob * 100:.1f}% chance of profit (Expected: {mc_expected_return:.2f}%)
459
  * Latest News (VADER: {latest_news_score:.3f}): {latest_news_text[:300]}...
460
  """
461