LOT 1 - Optimizare script build -Instalare mono comanda

This commit is contained in:
Dezvoltari Evotech 2026-06-27 06:42:02 -07:00
parent 5380c3fc63
commit 42ff22bf85
127 changed files with 16163 additions and 532 deletions

View file

@ -105,6 +105,21 @@ class VLLMBackend(LLMBackend):
"""Backend identifier name."""
return "vllm"
def _apply_thinking_default(self, kwargs: dict[str, object]) -> dict[str, object]:
"""Default reasoning models to non-thinking output for clean answers.
Injects ``extra_body={"chat_template_kwargs": {"enable_thinking": False}}``
unless the caller already supplied ``chat_template_kwargs``. Lets JSON-parsing
consumers (extractors, video semantic, brain) get the final answer directly.
"""
if not getattr(self._settings, "vllm_disable_thinking", True):
return kwargs
extra = dict(kwargs.get("extra_body") or {}) # type: ignore[arg-type]
ctk = dict(extra.get("chat_template_kwargs") or {})
ctk.setdefault("enable_thinking", False)
extra["chat_template_kwargs"] = ctk
return {**kwargs, "extra_body": extra}
async def complete(
self,
messages: list[ChatMessage],
@ -127,6 +142,8 @@ class VLLMBackend(LLMBackend):
LLMTimeoutError: If the request times out.
"""
kwargs = self._apply_thinking_default(kwargs)
async def _do_complete() -> CompletionResponse:
response = await self._client.chat.completions.create(
model=model,
@ -240,6 +257,7 @@ class VLLMBackend(LLMBackend):
LLMTimeoutError: If the request times out.
"""
stream = None
kwargs = self._apply_thinking_default(kwargs)
try:
stream = await self._client.chat.completions.create(
model=model,

View file

@ -111,6 +111,16 @@ class LLMSettings(BaseSettings):
default=None,
description="API key for vLLM server (if required)",
)
vllm_disable_thinking: bool = Field(
default=True,
description=(
"Inject chat_template_kwargs={'enable_thinking': False} on vLLM chat "
"requests so reasoning models (e.g. Qwen3.5) return the final answer "
"directly instead of a 'thinking' preamble — required for callers that "
"parse JSON (extractors sentiment/OCR, video semantic, brain). Callers "
"may override by passing their own chat_template_kwargs."
),
)
# llama.cpp settings
llamacpp_base_url: str = Field(