1515use App \Domain \Provider \Entity \ProviderEntity ;
1616use App \Domain \Provider \Entity \ProviderModelEntity ;
1717use App \Domain \Provider \Entity \ValueObject \Category ;
18+ use App \Domain \Provider \Entity \ValueObject \ModelType ;
1819use App \Domain \Provider \Entity \ValueObject \ProviderDataIsolation ;
1920use App \Domain \Provider \Entity \ValueObject \Query \ProviderModelQuery ;
2021use App \Domain \Provider \Entity \ValueObject \Status ;
@@ -137,7 +138,7 @@ public function getOrganizationEmbeddingModel(string $model, ?string $orgCode =
137138 */
138139 public function getChatModels (string $ organizationCode ): array
139140 {
140- return $ this ->getModelsByType ($ organizationCode , 'chat ' );
141+ return $ this ->getModelsByType ($ organizationCode , 'chat ' , ModelType:: LLM );
141142 }
142143
143144 /**
@@ -146,7 +147,7 @@ public function getChatModels(string $organizationCode): array
146147 */
147148 public function getEmbeddingModels (string $ organizationCode ): array
148149 {
149- return $ this ->getModelsByType ($ organizationCode , 'embedding ' );
150+ return $ this ->getModelsByType ($ organizationCode , 'embedding ' , ModelType:: EMBEDDING );
150151 }
151152
152153 protected function loadEnvModels (): void
@@ -331,13 +332,28 @@ protected function loadApiModels(): void
331332 * @param string $type 模型类型(chat|embedding)
332333 * @return OdinModel[]
333334 */
334- private function getModelsByType (string $ organizationCode , string $ type ): array
335+ private function getModelsByType (string $ organizationCode , string $ type, ? ModelType $ modelType = null ): array
335336 {
336337 $ list = [];
337338
338339 // 获取已持久化的配置
339340 $ models = $ this ->getModels ($ type );
340341 foreach ($ models as $ name => $ model ) {
342+ switch ($ modelType ) {
343+ case ModelType::LLM :
344+ if ($ model instanceof AbstractModel && ! $ model ->getModelOptions ()->isChat ()) {
345+ continue 2 ;
346+ }
347+ break ;
348+ case ModelType::EMBEDDING :
349+ if ($ model instanceof AbstractModel && ! $ model ->getModelOptions ()->isEmbedding ()) {
350+ continue 2 ;
351+ }
352+ break ;
353+ default :
354+ // 如果没有指定类型,则全部添加
355+ break ;
356+ }
341357 $ list [$ name ] = new OdinModel (key: $ name , model: $ model , attributes: $ this ->attributes [$ name ]);
342358 }
343359
@@ -346,6 +362,7 @@ private function getModelsByType(string $organizationCode, string $type): array
346362 $ providerModelQuery = new ProviderModelQuery ();
347363 $ providerModelQuery ->setStatus (Status::Enabled);
348364 $ providerModelQuery ->setCategory (Category::LLM );
365+ $ providerModelQuery ->setModelType ($ modelType );
349366 $ providerModelData = di (ProviderModelDomainService::class)->queries ($ providerDataIsolation , $ providerModelQuery , Page::createNoPage ());
350367 $ providerConfigIds = [];
351368 foreach ($ providerModelData ['list ' ] as $ providerModel ) {
0 commit comments