Dmitry Beresnev commited on
Commit ·
23f86af
1
Parent(s): ed359f0
configure openclaw to use custom LLM server
Browse files- app.py +6 -2
- openclaw.json +41 -9
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import json
|
| 2 |
import os
|
|
|
|
| 3 |
import shutil
|
| 4 |
import socket
|
| 5 |
import subprocess
|
|
@@ -248,8 +249,11 @@ def parse_expected_env_vars(config_data: dict) -> list[str]:
|
|
| 248 |
vars_found: set[str] = set()
|
| 249 |
for provider in config_data.get("providers", []):
|
| 250 |
base_url = provider.get("base_url")
|
| 251 |
-
if isinstance(base_url, str)
|
| 252 |
-
vars_found.
|
|
|
|
|
|
|
|
|
|
| 253 |
for tool in config_data.get("tools", {}).values():
|
| 254 |
for env_name in tool.get("env", []):
|
| 255 |
vars_found.add(env_name)
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
+
import re
|
| 4 |
import shutil
|
| 5 |
import socket
|
| 6 |
import subprocess
|
|
|
|
| 249 |
vars_found: set[str] = set()
|
| 250 |
for provider in config_data.get("providers", []):
|
| 251 |
base_url = provider.get("base_url")
|
| 252 |
+
if isinstance(base_url, str):
|
| 253 |
+
vars_found.update(re.findall(r"\$\{([A-Z0-9_]+)\}", base_url))
|
| 254 |
+
for _, val in provider.get("headers", {}).items():
|
| 255 |
+
if isinstance(val, str):
|
| 256 |
+
vars_found.update(re.findall(r"\$\{([A-Z0-9_]+)\}", val))
|
| 257 |
for tool in config_data.get("tools", {}).values():
|
| 258 |
for env_name in tool.get("env", []):
|
| 259 |
vars_found.add(env_name)
|
openclaw.json
CHANGED
|
@@ -1,26 +1,58 @@
|
|
| 1 |
{
|
| 2 |
"agent": {
|
| 3 |
"name": "openclaw-trading-bot",
|
| 4 |
-
"description": "OpenClaw bot for paper trading with Alpaca and
|
| 5 |
"timezone": "UTC"
|
| 6 |
},
|
| 7 |
"providers": [
|
| 8 |
{
|
| 9 |
-
"name": "
|
| 10 |
"type": "custom_http",
|
| 11 |
-
"base_url": "${
|
| 12 |
"method": "POST",
|
| 13 |
-
"timeout_ms":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
"request_schema": {
|
| 15 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
},
|
| 17 |
-
"response_path": "
|
| 18 |
}
|
| 19 |
],
|
| 20 |
"routing": {
|
| 21 |
-
"market_analysis": "
|
| 22 |
-
"signal_generation": "
|
| 23 |
-
"reporting": "
|
| 24 |
},
|
| 25 |
"tools": {
|
| 26 |
"alpaca_paper": {
|
|
|
|
| 1 |
{
|
| 2 |
"agent": {
|
| 3 |
"name": "openclaw-trading-bot",
|
| 4 |
+
"description": "OpenClaw bot for paper trading with Alpaca and ResearchEngineering AGI Multi-Model API",
|
| 5 |
"timezone": "UTC"
|
| 6 |
},
|
| 7 |
"providers": [
|
| 8 |
{
|
| 9 |
+
"name": "agi_chat",
|
| 10 |
"type": "custom_http",
|
| 11 |
+
"base_url": "${LLM_SPACE_OPENAI_URL}",
|
| 12 |
"method": "POST",
|
| 13 |
+
"timeout_ms": 30000,
|
| 14 |
+
"headers": {
|
| 15 |
+
"Content-Type": "application/json"
|
| 16 |
+
},
|
| 17 |
+
"request_schema": {
|
| 18 |
+
"messages": [
|
| 19 |
+
{
|
| 20 |
+
"role": "user",
|
| 21 |
+
"content": "${prompt}"
|
| 22 |
+
}
|
| 23 |
+
],
|
| 24 |
+
"max_tokens": 700,
|
| 25 |
+
"temperature": 0.2
|
| 26 |
+
},
|
| 27 |
+
"response_path": "choices.0.message.content"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"name": "agi_web_chat",
|
| 31 |
+
"type": "custom_http",
|
| 32 |
+
"base_url": "${LLM_SPACE_WEBCHAT_URL}",
|
| 33 |
+
"method": "POST",
|
| 34 |
+
"timeout_ms": 45000,
|
| 35 |
+
"headers": {
|
| 36 |
+
"Content-Type": "application/json"
|
| 37 |
+
},
|
| 38 |
"request_schema": {
|
| 39 |
+
"messages": [
|
| 40 |
+
{
|
| 41 |
+
"role": "user",
|
| 42 |
+
"content": "${prompt}"
|
| 43 |
+
}
|
| 44 |
+
],
|
| 45 |
+
"max_tokens": 700,
|
| 46 |
+
"temperature": 0.2,
|
| 47 |
+
"max_search_results": 5
|
| 48 |
},
|
| 49 |
+
"response_path": "choices.0.message.content"
|
| 50 |
}
|
| 51 |
],
|
| 52 |
"routing": {
|
| 53 |
+
"market_analysis": "agi_web_chat",
|
| 54 |
+
"signal_generation": "agi_chat",
|
| 55 |
+
"reporting": "agi_chat"
|
| 56 |
},
|
| 57 |
"tools": {
|
| 58 |
"alpaca_paper": {
|