feat: Implement Dify LLM provider and update related configurations and tests

This commit is contained in:
Xin Wang
2026-03-11 16:35:59 +08:00
parent 3b9ee80c8f
commit 5eec8f2b30
7 changed files with 455 additions and 3 deletions

View File

@@ -28,7 +28,7 @@ from providers.tts.volcengine import VolcengineTTSService
_OPENAI_COMPATIBLE_PROVIDERS = {"openai_compatible", "openai-compatible", "siliconflow"}
_DASHSCOPE_PROVIDERS = {"dashscope"}
_VOLCENGINE_PROVIDERS = {"volcengine"}
_SUPPORTED_LLM_PROVIDERS = {"openai", "fastgpt", *_OPENAI_COMPATIBLE_PROVIDERS}
_SUPPORTED_LLM_PROVIDERS = {"openai", "dify", "fastgpt", *_OPENAI_COMPATIBLE_PROVIDERS}
class DefaultRealtimeServiceFactory(RealtimeServiceFactory):
@@ -58,6 +58,16 @@ class DefaultRealtimeServiceFactory(RealtimeServiceFactory):
def create_llm_service(self, spec: LLMServiceSpec) -> LLMPort:
provider = self._normalize_provider(spec.provider)
if provider == "dify" and spec.api_key and spec.base_url:
from providers.llm.dify import DifyLLMService
return DifyLLMService(
api_key=spec.api_key,
base_url=spec.base_url,
model=spec.model,
system_prompt=spec.system_prompt,
)
if provider == "fastgpt" and spec.api_key and spec.base_url:
from providers.llm.fastgpt import FastGPTLLMService