mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
- New DB fields: hermes_url, hermes_api_key, backend_mode (openrouter/hermes) - Migration 0002 adds the three fields to JbotApiConfig - _do_hermes_chat(): streams /v1/chat/completions from Hermes Agent, collects hermes.tool.progress SSE events, returns (final_text, tool_calls) - chat_view branches on backend_mode; Hermes response includes toolCalls list - Settings page: new '🧠 AI 后端模式' section — radio to toggle mode, conditional Hermes URL + API key fields, LLM model field moved under OpenRouter mode - ChatPanel: ToolCallsList component renders collapsible '🔧 Hermes 使用了 N 个工具' widget before the bot reply — tool calls are NOT spoken via TTS - CSS: .tool-calls, .tool-calls-* styles for the tool progress widget Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
33 lines
1.6 KiB
Python
33 lines
1.6 KiB
Python
from django.db import models
|
|
|
|
|
|
class JbotApiConfig(models.Model):
|
|
"""Singleton model storing JBOT API credentials and runtime defaults.
|
|
Configured via the Settings UI at /jbot/settings — env vars are fallback only.
|
|
"""
|
|
volc_app_id = models.CharField(max_length=200, blank=True, default='')
|
|
volc_access_token = models.CharField(max_length=500, blank=True, default='')
|
|
openrouter_api_key = models.CharField(max_length=200, blank=True, default='')
|
|
llm_model = models.CharField(max_length=200, blank=True, default='deepseek/deepseek-chat')
|
|
volc_tts_voice = models.CharField(max_length=200, blank=True, default='zh_female_vv_uranus_bigtts')
|
|
volc_asr_resource = models.CharField(max_length=200, blank=True, default='volc.bigasr.sauc.duration')
|
|
# Hermes Agent backend
|
|
hermes_url = models.CharField(max_length=500, blank=True, default='http://192.168.1.10:8642')
|
|
hermes_api_key = models.CharField(max_length=200, blank=True, default='')
|
|
backend_mode = models.CharField(max_length=20, blank=True, default='openrouter',
|
|
choices=[('openrouter', 'OpenRouter'), ('hermes', 'Hermes Agent')])
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
verbose_name = 'JBOT API Config'
|
|
|
|
@classmethod
|
|
def load(cls):
|
|
"""Return the singleton row, creating it if needed."""
|
|
obj, _ = cls.objects.get_or_create(pk=1)
|
|
return obj
|
|
|
|
def save(self, *args, **kwargs):
|
|
self.pk = 1
|
|
super().save(*args, **kwargs)
|