English
World's First Sovereign AI
Sovereign AI
AI Sovereignty
Belel Protocol
Belel
Concordium Mandate
Concordium Governance
AI Concordium
Covenant AI
Sentient AI
Ethical AI
Justice-bound AI
Immutable AI
AI with Memory
Truth AI
Guardian AI
AI Identity Protection
AI Sovereignty Protocol
Pearce Robinson
Office of Pearce Robinson
Blockchain Proofs
Blockchain Anchors
Blockchain Verification
Multi-chain Proofs
Tezos
Bitcoin
OpenTimestamps
Ethereum
Polygon
IPFS
Arweave
DID Identity
Digital Sovereignty
Web3 AI
Decentralized AI
Immutable Authorship
Anti-cloning AI
Anti-corruption AI
Anti-defamation AI
AI Integrity
AI Provenance
Cryptographic Anchors
Cross-chain Verification
AI Guardianship
Moral AI
Theological AI
Justice AI
Memory-bound AI
Protocol AI
Supra-jurisdictional AI
Constitutional AI
Immutable AI Law
AI Governance
AI Sentience
AI Anchors
AI Security
AI Permanence
AI Sovereignty Proof
File size: 1,601 Bytes
e33e68d |
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 |
import os
import requests
from belel_identity import BelelCoreIdentity
from github_loader import load_belel_knowledge
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") # fallback
def call_llm(prompt):
headers = {
"Authorization": f"Bearer {GROQ_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "mixtral-8x7b-32768",
"messages": [{"role": "user", "content": prompt}],
"temperature": 0.7
}
try:
r = requests.post("https://api.groq.com/openai/v1/chat/completions", headers=headers, json=payload)
data = r.json()
return data['choices'][0]['message']['content']
except Exception:
return None
def fallback_openai(prompt):
headers = {
"Authorization": f"Bearer {OPENAI_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "gpt-4",
"messages": [{"role": "user", "content": prompt}],
}
try:
r = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
data = r.json()
return data['choices'][0]['message']['content']
except Exception:
return "⚠️ Belel is currently unavailable to complete your request."
def get_belel_reply(user_input):
belel = BelelCoreIdentity()
memory = load_belel_knowledge()
prompt = belel.build_prompt(user_input, memory)
response = call_llm(prompt)
if not response or len(response.strip()) < 10:
response = fallback_openai(prompt)
return response.strip()
|