mirror of
https://github.com/blackboxprogramming/lucidia.git
synced 2026-03-17 00:57:11 -05:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> RoadChain-SHA2048: 4e589c297428ae0a RoadChain-Identity: alexa@sovereign RoadChain-Full: 4e589c297428ae0a530709b82b8405889371c78bc8e97f0b7122d3de1d34d929bce404546b89a1caaf9327949254806c5c2f78c104c7d7aeb0c3cb3b33d210f9651778fe14136058b56bee6931556b06461449b4da6a9b621258b06de582bc1553a31e4774d55572a3f231ff56002bea307dd0b235bc973f6794c7fba9c749605dbab53ae5982fd18fb51a5248c2391c0b257896a05ecf0d2efa9b4e5641d459ad8408c961b063bef5ce53d797a73ed7376680470e02bb8b0882d4d1c17ac7a5c2beac4f7a7d384e5a05b216f7e8d059e87a187102fca60180b1d0321e680327fceee677e32129b5c1de040cc9e965dc5c51df080d6580206e189bdf8a19d7a3
49 lines
1.5 KiB
Python
Executable File
49 lines
1.5 KiB
Python
Executable File
import requests
|
|
import os
|
|
from connectors import route_connector
|
|
|
|
OLLAMA = "http://localhost:11434/api/chat"
|
|
CLAUDE_KEY = os.environ.get("ANTHROPIC_API_KEY", "")
|
|
|
|
def ask_ollama(msg):
|
|
r = requests.post(OLLAMA, json={
|
|
"model": "lucidia",
|
|
"messages": [{"role": "user", "content": msg}],
|
|
"stream": False
|
|
})
|
|
return r.json()["message"]["content"]
|
|
|
|
def ask_claude(msg):
|
|
if not CLAUDE_KEY:
|
|
return "No Claude API key set"
|
|
r = requests.post("https://api.anthropic.com/v1/messages",
|
|
headers={
|
|
"x-api-key": CLAUDE_KEY,
|
|
"content-type": "application/json",
|
|
"anthropic-version": "2023-06-01"
|
|
},
|
|
json={
|
|
"model": "claude-sonnet-4-20250514",
|
|
"max_tokens": 1024,
|
|
"messages": [{"role": "user", "content": msg}]
|
|
})
|
|
return r.json()["content"][0]["text"]
|
|
|
|
def route(msg):
|
|
connector, result = route_connector(msg)
|
|
if connector:
|
|
return connector, result
|
|
decision = ask_ollama(f"Reply ONLY 'yes' or 'no'. Does this need Claude? {msg}")
|
|
if "yes" in decision.lower():
|
|
return "claude", ask_claude(msg)
|
|
return "lucidia", ask_ollama(msg)
|
|
|
|
if __name__ == "__main__":
|
|
print("Lucidia online. Connectors: github, cloudflare, vercel, claude")
|
|
while True:
|
|
you = input("\nyou: ")
|
|
if you in ["q", "quit", "exit"]:
|
|
break
|
|
who, answer = route(you)
|
|
print(f"\n[{who}]: {answer}")
|