Spaces:
Paused
Paused
Update app.py
Browse files5 unmodified lines67891011121314151612 unmodified lines29303132333435363738394041423 unmodified lines46474849505110 unmodified lines626364656667686970717273747576777879808182835 unmodified linesfrom flask_cors import CORSfrom datetime import datetime# 🔱 DuckDuckGo Library එක Import කිරීමේදී සිදුවන Error එක වැළැක්වීමටtry:from duckduckgo_search import DDGSexcept ImportError:# මෙය Hugging Face වලදී Module එක නැවත තහවුරු කිරීමටයිos.system('pip install duckduckgo_search')from duckduckgo_search import DDGS12 unmodified linesdef fetch_duckduckgo_intel(query):intel = ""try:# 🔱 Latest version logicwith DDGS() as ddgs:results = ddgs.text(query, max_results=4)for r in results:intel += f"\n- {r['title']}: {r['body']}"except Exception as e:print(f"Search Warning: {e}")intel = "Global intelligence access restricted."return intel@app.route('/api/chat', methods=['POST'])3 unmodified linesuser_msg = data.get("message", "")tier = data.get("tier", "prime")model_map = {"prime": "minimax/minimax-m2.5:free","nexus": "tencent/hy3-preview:free"10 unmodified lines"X-Title": "Elephant AI Core"}system_prompt = f"You are {tier.upper()} mode of Elephant AI by MINZO-PRIME. Time: {current_time}. Data: {web_context}"payload = {"model": selected_model,"messages": [{"role": "system", "content": system_prompt}, {"role": "user", "content": user_msg}]}resp = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=payload, timeout=60)return jsonify({"reply": resp.json()['choices'][0]['message']['content']})except Exception as e:return jsonify({"reply": f"Core Disruption: {str(e)}"}), 500@app.route('/')def health():return "🐘 Elephant AI Core: ONLINE"if __name__ == "__main__":app.run(host='0.0.0.0', port=7860)5 unmodified lines678910111213141512 unmodified lines2829303132333435363738393 unmodified lines4344454647484910 unmodified lines60616263646566676869707172737475767778798081828384858687885 unmodified linesfrom flask_cors import CORSfrom datetime import datetime# 🔱 Stable DDGS Integrationtry:from duckduckgo_search import DDGSexcept ImportError:os.system('pip install duckduckgo_search')from duckduckgo_search import DDGS12 unmodified linesdef fetch_duckduckgo_intel(query):intel = ""try:ddgs = DDGS()results = ddgs.text(query, max_results=4)for r in results:intel += f"\n- {r['title']}: {r['body']}"except Exception as e:intel = "Web intelligence access limited."return intel@app.route('/api/chat', methods=['POST'])3 unmodified linesuser_msg = data.get("message", "")tier = data.get("tier", "prime")# 🔱 Prime: Minimax | Nexus: Tencent Hy3model_map = {"prime": "minimax/minimax-m2.5:free","nexus": "tencent/hy3-preview:free"10 unmodified lines"X-Title": "Elephant AI Core"}system_prompt = f"""You are {tier.upper()} mode of Elephant AI by MINZO-PRIME.System Time: {current_time}.Live Web Data: {web_context}Always maintain your sovereign identity."""payload = {"model": selected_model,"messages": [{"role": "system", "content": system_prompt},{"role": "user", "content": user_msg}]}resp = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=payload, timeout=60)ai_reply = resp.json()['choices'][0]['message']['content']return jsonify({"reply": ai_reply})except Exception as e:return jsonify({"reply": f"Core Disruption: {str(e)}"}), 500@app.route('/')def health():return "🐘 Elephant AI Core: ONLINE | Operator: MINZO-PRIME"if __name__ == "__main__":app.run(host='0.0.0.0', port=7860)
app.py+18-13