Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 100 additions & 12 deletions chatlas/data/prices.json
Original file line number Diff line number Diff line change
Expand Up @@ -1140,17 +1140,17 @@
"provider": "AWS/Bedrock",
"model": "us-gov-east-1/anthropic.claude-sonnet-4-5-20250929-v1:0",
"variant": "",
"input": 3.3,
"output": 16.5,
"cached_input": 0.33
"input": 3.6,
"output": 18,
"cached_input": 0.36
},
{
"provider": "AWS/Bedrock",
"model": "us-gov-east-1/claude-sonnet-4-5-20250929-v1:0",
"variant": "",
"input": 3.3,
"output": 16.5,
"cached_input": 0.33
"input": 3.6,
"output": 18,
"cached_input": 0.36
},
{
"provider": "AWS/Bedrock",
Expand Down Expand Up @@ -1244,17 +1244,17 @@
"provider": "AWS/Bedrock",
"model": "us-gov-west-1/anthropic.claude-sonnet-4-5-20250929-v1:0",
"variant": "",
"input": 3.3,
"output": 16.5,
"cached_input": 0.33
"input": 3.6,
"output": 18,
"cached_input": 0.36
},
{
"provider": "AWS/Bedrock",
"model": "us-gov-west-1/claude-sonnet-4-5-20250929-v1:0",
"variant": "",
"input": 3.3,
"output": 16.5,
"cached_input": 0.33
"input": 3.6,
"output": 18,
"cached_input": 0.36
},
{
"provider": "AWS/Bedrock",
Expand Down Expand Up @@ -4271,6 +4271,87 @@
"output": 1.5,
"cached_input": 0.025
},
{
"provider": "Groq",
"model": "gemma-7b-it",
"variant": "",
"input": 0.05,
"output": 0.08
},
{
"provider": "Groq",
"model": "llama-3.1-8b-instant",
"variant": "",
"input": 0.05,
"output": 0.08
},
{
"provider": "Groq",
"model": "llama-3.3-70b-versatile",
"variant": "",
"input": 0.59,
"output": 0.79
},
{
"provider": "Groq",
"model": "meta-llama/llama-4-maverick-17b-128e-instruct",
"variant": "",
"input": 0.2,
"output": 0.6
},
{
"provider": "Groq",
"model": "meta-llama/llama-4-scout-17b-16e-instruct",
"variant": "",
"input": 0.11,
"output": 0.34
},
{
"provider": "Groq",
"model": "meta-llama/llama-guard-4-12b",
"variant": "",
"input": 0.2,
"output": 0.2
},
{
"provider": "Groq",
"model": "moonshotai/kimi-k2-instruct-0905",
"variant": "",
"input": 1,
"output": 3,
"cached_input": 0.5
},
{
"provider": "Groq",
"model": "openai/gpt-oss-120b",
"variant": "",
"input": 0.15,
"output": 0.6,
"cached_input": 0.075
},
{
"provider": "Groq",
"model": "openai/gpt-oss-20b",
"variant": "",
"input": 0.075,
"output": 0.3,
"cached_input": 0.0375
},
{
"provider": "Groq",
"model": "openai/gpt-oss-safeguard-20b",
"variant": "",
"input": 0.075,
"output": 0.3,
"cached_input": 0.037
},
Comment thread
cpsievert marked this conversation as resolved.
{
"provider": "Groq",
"model": "qwen/qwen3-32b",
"variant": "",
"input": 0.29,
"output": 0.59
},
{
"provider": "Mistral",
"model": "codestral-2405",
Expand Down Expand Up @@ -4444,6 +4525,13 @@
"input": 0.15,
"output": 0.15
},
{
"provider": "Mistral",
"model": "ministral-8b-latest",
"variant": "",
"input": 0.15,
"output": 0.15
},
{
"provider": "Mistral",
"model": "mistral-embed",
Expand Down
38 changes: 37 additions & 1 deletion chatlas/types/anthropic/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
# ---------------------------------------------------------


from typing import Any, Mapping, Optional, TypedDict
from typing import (
Any,
Awaitable,
Callable,
Mapping,
Optional,
Sequence,
TypedDict,
Union,
)

import anthropic
import anthropic._response
import anthropic.lib.credentials._cache
import anthropic.lib.credentials._types
import httpx
Expand All @@ -24,6 +34,32 @@ class ChatClientArgs(TypedDict, total=False):
default_headers: Optional[Mapping[str, str]]
default_query: Optional[Mapping[str, object]]
http_client: httpx.AsyncClient | None
middleware: Optional[
Sequence[
Union[
anthropic.Middleware,
Callable[
[
anthropic.APIRequest,
Callable[
[anthropic.APIRequest], anthropic._response.APIResponse[Any]
],
],
anthropic._response.APIResponse[Any],
],
Callable[
[
anthropic.APIRequest,
Callable[
[anthropic.APIRequest],
Awaitable[anthropic._response.AsyncAPIResponse[Any]],
],
],
Awaitable[anthropic._response.AsyncAPIResponse[Any]],
],
]
]
]
_strict_response_validation: bool
_token_cache: (
anthropic.lib.credentials._cache.TokenCache | None | anthropic.NotGiven
Expand Down
38 changes: 37 additions & 1 deletion chatlas/types/anthropic/_client_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@
# Do not modify this file. It was generated by `scripts/generate_typed_dicts.py`.
# ---------------------------------------------------------

from typing import Mapping, Optional, TypedDict
from typing import (
Any,
Awaitable,
Callable,
Mapping,
Optional,
Sequence,
TypedDict,
Union,
)

import anthropic
import anthropic._response
import httpx


Expand All @@ -21,4 +31,30 @@ class ChatBedrockClientArgs(TypedDict, total=False):
default_headers: Optional[Mapping[str, str]]
default_query: Optional[Mapping[str, object]]
http_client: httpx.AsyncClient | None
middleware: Optional[
Sequence[
Union[
anthropic.Middleware,
Callable[
[
anthropic.APIRequest,
Callable[
[anthropic.APIRequest], anthropic._response.APIResponse[Any]
],
],
anthropic._response.APIResponse[Any],
],
Callable[
[
anthropic.APIRequest,
Callable[
[anthropic.APIRequest],
Awaitable[anthropic._response.AsyncAPIResponse[Any]],
],
],
Awaitable[anthropic._response.AsyncAPIResponse[Any]],
],
]
]
]
_strict_response_validation: bool
2 changes: 2 additions & 0 deletions chatlas/types/anthropic/_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class SubmitInputArgs(TypedDict, total=False):
messages: Iterable[anthropic.types.message_param.MessageParam]
model: Union[
Literal[
"claude-fable-5",
"claude-mythos-5",
"claude-opus-4-8",
"claude-opus-4-7",
"claude-mythos-preview",
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dev = [
"pandas",
"polars",
"openai",
"anthropic[bedrock]",
"anthropic[bedrock]>=0.109.1",
"google-genai>=1.14.0",
"numpy>1.24.4",
"tiktoken",
Expand Down Expand Up @@ -98,8 +98,8 @@ eval = [
"inspect-ai;python_version>='3.10'"
]
# Provider extras ----
anthropic = ["anthropic"]
bedrock-anthropic = ["anthropic[bedrock]"]
anthropic = ["anthropic>=0.109.1"]
bedrock-anthropic = ["anthropic[bedrock]>=0.109.1"]
databricks = ["databricks-sdk"]
# Intentionally empty since these providers used to require
# an additional openai install, but that's now included
Expand Down
11 changes: 9 additions & 2 deletions scripts/_generate_anthropic_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import httpx
from anthropic import AsyncAnthropic, AsyncAnthropicBedrock
from anthropic._response import APIResponse, AsyncAPIResponse
from anthropic.resources import AsyncMessages

from _utils import generate_typeddict_code, write_code_to_file
Expand All @@ -27,11 +28,17 @@
provider_dir / "_submit.py",
)

_anthropic_localns = {
"URL": httpx.URL,
"APIResponse": APIResponse,
"AsyncAPIResponse": AsyncAPIResponse,
}

init_args = generate_typeddict_code(
AsyncAnthropic.__init__,
"ChatClientArgs",
excluded_fields={"self"},
localns={"URL": httpx.URL},
localns=_anthropic_localns,
)

write_code_to_file(
Expand All @@ -44,7 +51,7 @@
AsyncAnthropicBedrock.__init__,
"ChatBedrockClientArgs",
excluded_fields={"self"},
localns={"URL": httpx.URL},
localns=_anthropic_localns,
)

write_code_to_file(
Expand Down
43 changes: 43 additions & 0 deletions scripts/_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import collections.abc
import inspect
import re
import subprocess
Expand Down Expand Up @@ -111,6 +112,39 @@ def get_type_string(typ: Any) -> tuple[str, set[str]]:
args = ", ".join(repr(arg) for arg in typ.__args__)
imports.add("from typing import Literal")
return f"Literal[{args}]", imports
if origin is collections.abc.Callable:
type_args = typ.__args__ or ()

# typing.Callable is typically represented as (Ellipsis, R) or (A, B, R)
# (older versions may use ([A, B], R)).
if not type_args:
imports.add("from typing import Callable")
return "Callable[..., Any]", imports

ret_type = type_args[-1]
params = type_args[:-1]

# Handle Callable[..., R]
if len(type_args) == 2 and type_args[0] is Ellipsis:
ret_str, ret_imports = get_type_string(ret_type)
imports.update(ret_imports)
imports.add("from typing import Callable")
return f"Callable[..., {ret_str}]", imports

# Handle Callable[[A, B], R]
if len(type_args) == 2 and isinstance(type_args[0], (list, tuple)):
params = tuple(type_args[0])

param_strs = []
for arg in params:
arg_str, arg_imports = get_type_string(arg)
param_strs.append(arg_str)
imports.update(arg_imports)

ret_str, ret_imports = get_type_string(ret_type)
imports.update(ret_imports)
imports.add("from typing import Callable")
return f"Callable[[{', '.join(param_strs)}], {ret_str}]", imports
Comment thread
Copilot marked this conversation as resolved.
origin_name = origin.__name__
args = []
for arg in typ.__args__:
Expand All @@ -119,6 +153,15 @@ def get_type_string(typ: Any) -> tuple[str, set[str]]:
imports.update(arg_imports)
if origin_name in TYPING_IMPORTS:
imports.add(f"from typing import {origin_name}")
elif getattr(origin, "__module__", "builtins") not in (
"builtins",
"typing",
"typing_extensions",
"collections.abc",
):
module = origin.__module__
imports.add(f"import {module}")
origin_name = f"{module}.{origin_name}"
return f"{origin_name}[{', '.join(args)}]", imports
elif isinstance(typ, type):
module = typ.__module__
Expand Down
Loading