Made Jarvis more mobile friendly

This commit is contained in:
2026-04-21 11:00:39 +02:00
parent a72eef4b82
commit eaea8d94b1
14 changed files with 604 additions and 97 deletions
+17 -5
View File
@@ -83,7 +83,12 @@ class AnthropicProvider(AIProvider):
"max_tokens": max_tokens,
}
if system:
params["system"] = system
# Wrap in a content block with cache_control so the system prompt is
# cached across repeated calls (e.g. email handling runs). Cached tokens
# cost ~10% of normal input price after the first write.
params["system"] = [
{"type": "text", "text": system, "cache_control": {"type": "ephemeral"}}
]
if tools:
# aide tool schemas ARE Anthropic format — pass through directly
params["tools"] = tools
@@ -163,10 +168,17 @@ class AnthropicProvider(AIProvider):
arguments=block.input,
))
usage = UsageStats(
input_tokens=response.usage.input_tokens,
output_tokens=response.usage.output_tokens,
) if response.usage else UsageStats()
if response.usage:
cache_read = getattr(response.usage, "cache_read_input_tokens", 0) or 0
cache_write = getattr(response.usage, "cache_creation_input_tokens", 0) or 0
usage = UsageStats(
input_tokens=response.usage.input_tokens,
output_tokens=response.usage.output_tokens,
cache_read_tokens=cache_read,
cache_write_tokens=cache_write,
)
else:
usage = UsageStats()
finish_reason = response.stop_reason or "stop"
if tool_calls:
+2
View File
@@ -24,6 +24,8 @@ class ToolCallResult:
class UsageStats:
input_tokens: int = 0
output_tokens: int = 0
cache_read_tokens: int = 0 # Anthropic: tokens served from cache (billed at ~10%)
cache_write_tokens: int = 0 # Anthropic: tokens written to cache (billed at ~125%)
@property
def total_tokens(self) -> int: