Merge pull request #3561 from xinnan-tech/py-test-mem

Py test mem
This commit is contained in:
wengzh 2026-11-16 14:52:51 +08:00 committed by GitHub
commit b545623b38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 98 additions and 7 deletions

View file

@ -272,7 +272,7 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
| 使用方式 | 支持平台 | 免费平台 | | 使用方式 | 支持平台 | 免费平台 |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| OpenAI 接口调用 | 阿里百炼、智谱ChatGLMVLLM | 智谱ChatGLMVLLM | | OpenAI 接口调用 | 阿里百炼、智谱ChatGLMVLLM、科大讯飞 | 智谱ChatGLMVLLM |
实际上,任何支持 OpenAI 接口调用的 VLLM 均可接入使用。 实际上,任何支持 OpenAI 接口调用的 VLLM 均可接入使用。
@ -322,6 +322,7 @@ Websocket接口地址: wss://2662r3426b.vicp.fun/xiaozhi/v1/
| Memory | [powermem](./docs/powermem-integration.md) | 本地总结 | 取决于LLM和DB | OceanBase开源,支持智能检索 | | Memory | [powermem](./docs/powermem-integration.md) | 本地总结 | 取决于LLM和DB | OceanBase开源,支持智能检索 |
| Memory | mem_local_short | 本地总结 | 免费 | | | Memory | mem_local_short | 本地总结 | 免费 | |
| Memory | nomem | 无记忆模式 | 免费 | | | Memory | nomem | 无记忆模式 | 免费 | |
| Memory | mem_report_only | 仅上报 | 免费 | 只上报聊天记录,不做记忆总结 |
--- ---

View file

