/
/
/
1"""Constants for the OpenAI Compatible provider."""
2
3from __future__ import annotations
4
5from typing import Final
6
7CONF_SERVICE: Final = "service"
8CONF_BASE_URL: Final = "base_url"
9CONF_API_KEY: Final = "api_key"
10CONF_MODELS: Final = "models"
11
12SERVICE_CUSTOM: Final = "custom"
13
14# base URLs of the services this is most often pointed at, so the address does not have
15# to be looked up. SERVICE_CUSTOM covers everything else, and the address stays editable
16# either way - a localhost default is wrong whenever the server runs on another machine.
17SERVICE_BASE_URLS: Final = {
18 "openai": "https://api.openai.com/v1",
19 "groq": "https://api.groq.com/openai/v1",
20 "openrouter": "https://openrouter.ai/api/v1",
21 "together": "https://api.together.xyz/v1",
22 "ollama": "http://localhost:11434/v1",
23 "lmstudio": "http://localhost:1234/v1",
24}
25
26DEFAULT_SERVICE: Final = "openai"
27
28# the shared HTTP session carries no deadline of its own, so each call brings one.
29# Generous enough for a local server on CPU, while still well short of the point
30# where a caller waiting on the answer has any use for it.
31CHAT_REQUEST_TIMEOUT: Final = 120
32
33# the model listing only fills a picker, so it gets a shorter deadline: a slow
34# endpoint must not hold up the settings page
35MODELS_REQUEST_TIMEOUT: Final = 15
36