perf(llm): short one-shot calls say so to Strata
Every call that no later request continues (call_llm_direct, call_llm_streaming, the warm-up and the v1 intent judge) now sends "strata_checkpoint": false on the OpenAI-compatible path. Strata's Qwen3.6 engine then gives that call's session away first, so with two or more requests at once a reply's tool turn keeps its session through the short calls made between its steps. The reply loop's chat_with_messages is not marked (its next step continues it); the Ollama API gets no new field. With one request at once nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,7 @@ def warm_up_ollama_model(base_url: str, model: str, timeout: float) -> bool:
|
||||
if is_openai_compatible(base_url):
|
||||
# The server loads its model at launch; one token checks it answers.
|
||||
body = openai_chat_body(model, [{"role": "user", "content": "hi"}], stream=False,
|
||||
thinking=False, max_tokens=1)
|
||||
thinking=False, max_tokens=1, one_shot=True)
|
||||
try:
|
||||
response = post_chat_completion(base_url, body, timeout)
|
||||
ok = response.status_code == 200
|
||||
@@ -438,6 +438,7 @@ Examples:
|
||||
self.config.model,
|
||||
[{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}],
|
||||
stream=False, thinking=self.config.thinking, max_tokens=200, temperature=0.0,
|
||||
one_shot=True,
|
||||
),
|
||||
self.config.timeout_sec,
|
||||
)
|
||||
|
||||
@@ -110,7 +110,11 @@ def openai_chat_body(
|
||||
max_tokens: Optional[int] = None,
|
||||
temperature: Optional[float] = None,
|
||||
tools: Optional[List[Dict[str, Any]]] = None,
|
||||
one_shot: bool = False,
|
||||
) -> Dict[str, Any]:
|
||||
"""``one_shot``: no later request continues this one (a classification, an extraction, a
|
||||
warm-up). Strata then gives its session away first, so a reply's tool turn keeps its own
|
||||
session through the short calls made between its steps; other servers ignore the field."""
|
||||
body: Dict[str, Any] = {
|
||||
"model": chat_model,
|
||||
"messages": _openai_messages(messages),
|
||||
@@ -124,6 +128,8 @@ def openai_chat_body(
|
||||
body["temperature"] = temperature
|
||||
if tools:
|
||||
body["tools"] = tools
|
||||
if one_shot:
|
||||
body["strata_checkpoint"] = False
|
||||
return body
|
||||
|
||||
|
||||
@@ -246,7 +252,8 @@ def call_llm_direct(base_url: str, chat_model: str, system_prompt: str, user_con
|
||||
|
||||
if is_openai_compatible(base_url):
|
||||
caller = _caller_name()
|
||||
body = openai_chat_body(chat_model, messages, stream=False, thinking=thinking, temperature=temperature)
|
||||
body = openai_chat_body(chat_model, messages, stream=False, thinking=thinking, temperature=temperature,
|
||||
one_shot=True)
|
||||
try:
|
||||
content = _openai_chat(base_url, body, timeout_sec, caller)["message"]["content"]
|
||||
if content.strip():
|
||||
@@ -386,7 +393,7 @@ def _openai_stream(
|
||||
thinking: bool,
|
||||
) -> Optional[str]:
|
||||
"""Server-sent-events stream from ``/chat/completions``; answer text only (no reasoning)."""
|
||||
body = openai_chat_body(chat_model, messages, stream=True, thinking=thinking)
|
||||
body = openai_chat_body(chat_model, messages, stream=True, thinking=thinking, one_shot=True)
|
||||
try:
|
||||
with post_chat_completion(base_url, body, timeout_sec, stream=True) as resp:
|
||||
resp.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user