Skip to content

Commit 8858ee0

Browse files
VinchanGitvinchan
authored andcommitted
feat(*):add NaturalLanguageProcessing Enum (#12)
* feat(*):add NaturalLanguageProcessing Enum * feat(*):add NaturalLanguageProcessing Enum * feat(*):resolve conversation * feat(*):resolve conversation --------- Co-authored-by: vinchan <[email protected]>
1 parent 856d80c commit 8858ee0

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

backend/magic-service/app/Application/ModelAdmin/Service/ServiceProviderAppService.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use App\Interfaces\Authorization\Web\MagicUserAuthorization;
3333
use Exception;
3434
use Hyperf\Odin\Api\Response\ChatCompletionResponse;
35+
use App\Domain\ModelAdmin\Constant\NaturalLanguageProcessing;
3536

3637
class ServiceProviderAppService
3738
{
@@ -146,8 +147,8 @@ public function connectivityTest(string $serviceProviderConfigId, string $modelV
146147

147148
// 根据服务商类型和模型类型进行连通性测试
148149
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),
151152
default => $this->serviceProviderDomainService->connectivityTest($serviceProviderConfigId, $modelVersion, $authorization->getOrganizationCode()),
152153
};
153154
}
@@ -244,12 +245,12 @@ public function maskSensitiveConfigInfo(ServiceProviderConfigDTO $serviceProvide
244245
/**
245246
* 获取联通测试类型.
246247
*/
247-
private function getConnectivityTestType(string $category, int $modelType): string
248+
private function getConnectivityTestType(string $category, int $modelType)
248249
{
249250
if (ServiceProviderCategory::from($category) === ServiceProviderCategory::LLM) {
250-
return $modelType === ModelType::EMBEDDING->value ? 'embedding' : 'llm';
251+
return $modelType === ModelType::EMBEDDING->value ? NaturalLanguageProcessing::EMBEDDING : NaturalLanguageProcessing::LLM;
251252
}
252-
return 'default';
253+
return NaturalLanguageProcessing::DEFAULT;
253254
}
254255

255256
private function embeddingConnectivityTest(string $modelId, MagicUserAuthorization $authorization): ConnectResponse
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* Copyright (c) The Magic , Distributed under the software license
6+
*/
7+
8+
namespace App\Domain\ModelAdmin\Constant;
9+
10+
enum NaturalLanguageProcessing: string
11+
{
12+
case DEFAULT = 'default';
13+
14+
case EMBEDDING = 'embedding'; // 嵌入
15+
16+
case LLM = 'llm'; // 大语言
17+
}

0 commit comments

Comments
 (0)