fix: stop user-level gateway service conflicting with system-level one
Root cause: user-level hermes-gateway.service was running the same -p default gateway as the system-level hermes-gateway@default.service, causing the two to SIGTERM each other every ~5 minutes. This killed in-flight Hermes API requests with 'Remote end closed connection'. Fix: disabled the redundant user-level service. Also: simplified webhook to just forward raw message content (no system prompt, no ACK, no max_tokens overrides). Removed unused _get_ack method.
This commit is contained in:
@@ -125,11 +125,10 @@ class WebhookHandler(BaseHTTPRequestHandler):
|
||||
self._respond(200, {"status": "ok"})
|
||||
|
||||
def _forward_to_hermes(self, sender, sender_id, text):
|
||||
"""Forward to Hermes and send reply back to WeChat."""
|
||||
"""Forward message to Hermes, get response, send back to WeChat."""
|
||||
payload = json.dumps({
|
||||
"model": "nova-4",
|
||||
"messages": [
|
||||
{"role": "system", "content": "你是莫荷微信Bot。回复简洁,不要废话。"},
|
||||
{"role": "user", "content": f"[微信消息] 来自 {sender}({sender_id}): {text}"}
|
||||
]
|
||||
}).encode()
|
||||
@@ -141,12 +140,11 @@ class WebhookHandler(BaseHTTPRequestHandler):
|
||||
opener = ureq.build_opener(handler)
|
||||
req = ureq.Request(HERMES_API, data=payload,
|
||||
headers={"Content-Type": "application/json", "Authorization": f"Bearer {HERMES_KEY}"})
|
||||
resp = opener.open(req, timeout=30)
|
||||
resp = opener.open(req, timeout=180)
|
||||
resp_data = json.loads(resp.read())
|
||||
reply = resp_data.get('choices', [{}])[0].get('message', {}).get('content', '')
|
||||
log.info(f"Hermes OK, reply: {reply[:60]}")
|
||||
|
||||
# Send reply back via WeChat API
|
||||
if reply and sender:
|
||||
self._send_wechat(sender, reply)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user