#!/usr/bin/env python3 """记录工作区模型注册。对话走 New-API 的 dify-gateway,向量和重排走 Xinference。 现网已经注册过。再跑一次如果返回 Can't add same credential,停下来即可。 不要创建第二把名为 dify-gateway 的令牌。 """ import json import urllib.request DIFY = "http://127.0.0.1:8088" NEW_API = "http://10.0.1.47:3000/v1" XINFERENCE = "http://10.0.1.47:9997" GATEWAY_KEY = "sk-C0P9V9kwPfXDvQCfaVzSLCJRUmioNmxYud1uqsLXkBqZTFxK" llm = { "model": "qwen3.6-27b", "model_type": "llm", "credentials": { "mode": "chat", "context_size": "65536", "max_tokens_to_sample": "8192", "function_calling_type": "tool_call", "stream_function_calling": "supported", "display_name": "qwen3.6-27b", "endpoint_url": NEW_API, "api_key": GATEWAY_KEY, }, } embedding = { "model": "bge-m3", "model_type": "text-embedding", "credentials": { "server_url": XINFERENCE, "model_uid": "bge-m3", }, } rerank = { "model": "bge-reranker-v2-m3", "model_type": "rerank", "credentials": { "server_url": XINFERENCE, "model_uid": "bge-reranker-v2-m3", }, } def show(title, body): print(title) print(json.dumps(body, ensure_ascii=False, indent=2)) show("对话模型", llm) show("向量模型", embedding) show("重排模型", rerank) print("保存:POST /console/api/workspaces/current/model-providers//models/credentials") print("供应商:langgenius/openai_api_compatible/openai_api_compatible") print("供应商:langgenius/xinference/xinference") print("然后把这三项设成工作区默认模型。")