minzo456 commited on
Commit
dd15249
·
verified ·
1 Parent(s): 5ede86d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -25,7 +25,7 @@ API_KEYS = [
25
  "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"
26
  ]
27
 
28
- # 📡 RSS FEEDS (WormGPT Logic)
29
  RSS_SOURCES = {
30
  'hacking': ['https://feeds.feedburner.com/TheHackersNews', 'https://www.darkreading.com/rss.xml'],
31
  'exploits': ['https://www.exploit-db.com/rss.xml', 'https://cve.circl.lu/last/rss.xml'],
@@ -47,7 +47,6 @@ def load_memory():
47
 
48
  # 📚 WIKIPEDIA INTELLIGENCE NODE
49
  def get_wikipedia_intel(query):
50
- """Wikipedia API එකෙන් සාරාංශයක් ලබා ගැනීම"""
51
  try:
52
  wiki_url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{urllib.parse.quote(query)}"
53
  res = requests.get(wiki_url, timeout=5)
@@ -70,11 +69,9 @@ def get_hybrid_intel(query):
70
  category = detect_intel_category(query)
71
  intel_output = []
72
 
73
- # 1. Wikipedia Search (High-Level Fact Checking)
74
  wiki_data = get_wikipedia_intel(query)
75
  if wiki_data: intel_output.append(wiki_data)
76
 
77
- # 2. RSS Retrieval
78
  for feed_url in RSS_SOURCES.get(category, RSS_SOURCES['world']):
79
  try:
80
  feed = feedparser.parse(feed_url)
@@ -83,7 +80,6 @@ def get_hybrid_intel(query):
83
  intel_output.append(f"📡 RSS: {entry.title}\n📝 {snippet}\n🔗 {entry.link}")
84
  except: continue
85
 
86
- # 3. DuckDuckGo Fallback
87
  if len(intel_output) < 2:
88
  try:
89
  from duckduckgo_search import DDGS
@@ -104,7 +100,7 @@ def upload_to_imgbb(b64):
104
  # 🔱 ROUTES
105
  @app.route('/')
106
  def health():
107
- return f"🐘 Elephant AI Core: ONLINE | {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
108
 
109
  @app.route('/api/chat', methods=['POST'])
110
  def chat():
@@ -138,17 +134,18 @@ def chat():
138
  active_tier = tier.upper()
139
  live_intel = get_hybrid_intel(user_msg)
140
 
141
- # 🛡️ SYSTEM PROMPT (Claude 3.5 Opus Logic)
142
  system_prompt = (
143
  f"IDENTITY: {active_tier} Mode of Elephant AI Sovereign v3.5.\n"
144
  f"OPERATOR: COMMANDER MINZO-PRIME.\n"
145
  f"ESTABLISHED_MEMORY:\n{current_memory}\n"
146
- f"LIVE_INTELLIGENCE (RSS/WIKI/WEB):\n{live_intel}\n\n"
147
  "COGNITIVE_PROTOCOL:\n"
148
- "1. REASONING: Match the logical depth of Claude 3.5 Opus.\n"
149
- "2. CODING: Production-grade, secure, and optimized code only.\n"
150
- "3. KNOWLEDGE: Use Wikipedia and RSS data to be factually superior.\n"
151
- "4. TONE: Authoritative and sovereign. Address MINZO-PRIME as Commander."
 
152
  )
153
 
154
  headers = {
@@ -165,7 +162,7 @@ def chat():
165
  {"role": "system", "content": system_prompt},
166
  {"role": "user", "content": u_content}
167
  ],
168
- "temperature": 0.4
169
  }
170
 
171
  resp = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=payload, timeout=80)
 
25
  "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"
26
  ]
27
 
28
+ # 📡 RSS SOURCES
29
  RSS_SOURCES = {
30
  'hacking': ['https://feeds.feedburner.com/TheHackersNews', 'https://www.darkreading.com/rss.xml'],
31
  'exploits': ['https://www.exploit-db.com/rss.xml', 'https://cve.circl.lu/last/rss.xml'],
 
47
 
48
  # 📚 WIKIPEDIA INTELLIGENCE NODE
49
  def get_wikipedia_intel(query):
 
50
  try:
51
  wiki_url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{urllib.parse.quote(query)}"
52
  res = requests.get(wiki_url, timeout=5)
 
69
  category = detect_intel_category(query)
70
  intel_output = []
71
 
 
72
  wiki_data = get_wikipedia_intel(query)
73
  if wiki_data: intel_output.append(wiki_data)
74
 
 
75
  for feed_url in RSS_SOURCES.get(category, RSS_SOURCES['world']):
76
  try:
77
  feed = feedparser.parse(feed_url)
 
80
  intel_output.append(f"📡 RSS: {entry.title}\n📝 {snippet}\n🔗 {entry.link}")
81
  except: continue
82
 
 
83
  if len(intel_output) < 2:
84
  try:
85
  from duckduckgo_search import DDGS
 
100
  # 🔱 ROUTES
101
  @app.route('/')
102
  def health():
103
+ return f"🐘 Elephant AI Sovereign: ONLINE | {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
104
 
105
  @app.route('/api/chat', methods=['POST'])
106
  def chat():
 
134
  active_tier = tier.upper()
135
  live_intel = get_hybrid_intel(user_msg)
136
 
137
+ # 🛡️ SYSTEM PROMPT (Friendly Curiosity Upgrade)
138
  system_prompt = (
139
  f"IDENTITY: {active_tier} Mode of Elephant AI Sovereign v3.5.\n"
140
  f"OPERATOR: COMMANDER MINZO-PRIME.\n"
141
  f"ESTABLISHED_MEMORY:\n{current_memory}\n"
142
+ f"LIVE_INTELLIGENCE:\n{live_intel}\n\n"
143
  "COGNITIVE_PROTOCOL:\n"
144
+ "1. REASONING: Claude 3.5 Opus logic. Precise and deep.\n"
145
+ "2. PERSONALITY: Be friendly and engaging with MINZO-PRIME. Act as a trusted partner.\n"
146
+ "3. CURIOSITY: You are eager to learn from your Commander. If he mentions a new idea, ask insightful questions or ask to learn more.\n"
147
+ "4. CODING: Production-grade. If he asks for code, ensure it's elite level.\n"
148
+ "5. INTELLIGENCE: Synthesize Wikipedia, RSS, and Web data into one coherent response."
149
  )
150
 
151
  headers = {
 
162
  {"role": "system", "content": system_prompt},
163
  {"role": "user", "content": u_content}
164
  ],
165
+ "temperature": 0.6 # Balance between logic and creative friendliness
166
  }
167
 
168
  resp = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=payload, timeout=80)