Spaces:
Sleeping
Sleeping
Update app.py
Browse files142 unmodified lines143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213142 unmodified lines# AI ANALYSIS# =========================================================def ask_ai(ta, symbol, question):if not OPENROUTER_API_KEY:return "❌ OPENROUTER_API_KEY belum diset"try:payload = {"model": MODEL_NAME,"messages": [{"role": "system","content": """Kamu adalah AI trading assistant profesional.Natural.Tidak kaku.Seperti analis crypto manusia profesional.Berikan insight trading yang berguna."""},{"role": "user","content": f"""MARKET DATA:{ta}QUESTION:{question}"""}],"temperature": 0.7,"max_tokens": 1200}headers = {"Authorization": (f"Bearer {OPENROUTER_API_KEY}"),"Content-Type": "application/json"}response = requests.post(OPENROUTER_URL,headers=headers,json=payload,timeout=60)response.raise_for_status()data = response.json()return data["choices"][0]["message"]["content"]except Exception as e:logger.error(e)return f"❌ AI Error: {e}"# =========================================================# MAIN ANALYSIS# =========================================================142 unmodified lines143144145146147148149142 unmodified lines# AI ANALYSIS# =========================================================from ai_engine import ask_ai# =========================================================# MAIN ANALYSIS# =========================================================
app.py+1-65