Skip to content

Anthropic

minisweagent.models.anthropic

AnthropicModel

AnthropicModel(**kwargs)

Bases: LitellmModel

For the use of anthropic models, we need to add explicit cache control marks to the messages or we lose out on the benefits of the cache. Because break points are limited per key, we also need to rotate between different keys if running with multiple agents in parallel threads.

Source code in src/minisweagent/models/litellm_model.py
26
27
28
29
def __init__(self, **kwargs):
    self.config = LitellmModelConfig(**kwargs)
    self.cost = 0.0
    self.n_calls = 0

query

query(messages: list[dict], **kwargs) -> dict
Source code in src/minisweagent/models/anthropic.py
15
16
17
18
19
def query(self, messages: list[dict], **kwargs) -> dict:
    api_key = None
    if rotating_keys := os.getenv("ANTHROPIC_API_KEYS"):
        api_key = get_key_per_thread(rotating_keys.split("::"))
    return super().query(set_cache_control(messages), api_key=api_key, **kwargs)