Public Access
35 lines
782 B
Python
35 lines
782 B
Python
import re, subprocess
|
|
|
|
# Read current proxy
|
|
with open("/opt/ai-proxy/proxy.py") as f:
|
|
code = f.read()
|
|
|
|
# Add groq-3 provider after groq-2
|
|
old = ''' "priority": 11,
|
|
},'''
|
|
|
|
new = ''' "priority": 11,
|
|
},
|
|
{
|
|
"name": "groq-3",
|
|
"client": lambda: AsyncOpenAI(
|
|
api_key=os.getenv("GROQ_API_KEY_3"),
|
|
base_url="https://api.groq.com/openai/v1"
|
|
),
|
|
"models": [
|
|
"llama-3.1-8b-instant",
|
|
"llama-3.3-70b-versatile",
|
|
],
|
|
"priority": 12,
|
|
},'''
|
|
|
|
code = code.replace(old, new)
|
|
|
|
with open("/opt/ai-proxy/proxy.py", "w") as f:
|
|
f.write(code)
|
|
|
|
print("Added groq-3 provider!")
|
|
|
|
subprocess.run(["systemctl", "restart", "ai-proxy"], capture_output=True)
|
|
print("Proxy restarted!")
|