fix: normalize unicode escape sequences and reformat multi-line expressions across codebase
This commit is contained in:
@@ -66,14 +66,19 @@ class LLMClient:
|
||||
raise LLMError("Model response contained no message.", body=str(data)[:500])
|
||||
|
||||
record_usage(data.get("usage"))
|
||||
logger.debug("LLM response received (tool_calls=%s)", bool(message.get("tool_calls")))
|
||||
logger.debug(
|
||||
"LLM response received (tool_calls=%s)", bool(message.get("tool_calls"))
|
||||
)
|
||||
return message
|
||||
|
||||
async def summarize(self, text: str) -> str:
|
||||
payload = {
|
||||
"model": self._settings.ai_model,
|
||||
"messages": [
|
||||
{"role": "system", "content": "You are a precise technical summarizer."},
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a precise technical summarizer.",
|
||||
},
|
||||
{"role": "user", "content": text},
|
||||
],
|
||||
"temperature": 0.0,
|
||||
@@ -83,12 +88,16 @@ class LLMClient:
|
||||
except httpx.HTTPError as exc:
|
||||
raise LLMError(f"Could not reach the model endpoint: {exc}") from exc
|
||||
if response.status_code >= 400:
|
||||
raise LLMError(f"Model endpoint returned {response.status_code}: {self._reason(response)}")
|
||||
raise LLMError(
|
||||
f"Model endpoint returned {response.status_code}: {self._reason(response)}"
|
||||
)
|
||||
try:
|
||||
data = response.json()
|
||||
content = data["choices"][0]["message"]["content"] or ""
|
||||
except (ValueError, KeyError, IndexError) as exc:
|
||||
raise LLMError("Model summarization returned an unexpected response.") from exc
|
||||
raise LLMError(
|
||||
"Model summarization returned an unexpected response."
|
||||
) from exc
|
||||
record_usage(data.get("usage"))
|
||||
return content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user