import voluptuous as vol
from . import AnthropicConfigEntry as AnthropicConfigEntry
from .const import CONF_CHAT_MODEL as CONF_CHAT_MODEL, CONF_CODE_EXECUTION as CONF_CODE_EXECUTION, CONF_MAX_TOKENS as CONF_MAX_TOKENS, CONF_TEMPERATURE as CONF_TEMPERATURE, CONF_THINKING_BUDGET as CONF_THINKING_BUDGET, CONF_THINKING_EFFORT as CONF_THINKING_EFFORT, CONF_WEB_SEARCH as CONF_WEB_SEARCH, CONF_WEB_SEARCH_CITY as CONF_WEB_SEARCH_CITY, CONF_WEB_SEARCH_COUNTRY as CONF_WEB_SEARCH_COUNTRY, CONF_WEB_SEARCH_MAX_USES as CONF_WEB_SEARCH_MAX_USES, CONF_WEB_SEARCH_REGION as CONF_WEB_SEARCH_REGION, CONF_WEB_SEARCH_TIMEZONE as CONF_WEB_SEARCH_TIMEZONE, CONF_WEB_SEARCH_USER_LOCATION as CONF_WEB_SEARCH_USER_LOCATION, DEFAULT as DEFAULT, DOMAIN as DOMAIN, LOGGER as LOGGER, MIN_THINKING_BUDGET as MIN_THINKING_BUDGET, NON_ADAPTIVE_THINKING_MODELS as NON_ADAPTIVE_THINKING_MODELS, NON_THINKING_MODELS as NON_THINKING_MODELS, UNSUPPORTED_STRUCTURED_OUTPUT_MODELS as UNSUPPORTED_STRUCTURED_OUTPUT_MODELS
from _typeshed import Incomplete
from anthropic import AsyncStream as AsyncStream
from anthropic.types import Container as Container, ContentBlockParam as ContentBlockParam, DocumentBlockParam, ImageBlockParam, MessageDeltaUsage as MessageDeltaUsage, MessageParam, MessageStreamEvent as MessageStreamEvent, TextCitation as TextCitation, TextCitationParam as TextCitationParam, ToolParam, ToolUnionParam as ToolUnionParam, Usage as Usage
from collections.abc import AsyncGenerator, Callable as Callable, Iterable
from dataclasses import dataclass, field
from homeassistant.components import conversation as conversation
from homeassistant.config_entries import ConfigSubentry as ConfigSubentry
from homeassistant.core import HomeAssistant as HomeAssistant
from homeassistant.exceptions import HomeAssistantError as HomeAssistantError
from homeassistant.helpers import llm as llm
from homeassistant.helpers.entity import Entity as Entity
from homeassistant.helpers.json import json_dumps as json_dumps
from homeassistant.util import slugify as slugify
from homeassistant.util.json import JsonObjectType as JsonObjectType
from pathlib import Path
from typing import Any

MAX_TOOL_ITERATIONS: int

def _format_tool(tool: llm.Tool, custom_serializer: Callable[[Any], Any] | None) -> ToolParam: ...

@dataclass(slots=True)
class CitationDetails:
    index: int = ...
    length: int = ...
    citations: list[TextCitationParam] = field(default_factory=list)

@dataclass(slots=True)
class ContentDetails:
    citation_details: list[CitationDetails] = field(default_factory=list)
    thinking_signature: str | None = ...
    redacted_thinking: str | None = ...
    container: Container | None = ...
    def has_content(self) -> bool: ...
    def __bool__(self) -> bool: ...
    def has_citations(self) -> bool: ...
    def add_citation_detail(self) -> None: ...
    def add_citation(self, citation: TextCitation) -> None: ...
    def delete_empty(self) -> None: ...

def _convert_content(chat_content: Iterable[conversation.Content]) -> tuple[list[MessageParam], str | None]: ...
async def _transform_stream(chat_log: conversation.ChatLog, stream: AsyncStream[MessageStreamEvent], output_tool: str | None = None) -> AsyncGenerator[conversation.AssistantContentDeltaDict | conversation.ToolResultContentDeltaDict]: ...
def _create_token_stats(input_usage: Usage | None, response_usage: MessageDeltaUsage) -> dict[str, Any]: ...

class AnthropicBaseLLMEntity(Entity):
    _attr_has_entity_name: bool
    _attr_name: Incomplete
    entry: Incomplete
    subentry: Incomplete
    _attr_unique_id: Incomplete
    _attr_device_info: Incomplete
    def __init__(self, entry: AnthropicConfigEntry, subentry: ConfigSubentry) -> None: ...
    async def _async_handle_chat_log(self, chat_log: conversation.ChatLog, structure_name: str | None = None, structure: vol.Schema | None = None, max_iterations: int = ...) -> None: ...

async def async_prepare_files_for_prompt(hass: HomeAssistant, files: list[tuple[Path, str | None]]) -> Iterable[ImageBlockParam | DocumentBlockParam]: ...