@ -270,7 +270,7 @@ Tatsächlich kann jedes LLM, das OpenAI-Schnittstellenaufrufe unterstützt, inte
| Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen | | Verwendungsmethode | Unterstützte Plattformen | Kostenlose Plattformen |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| OpenAI-Schnittstellenaufrufe | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | OpenAI-Schnittstellenaufrufe | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
Tatsächlich kann jedes VLLM, das OpenAI-Schnittstellenaufrufe unterstützt, integriert und verwendet werden. Tatsächlich kann jedes VLLM, das OpenAI-Schnittstellenaufrufe unterstützt, integriert und verwendet werden.
@ -320,6 +320,7 @@ Die Stimmabdruckerkennung erfordert einen separat bereitgestellten [voiceprint-a
| Memory | [powermem](../powermem-integration.md) | Lokale Zusammenfassung | Abhängig von LLM und DB | OceanBase Open Source, unterstützt intelligente Abfrage | | Memory | [powermem](../powermem-integration.md) | Lokale Zusammenfassung | Abhängig von LLM und DB | OceanBase Open Source, unterstützt intelligente Abfrage |
| Memory | mem_local_short | Lokale Zusammenfassung | Kostenlos | | | Memory | mem_local_short | Lokale Zusammenfassung | Kostenlos | |
| Memory | nomem | Kein Gedächtnismodus | Kostenlos | | | Memory | nomem | Kein Gedächtnismodus | Kostenlos | |
| Memory | mem_report_only | Nur Meldung | Kostenlos | Meldet nur Chat-Verläufe, keine Gedächtniszusammenfassung |
--- ---

View file

@ -270,7 +270,7 @@ In fact, any LLM that supports OpenAI interface calls can be integrated and used
| Usage Method | Supported Platforms | Free Platforms | | Usage Method | Supported Platforms | Free Platforms |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| OpenAI interface calls | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | OpenAI interface calls | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
In fact, any VLLM that supports OpenAI interface calls can be integrated and used. In fact, any VLLM that supports OpenAI interface calls can be integrated and used.
@ -320,6 +320,7 @@ Voiceprint recognition requires a separately deployed [voiceprint-api](https://g
| Memory | [powermem](../powermem-integration.md) | Local summarization | Depends on LLM and DB | OceanBase open source, supports intelligent retrieval | | Memory | [powermem](../powermem-integration.md) | Local summarization | Depends on LLM and DB | OceanBase open source, supports intelligent retrieval |
| Memory | mem_local_short | Local summarization | Free | | | Memory | mem_local_short | Local summarization | Free | |
| Memory | nomem | No memory mode | Free | | | Memory | nomem | No memory mode | Free | |
| Memory | mem_report_only | Report only | Free | Only reports chat records, no memory summarization |
--- ---

View file

@ -270,7 +270,7 @@ En la práctica, se puede integrar cualquier LLM que admita llamadas por la inte
| Forma de uso | Plataformas compatibles | Plataformas gratuitas | | Forma de uso | Plataformas compatibles | Plataformas gratuitas |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| Llamadas por la interfaz OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | Llamadas por la interfaz OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
En la práctica, se puede integrar cualquier VLLM que admita llamadas por la interfaz OpenAI. En la práctica, se puede integrar cualquier VLLM que admita llamadas por la interfaz OpenAI.
@ -320,6 +320,7 @@ El reconocimiento de huella de voz requiere desplegar por separado el servicio [
| Memory | [powermem](../powermem-integration.md) | Resumen local | Depende del LLM y de la base de datos | OceanBase de código abierto; admite búsqueda inteligente | | Memory | [powermem](../powermem-integration.md) | Resumen local | Depende del LLM y de la base de datos | OceanBase de código abierto; admite búsqueda inteligente |
| Memory | mem_local_short | Resumen local | Gratuito | | | Memory | mem_local_short | Resumen local | Gratuito | |
| Memory | nomem | Modo sin memoria | Gratuito | | | Memory | nomem | Modo sin memoria | Gratuito | |
| Memory | mem_report_only | Solo informe | Gratuito | Solo informa el historial de chat, sin resumen de memoria |
--- ---

View file

@ -270,7 +270,7 @@ Na verdade, qualquer LLM que suporte chamadas via interface OpenAI pode ser inte
| Método de Uso | Plataformas Suportadas | Plataformas Gratuitas | | Método de Uso | Plataformas Suportadas | Plataformas Gratuitas |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| Chamadas via interface OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | Chamadas via interface OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
Na verdade, qualquer VLLM que suporte chamadas via interface OpenAI pode ser integrado e utilizado. Na verdade, qualquer VLLM que suporte chamadas via interface OpenAI pode ser integrado e utilizado.
@ -320,6 +320,7 @@ O reconhecimento de impressão vocal exige um serviço [voiceprint-api](https://
| Memória | [powermem](../powermem-integration.md) | Resumo local | Depende do LLM e BD | OceanBase de código aberto, suporta busca inteligente | | Memória | [powermem](../powermem-integration.md) | Resumo local | Depende do LLM e BD | OceanBase de código aberto, suporta busca inteligente |
| Memória | mem_local_short | Resumo local | Gratuito | | | Memória | mem_local_short | Resumo local | Gratuito | |
| Memória | nomem | Modo sem memória | Gratuito | | | Memória | nomem | Modo sem memória | Gratuito | |
| Memória | mem_report_only | Apenas relatório | Gratuito | Apenas reporta o histórico de chat, sem resumo de memória |
--- ---

View file

@ -271,7 +271,7 @@ Trên thực tế, bất kỳ LLM nào hỗ trợ gọi giao diện OpenAI đề
| Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí | | Phương pháp sử dụng | Nền tảng hỗ trợ | Nền tảng miễn phí |
|:---:|:---:|:---:| |:---:|:---:|:---:|
| Gọi giao diện OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM | Zhipu ChatGLMVLLM | | Gọi giao diện OpenAI | Alibaba Bailian, Zhipu ChatGLMVLLM, iFLYTEK | Zhipu ChatGLMVLLM |
Trên thực tế, bất kỳ VLLM nào hỗ trợ gọi giao diện OpenAI đều có thể truy cập sử dụng. Trên thực tế, bất kỳ VLLM nào hỗ trợ gọi giao diện OpenAI đều có thể truy cập sử dụng.
@ -321,6 +321,7 @@ Nhận dạng vân giọng cần dịch vụ [voiceprint-api](https://github.com
| Memory | [powermem](../powermem-integration.md) | Tóm tắt cục bộ | Phụ thuộc vào LLM và DB | OceanBase mã nguồn mở, hỗ trợ tìm kiếm thông minh | | Memory | [powermem](../powermem-integration.md) | Tóm tắt cục bộ | Phụ thuộc vào LLM và DB | OceanBase mã nguồn mở, hỗ trợ tìm kiếm thông minh |
| Memory | mem_local_short | Tóm tắt cục bộ | Miễn phí | | | Memory | mem_local_short | Tóm tắt cục bộ | Miễn phí | |
| Memory | nomem | Chế độ không có bộ nhớ | Miễn phí | | | Memory | nomem | Chế độ không có bộ nhớ | Miễn phí | |
| Memory | mem_report_only | Chỉ báo cáo | Miễn phí | Chỉ báo cáo lịch sử trò chuyện, không tóm tắt bộ nhớ |
--- ---

View file

@ -765,7 +765,11 @@ VLLM:
# 开通应用地址:https://console.xfyun.cn/app/myapp # 开通应用地址:https://console.xfyun.cn/app/myapp
# 有免费额度,但也要开通服务,才能获取api_key # 有免费额度,但也要开通服务,才能获取api_key
# 每一个模型都需要单独开通,每一个模型的 api_key 都不同,例如 Lite 模型在 https://console.xfyun.cn/services/cbm 开通 # 每一个模型都需要单独开通,每一个模型的 api_key 都不同,例如 Lite 模型在 https://console.xfyun.cn/services/cbm 开通
base_url: https://ark.cn-beijing.volces.com/api/v3 # 讯飞星火的 OpenAI 兼容端点,可用模型名(lite / 4.0Ultra 等)见
# https://www.xfyun.cn/doc/spark/HTTP调用文档.html
# 注意 base_url 必须指向讯飞自己的域名。这里曾误填成火山方舟的
# ark.cn-beijing.volces.com,会把讯飞的 api_key 发给火山引擎。
base_url: https://spark-api-open.xf-yun.com/v1
model_name: lite model_name: lite
api_key: 你的api_key api_key: 你的api_key
TTS: TTS:

View file

@ -0,0 +1,81 @@
"""供应器默认端点自检:防止不同 provider 的 base_url 被复制粘贴串台。
背景:``config.yaml`` 里每个 provider 的 ``base_url`` / ``url`` 都是照抄对应
厂商文档填的,很容易从相邻的 provider 直接复制粘贴。真实案例:``VLLM``
段的 ``XunfeiSparkLLM`` 抄了上面 ``LLM.DoubaoLLM`` 的火山方舟地址
(ark.cn-beijing.volces.com),选它做视觉模型时会把讯飞的 api_key 发给
火山引擎,而 ``model_name: lite`` 在那个端点上并不存在。
这里用一张「配置块 -> 端点主机名」的对照表把这类串台钉死。新增 provider
时顺手往表里加一行即可。
注意:本用例读的是仓库里**出厂的** ``config.yaml``,不是用户
``data/.config.yaml`` 合并后的结果 —— 要守的就是这份出厂默认值。
"""
from __future__ import annotations
from urllib.parse import urlparse
import pytest
from config.config_loader import get_project_dir, read_config
# (模块段, provider 名, 端点主机名里必须出现的片段)
PROVIDER_ENDPOINT_HOSTS = [
("LLM", "AliLLM", "dashscope.aliyuncs.com"),
("LLM", "AliAppLLM", "dashscope.aliyuncs.com"),
("LLM", "ChatGLMLLM", "bigmodel.cn"),
("LLM", "DeepSeekLLM", "deepseek.com"),
("LLM", "DifyLLM", "dify.ai"),
("LLM", "DoubaoLLM", "volces.com"),
("LLM", "VolcesAiGatewayLLM", "volces.com"),
("VLLM", "ChatGLMVLLM", "bigmodel.cn"),
("VLLM", "QwenVLVLLM", "dashscope.aliyuncs.com"),
("VLLM", "XunfeiSparkLLM", "xf-yun.com"),
("ASR", "OpenaiASR", "api.openai.com"),
("ASR", "GroqASR", "api.groq.com"),
("ASR", "Qwen3ASRFlash", "dashscope.aliyuncs.com"),
("TTS", "OpenAITTS", "api.openai.com"),
("TTS", "DoubaoTTS", "bytedance.com"),
("TTS", "TTS302AI", "302ai.cn"),
("TTS", "VolcesAiGatewayTTS", "volces.com"),
]
@pytest.fixture(scope="module")
def default_config():
"""仓库里出厂的默认配置(未经用户 data/.config.yaml 覆盖)。"""
return read_config(get_project_dir() + "config.yaml")
def _endpoint_of(block: dict) -> str:
"""取 provider 配置块里生效的端点。
顺序与运行时一致:``core/providers/vllm/openai.py`` 和
``core/providers/llm/openai/openai.py`` 都是 ``base_url`` 优先、
``url`` 兜底;部分 TTS 用 ``api_url``。
"""
return block.get("base_url") or block.get("url") or block.get("api_url") or ""
@pytest.mark.parametrize(
"module,provider,expected_host",
PROVIDER_ENDPOINT_HOSTS,
ids=[f"{m}.{p}" for m, p, _ in PROVIDER_ENDPOINT_HOSTS],
)
def test_provider_endpoint_matches_platform(
default_config, module, provider, expected_host
):
"""provider 的端点必须落在它自己那家厂商的域名下。"""
block = default_config.get(module, {}).get(provider)
assert block is not None, f"config.yaml 里找不到 {module}.{provider} 配置块"
endpoint = _endpoint_of(block)
assert endpoint, f"{module}.{provider} 没有配置 base_url / url / api_url"
host = urlparse(endpoint).netloc
assert expected_host in host, (
f"{module}.{provider} 的端点 {endpoint!r} 解析出的主机是 {host!r},"
f"与平台不符(期望包含 {expected_host!r})—— 疑似从别的 provider 复制粘贴时带串了"
)