YandexGPT provider was properly added and fixed.
This commit is contained in:
parent
49d3242987
commit
674c52b6c6
3 changed files with 36 additions and 1 deletions
|
|
@ -76,6 +76,18 @@ class Settings(BaseSettings):
|
||||||
ollama_timeout: float = 120.0
|
ollama_timeout: float = 120.0
|
||||||
ollama_max_concurrency: int = 3
|
ollama_max_concurrency: int = 3
|
||||||
|
|
||||||
|
# --- YandexGPT provider ---
|
||||||
|
yandexgpt_api_key: str = ""
|
||||||
|
yandexgpt_folder_id: str = ""
|
||||||
|
yandexgpt_model: str = "yandexgpt-lite"
|
||||||
|
yandexgpt_fallback_model: str = ""
|
||||||
|
yandexgpt_base_url: str = "https://llm.api.cloud.yandex.net"
|
||||||
|
yandexgpt_completion_path: str = "/foundationModels/v1/completion"
|
||||||
|
yandexgpt_temperature: float = 0.2
|
||||||
|
yandexgpt_max_tokens: int = 3072
|
||||||
|
yandexgpt_timeout: float = 120.0
|
||||||
|
yandexgpt_max_concurrency: int = 3
|
||||||
|
|
||||||
# --- API ---
|
# --- API ---
|
||||||
api_host: str = "0.0.0.0"
|
api_host: str = "0.0.0.0"
|
||||||
api_port: int = 8000
|
api_port: int = 8000
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from __future__ import annotations
|
||||||
from ..config import Settings
|
from ..config import Settings
|
||||||
from .ollama_cloud import OllamaCloudProvider
|
from .ollama_cloud import OllamaCloudProvider
|
||||||
from .port import LLMProvider
|
from .port import LLMProvider
|
||||||
|
from .yandex_gpt import YandexGPTProvider
|
||||||
|
|
||||||
|
|
||||||
def build_llm_provider(settings: Settings) -> LLMProvider:
|
def build_llm_provider(settings: Settings) -> LLMProvider:
|
||||||
|
|
@ -26,7 +27,21 @@ def build_llm_provider(settings: Settings) -> LLMProvider:
|
||||||
max_concurrency=settings.ollama_max_concurrency,
|
max_concurrency=settings.ollama_max_concurrency,
|
||||||
chunk_size=settings.chunk_size_chars,
|
chunk_size=settings.chunk_size_chars,
|
||||||
)
|
)
|
||||||
|
case "yandex_gpt":
|
||||||
|
return YandexGPTProvider(
|
||||||
|
api_key=settings.yandexgpt_api_key,
|
||||||
|
folder_id=settings.yandexgpt_folder_id,
|
||||||
|
model=settings.yandexgpt_model,
|
||||||
|
fallback_model=settings.yandexgpt_fallback_model or None,
|
||||||
|
base_url=settings.yandexgpt_base_url,
|
||||||
|
completion_path=settings.yandexgpt_completion_path,
|
||||||
|
temperature=settings.yandexgpt_temperature,
|
||||||
|
max_tokens=settings.yandexgpt_max_tokens,
|
||||||
|
timeout=settings.yandexgpt_timeout,
|
||||||
|
max_concurrency=settings.yandexgpt_max_concurrency,
|
||||||
|
chunk_size=settings.chunk_size_chars,
|
||||||
|
)
|
||||||
case _:
|
case _:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"unknown LLM_PROVIDER={settings.llm_provider!r} (expected: 'ollama_cloud')"
|
f"unknown LLM_PROVIDER={settings.llm_provider!r} (expected: 'ollama_cloud', 'yandex_gpt')"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,13 @@ class AnalyzeHandler:
|
||||||
error: str,
|
error: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
mq_failed.labels(queue="analyze", failure_class=failure_class).inc()
|
mq_failed.labels(queue="analyze", failure_class=failure_class).inc()
|
||||||
|
log.warning(
|
||||||
|
"analyze_failure_retrying",
|
||||||
|
document_id=str(payload.document_id),
|
||||||
|
attempt=attempt,
|
||||||
|
failure_class=failure_class,
|
||||||
|
error=error,
|
||||||
|
)
|
||||||
async with self._session_factory() as session:
|
async with self._session_factory() as session:
|
||||||
await session.execute(
|
await session.execute(
|
||||||
text(
|
text(
|
||||||
|
|
@ -254,4 +261,5 @@ class AnalyzeHandler:
|
||||||
"analyze_terminal_failure",
|
"analyze_terminal_failure",
|
||||||
document_id=str(payload.document_id),
|
document_id=str(payload.document_id),
|
||||||
failure_class=failure_class,
|
failure_class=failure_class,
|
||||||
|
error=error,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue