|
32 | 32 | use App\Interfaces\Authorization\Web\MagicUserAuthorization; |
33 | 33 | use Exception; |
34 | 34 | use Hyperf\Odin\Api\Response\ChatCompletionResponse; |
| 35 | +use App\Domain\ModelAdmin\Constant\NaturalLanguageProcessing; |
35 | 36 |
|
36 | 37 | class ServiceProviderAppService |
37 | 38 | { |
@@ -146,8 +147,8 @@ public function connectivityTest(string $serviceProviderConfigId, string $modelV |
146 | 147 |
|
147 | 148 | // 根据服务商类型和模型类型进行连通性测试 |
148 | 149 | return match ($this->getConnectivityTestType($serviceProviderConfigDTO->getCategory(), $model->getModelType())) { |
149 | | - 'embedding' => $this->embeddingConnectivityTest($modelId, $authorization), |
150 | | - 'llm' => $this->llmConnectivityTest($modelId, $authorization), |
| 150 | + NaturalLanguageProcessing::EMBEDDING => $this->embeddingConnectivityTest($modelId, $authorization), |
| 151 | + NaturalLanguageProcessing::LLM => $this->llmConnectivityTest($modelId, $authorization), |
151 | 152 | default => $this->serviceProviderDomainService->connectivityTest($serviceProviderConfigId, $modelVersion, $authorization->getOrganizationCode()), |
152 | 153 | }; |
153 | 154 | } |
@@ -244,12 +245,12 @@ public function maskSensitiveConfigInfo(ServiceProviderConfigDTO $serviceProvide |
244 | 245 | /** |
245 | 246 | * 获取联通测试类型. |
246 | 247 | */ |
247 | | - private function getConnectivityTestType(string $category, int $modelType): string |
| 248 | + private function getConnectivityTestType(string $category, int $modelType) |
248 | 249 | { |
249 | 250 | if (ServiceProviderCategory::from($category) === ServiceProviderCategory::LLM) { |
250 | | - return $modelType === ModelType::EMBEDDING->value ? 'embedding' : 'llm'; |
| 251 | + return $modelType === ModelType::EMBEDDING->value ? NaturalLanguageProcessing::EMBEDDING : NaturalLanguageProcessing::LLM; |
251 | 252 | } |
252 | | - return 'default'; |
| 253 | + return NaturalLanguageProcessing::DEFAULT; |
253 | 254 | } |
254 | 255 |
|
255 | 256 | private function embeddingConnectivityTest(string $modelId, MagicUserAuthorization $authorization): ConnectResponse |
|
0 commit comments