mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 20:08:18 +08:00
fix(llm): skip Ollama auto-discovery network probe when provider disabled
This commit is contained in:
parent
7d02841d1d
commit
6fe9b6e5f7
@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import vip.mate.llm.model.DiscoverResult;
|
import vip.mate.llm.model.DiscoverResult;
|
||||||
import vip.mate.llm.model.ModelConfigEntity;
|
import vip.mate.llm.model.ModelConfigEntity;
|
||||||
import vip.mate.llm.model.ModelInfoDTO;
|
import vip.mate.llm.model.ModelInfoDTO;
|
||||||
|
import vip.mate.llm.model.ModelProviderEntity;
|
||||||
import vip.mate.llm.model.TestResult;
|
import vip.mate.llm.model.TestResult;
|
||||||
import vip.mate.llm.service.ModelConfigService;
|
import vip.mate.llm.service.ModelConfigService;
|
||||||
import vip.mate.llm.service.ModelDiscoveryService;
|
import vip.mate.llm.service.ModelDiscoveryService;
|
||||||
@ -23,9 +24,12 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* Startup runner: auto-detect running Ollama instance and register discovered models.
|
* Startup runner: auto-detect running Ollama instance and register discovered models.
|
||||||
* <p>
|
* <p>
|
||||||
* On application startup, pings the Ollama endpoint (default http://127.0.0.1:11434).
|
* On application startup, first checks whether the Ollama provider is enabled in
|
||||||
* If Ollama is online, discovers all pulled models and auto-enables matching pre-configured models.
|
* {@code mate_model_provider} — if not, skips immediately without any network
|
||||||
* If offline, silently skips (debug log only).
|
* traffic. When enabled, pings the Ollama endpoint (default
|
||||||
|
* http://127.0.0.1:11434); if online, discovers all pulled models and
|
||||||
|
* auto-enables matching pre-configured models. If offline, silently skips
|
||||||
|
* (debug log only).
|
||||||
*
|
*
|
||||||
* @author MateClaw Team
|
* @author MateClaw Team
|
||||||
*/
|
*/
|
||||||
@ -65,7 +69,22 @@ public class OllamaAutoDiscoveryRunner implements ApplicationRunner {
|
|||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) {
|
public void run(ApplicationArguments args) {
|
||||||
try {
|
try {
|
||||||
// Test connection first
|
// Skip the network probe entirely when the user hasn't enabled the
|
||||||
|
// Ollama provider — there's no point pinging localhost:11434 every
|
||||||
|
// boot for a provider that isn't part of the active model config.
|
||||||
|
ModelProviderEntity provider;
|
||||||
|
try {
|
||||||
|
provider = modelProviderService.getProviderConfig(OLLAMA_PROVIDER_ID);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("Ollama provider row missing, skipping auto-discovery");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Boolean.TRUE.equals(provider.getEnabled())) {
|
||||||
|
log.debug("Ollama provider disabled, skipping auto-discovery");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test connection
|
||||||
TestResult result = modelDiscoveryService.testConnection(OLLAMA_PROVIDER_ID);
|
TestResult result = modelDiscoveryService.testConnection(OLLAMA_PROVIDER_ID);
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
log.debug("Ollama not running, skipping auto-discovery: {}", result.getErrorMessage());
|
log.debug("Ollama not running, skipping auto-discovery: {}", result.getErrorMessage());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user