Enhance credential management and testing functionality
- Introduce new fields for voice, speed, and language in the AssistantConfig and ProviderCredential models to support TTS and ASR configurations. - Update the database schema and seeding script to accommodate the new fields, ensuring backward compatibility. - Implement credential testing endpoints and logic to validate OpenAI-compatible credentials, enhancing user experience and reliability. - Modify frontend components to include new fields in the credential forms and improve connection testing feedback. - Refactor related services and API interactions to support the new credential testing feature.
This commit is contained in:
@@ -101,8 +101,20 @@ class CredentialUpsert(CamelModel):
|
||||
interface_type: InterfaceType = "openai" # openai/xfyun/dashscope/gemini
|
||||
api_url: str = ""
|
||||
api_key: str = "" # 写时:占位符/空表示不改
|
||||
voice: str = "" # TTS
|
||||
speed: float = 1.0 # TTS
|
||||
language: str = "" # ASR
|
||||
is_default: bool = False
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _strip_irrelevant_options(self):
|
||||
if self.type != "TTS":
|
||||
self.voice = ""
|
||||
self.speed = 1.0
|
||||
if self.type != "ASR":
|
||||
self.language = ""
|
||||
return self
|
||||
|
||||
|
||||
class CredentialOut(CamelModel):
|
||||
id: str
|
||||
@@ -112,4 +124,25 @@ class CredentialOut(CamelModel):
|
||||
interface_type: str
|
||||
api_url: str
|
||||
api_key: str # 读时:打码后的值
|
||||
voice: str
|
||||
speed: float
|
||||
language: str
|
||||
is_default: bool
|
||||
|
||||
|
||||
class CredentialTestRequest(CamelModel):
|
||||
model_id: str
|
||||
type: ModelType
|
||||
interface_type: InterfaceType = "openai"
|
||||
api_url: str
|
||||
api_key: str = ""
|
||||
voice: str = ""
|
||||
speed: float = 1.0
|
||||
language: str = ""
|
||||
|
||||
|
||||
class CredentialTestResult(CamelModel):
|
||||
ok: bool
|
||||
latency_ms: int | None = None
|
||||
message: str
|
||||
detail: str = ""
|
||||
|
||||
Reference in New Issue
Block a user