17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173 | @router.get("/", response_model=List[ProviderInfo])
async def get_providers(
service: Annotated[SettingsService, Depends(get_settings_service)],
) -> Any:
"""
Retrieve the list of supported providers and their configuration status.
This allows the frontend to dynamically display available options.
"""
providers = []
# Helper to check if key exists (in DB or Env via SettingsService fallback)
async def is_configured(key: str) -> bool:
val = await service.get_value(key)
if val is None:
return False
val = str(val).strip()
# Consider empty or single asterisks (masked) as not configured
return bool(val and val != "" and not all(c == "*" for c in val))
# --- Embedding Providers ---
# Ollama
providers.append(
ProviderInfo(
id="ollama",
name="Ollama (Local)",
type="embedding",
description="GPU Accelerated & Efficient",
configured=await is_configured("ollama_base_url") or True, # Default is configured (localhost)
is_active=True,
supported_models=SUPPORTED_EMBEDDING_MODELS.get("ollama", []),
supported_transcription_models=SUPPORTED_TRANSCRIPTION_MODELS.get("ollama", []),
)
)
# Gemini
providers.append(
ProviderInfo(
id="gemini",
name="Google Gemini",
type="embedding",
description="Google DeepMind",
configured=await is_configured("gemini_api_key"),
is_active=True,
supported_models=SUPPORTED_EMBEDDING_MODELS.get("gemini", []),
supported_transcription_models=SUPPORTED_TRANSCRIPTION_MODELS.get("gemini", []),
)
)
# OpenAI
providers.append(
ProviderInfo(
id="openai",
name="OpenAI",
type="embedding",
description="Standard Industry Model",
configured=await is_configured("openai_api_key"),
is_active=True,
supported_models=SUPPORTED_EMBEDDING_MODELS.get("openai", []),
supported_transcription_models=SUPPORTED_TRANSCRIPTION_MODELS.get("openai", []),
)
)
# --- Chat Providers ---
# Ollama (Local)
providers.append(
ProviderInfo(
id="ollama",
name="Ollama (Local)",
type="chat",
description="Run models locally",
configured=True,
is_active=True,
supported_models=SUPPORTED_CHAT_MODELS.get("ollama", []),
)
)
# Gemini
providers.append(
ProviderInfo(
id="gemini",
name="Google Gemini",
type="chat",
description="Google DeepMind",
configured=await is_configured("gemini_api_key"),
is_active=True,
supported_models=SUPPORTED_CHAT_MODELS.get("gemini", []),
)
)
# OpenAI
providers.append(
ProviderInfo(
id="openai",
name="OpenAI",
type="chat",
description="ChatGPT",
configured=await is_configured("openai_api_key"),
is_active=True,
supported_models=SUPPORTED_CHAT_MODELS.get("openai", []),
)
)
# Mistral
providers.append(
ProviderInfo(
id="mistral",
name="Mistral AI",
type="chat",
description="European Champion",
configured=await is_configured("mistral_api_key"),
is_active=True,
supported_models=SUPPORTED_CHAT_MODELS.get("mistral", []),
)
)
# Anthropic
providers.append(
ProviderInfo(
id="anthropic",
name="Anthropic Claude",
type="chat",
description="Constitutional AI",
configured=await is_configured("anthropic_api_key"),
is_active=True,
supported_models=SUPPORTED_CHAT_MODELS.get("anthropic", []),
)
)
# --- Pertinence Providers ---
# Local (FastEmbed)
providers.append(
ProviderInfo(
id="local",
name="Pertinence Local (FastEmbed)",
type="rerank",
description="Private & Efficient (CPU)",
configured=True, # FastEmbed is built-in
is_active=True,
supported_models=SUPPORTED_RERANK_MODELS.get("local", []),
)
)
# Cohere
providers.append(
ProviderInfo(
id="cohere",
name="Cohere",
type="rerank",
description="Industry leader in Relevance",
configured=await is_configured("cohere_api_key"),
is_active=True,
supported_models=SUPPORTED_RERANK_MODELS.get("cohere", []),
)
)
return providers
|