Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0ff2e125b | ||
|
|
705804c503 |
@@ -30,7 +30,7 @@ jobs:
|
||||
-e RENOVATE_PLATFORM=gitea \
|
||||
-e RENOVATE_ENDPOINT=http://git.adam-french.co.uk:3000/api/v1 \
|
||||
-e RENOVATE_GIT_URL=endpoint \
|
||||
-e RENOVATE_REPOSITORIES=adamf/stpweb,adamf/stpgit \
|
||||
-e RENOVATE_REPOSITORIES=adamf/stpweb,adamf/stpgit,adamf/stppriv \
|
||||
-e RENOVATE_TOKEN \
|
||||
-e GITHUB_COM_TOKEN \
|
||||
-e LOG_LEVEL=info \
|
||||
|
||||
+16
-4
@@ -82,7 +82,10 @@ def _model_options(model: str, max_tokens: int) -> dict:
|
||||
"""
|
||||
if model.startswith(_NO_EFFORT_PREFIXES):
|
||||
return {"max_tokens": max_tokens}
|
||||
return {"max_tokens": max_tokens + THINKING_HEADROOM, "output_config": {"effort": EFFORT}}
|
||||
return {
|
||||
"max_tokens": max_tokens + THINKING_HEADROOM,
|
||||
"output_config": {"effort": EFFORT},
|
||||
}
|
||||
|
||||
|
||||
def ask_json(
|
||||
@@ -122,7 +125,11 @@ def ask_json(
|
||||
NotConfigured: no API key.
|
||||
ReadError: with one of the three messages above.
|
||||
"""
|
||||
request = {"model": MODEL, "messages": messages, **_model_options(MODEL, max_tokens)}
|
||||
request = {
|
||||
"model": MODEL,
|
||||
"messages": messages,
|
||||
**_model_options(MODEL, max_tokens),
|
||||
}
|
||||
if system is not None:
|
||||
request["system"] = system
|
||||
|
||||
@@ -139,14 +146,19 @@ def ask_json(
|
||||
|
||||
# A refusal is a 200; log it as such rather than as an unparseable reply.
|
||||
if getattr(message, "stop_reason", None) == "refusal":
|
||||
log.warning("Claude declined the request: %s", getattr(message, "stop_details", None))
|
||||
log.warning(
|
||||
"Claude declined the request: %s", getattr(message, "stop_details", None)
|
||||
)
|
||||
raise ReadError(failed)
|
||||
|
||||
# By type: on a thinking model the first block may be a thinking block.
|
||||
text = next((block.text for block in message.content if block.type == "text"), None)
|
||||
if text is None:
|
||||
if getattr(message, "stop_reason", None) == "max_tokens":
|
||||
log.warning("Claude ran out of tokens before answering (max_tokens=%s)", request["max_tokens"])
|
||||
log.warning(
|
||||
"Claude ran out of tokens before answering (max_tokens=%s)",
|
||||
request["max_tokens"],
|
||||
)
|
||||
raise ReadError(empty)
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user