# AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
# Generated by: npx ts-node scripts/generate-bot-sdk-types.ts
# Source of truth: TypeScript definitions in shared/
#
# To regenerate: yarn bot:types:generate
# To validate sync: yarn bot:types:check

from typing import Any, Dict, List, Optional, Union

from ._internal import _call_return, _call_no_return
from .bot_types import *
from .generated_enums import *

def message_send(
    id: Optional[str] = None,
    text: Optional[str] = None,
    markdown: Optional[str] = None,
    image: Optional[Image] = None,
    images: Optional[List[Optional[Image]]] = None,
    mention_user_ids: Optional[List[str]] = None,
    only_user_ids: Optional[List[str]] = None,
    lang: Optional[UserLang] = None,
    visibility: Optional[MessageVisibility] = None,
    color: Optional[MessageColor] = None,
    buttons: Optional[List[Button]] = None,
    mood: Optional[Mood] = None,
    impersonate_user_id: Optional[str] = None,
    file_ids: Optional[List[str]] = None,
    parent_message_id: Optional[str] = None,
) -> Message:
    """
    Send a message to the active conversation
    """
    result = _call_return(
        "botCodeMessageSend",
        {
            "id": id,
            "text": text,
            "markdown": markdown,
            "image": image,
            "images": images,
            "mention_user_ids": mention_user_ids,
            "only_user_ids": only_user_ids,
            "lang": lang,
            "visibility": visibility,
            "color": color,
            "buttons": buttons,
            "mood": mood,
            "impersonate_user_id": impersonate_user_id,
            "file_ids": file_ids,
            "parent_message_id": parent_message_id,
        },
    )
    return Message(**result)

def message_edit(
    id: Optional[str] = None,
    text: Optional[str] = None,
    markdown: Optional[str] = None,
) -> Message:
    """
    Edit an existing message
    """
    result = _call_return(
        "botCodeMessageEdit",
        {
            "id": id,
            "text": text,
            "markdown": markdown,
        },
    )
    return Message(**result)

def message_delete(
    id: Optional[str] = None,
) -> None:
    """
    Delete an existing message
    """
    _call_no_return(
        "botCodeMessageDelete",
        {
            "id": id,
        },
    )

def message_typing(
    parent_message_id: Optional[str] = None,
    future_message_id: Optional[str] = None,
) -> None:
    """
    Show a typing indicator in the active conversation
    """
    _call_no_return(
        "botCodeMessageTyping",
        {
            "parent_message_id": parent_message_id,
            "future_message_id": future_message_id,
        },
    )

def message_history(
    duration: Optional[int] = None,
    limit: Optional[int] = None,
    start: Optional[int] = None,
    include_hidden: Optional[bool] = None,
) -> List[Message]:
    """
    Get messages from the active conversation
    """
    result = _call_return(
        "botCodeMessageHistory",
        {
            "duration": duration,
            "limit": limit,
            "start": start,
            "include_hidden": include_hidden,
        },
    )
    return [Message(**item) for item in result]

def user_get(
    id: Optional[str] = None,
    user_id: Optional[str] = None,
) -> Optional[User]:
    """
    Get user by ID
    """
    result = _call_return(
        "botCodeUserGet",
        {
            "id": id,
            "user_id": user_id,
        },
    )
    return User(**result) if result is not None else None

def bot_get(
    id: Optional[str] = None,
    user_id: Optional[str] = None,
) -> Optional[Bot]:
    """
    Get bot by ID
    """
    result = _call_return(
        "botCodeBotGet",
        {
            "id": id,
            "user_id": user_id,
        },
    )
    return Bot(**result) if result is not None else None

def conversation_get(
    id: Optional[str] = None,
) -> Optional[Conversation]:
    """
    Get conversation by ID
    """
    result = _call_return(
        "botCodeConversationGet",
        {
            "id": id,
        },
    )
    return Conversation(**result) if result is not None else None

def file_create(
    type: Optional[FileType] = None,
    title: Optional[str] = None,
    markdown: Optional[str] = None,
    uri: Optional[str] = None,
    thumbnail: Optional[Image] = None,
    indexable: Optional[bool] = None,
    lang: Optional[UserLang] = None,
    scope: Optional[CodeFileCreateScope] = None,
    page: Optional[dict] = None,
    tags: Optional[List[str]] = None,
) -> File:
    """
    Create a new file
    """
    result = _call_return(
        "botCodeFileCreate",
        {
            "type": type,
            "title": title,
            "markdown": markdown,
            "uri": uri,
            "thumbnail": thumbnail,
            "indexable": indexable,
            "lang": lang,
            "scope": scope,
            "page": page,
            "tags": tags,
        },
    )
    return File(**result)

def file_get(
    id: Optional[str] = None,
) -> Optional[File]:
    """
    Get file by ID
    """
    result = _call_return(
        "botCodeFileGet",
        {
            "id": id,
        },
    )
    return File(**result) if result is not None else None

def file_update(
    id: Optional[str] = None,
    title: Optional[str] = None,
    markdown: Optional[str] = None,
    thumbnail: Optional[Image] = None,
    ui: Optional[dict] = None,
) -> None:
    """
    Update an existing file
    """
    _call_no_return(
        "botCodeFileUpdate",
        {
            "id": id,
            "title": title,
            "markdown": markdown,
            "thumbnail": thumbnail,
            "ui": ui,
        },
    )

def text_gen(
    question: Optional[str] = None,
    instruction: Optional[str] = None,
    messages: Optional[List[Union[TextGenMessage, Message]]] = None,
    model: Optional[TextGenModel] = None,
    abstract_model: Optional[TextGenAbstractModel] = None,
    priority: Optional[ProviderPriority] = None,
    routing_priority: Optional[ProviderPriority] = None,
    temperature: Optional[int] = None,
    top_k: Optional[int] = None,
    top_p: Optional[int] = None,
    max_tokens: Optional[int] = None,
    frequency_penalty: Optional[int] = None,
    presence_penalty: Optional[int] = None,
    repetition_penalty: Optional[int] = None,
    tools: Optional[List[TextGenTool]] = None,
    include_files: Optional[bool] = None,
    json: Optional[dict] = None,
) -> Optional[str]:
    """
    Generate text using the specified model (LLM). Use priority="price" (default) for cheapest provider or "performance" for fastest.
    """
    return _call_return(
        "botCodeTextGen",
        {
            "question": question,
            "instruction": instruction,
            "messages": messages,
            "model": model,
            "abstract_model": abstract_model,
            "priority": priority,
            "routing_priority": routing_priority,
            "temperature": temperature,
            "top_k": top_k,
            "top_p": top_p,
            "max_tokens": max_tokens,
            "frequency_penalty": frequency_penalty,
            "presence_penalty": presence_penalty,
            "repetition_penalty": repetition_penalty,
            "tools": tools,
            "include_files": include_files,
            "json": json,
        },
    )

def image_gen(
    model: Optional[ImageGenModel] = None,
    priority: Optional[ProviderPriority] = None,
    prompt: Optional[str] = None,
    negative_prompt: Optional[str] = None,
    size: Optional[str] = None,
    guidance_scale: Optional[int] = None,
    steps: Optional[int] = None,
    image: Optional[Image] = None,
    images: Optional[List[Optional[Image]]] = None,
    image_strength: Optional[int] = None,
    allow_sexual: Optional[bool] = None,
) -> Optional[Image]:
    """
    Generate an image using specified model. Use priority="price" (default) for cheapest provider or "performance" for fastest.
    """
    result = _call_return(
        "botCodeImageGen",
        {
            "model": model,
            "priority": priority,
            "prompt": prompt,
            "negative_prompt": negative_prompt,
            "size": size,
            "guidance_scale": guidance_scale,
            "steps": steps,
            "image": image,
            "images": images,
            "image_strength": image_strength,
            "allow_sexual": allow_sexual,
        },
    )
    return Image(**result) if result is not None else None

def query_files(
    query: Optional[str] = None,
    scope: Optional[QueryFilesScope] = None,
    catalog_ids: Optional[List[str]] = None,
    tags: Optional[List[str]] = None,
    limit: Optional[int] = None,
) -> List[FileChunk]:
    """
    Get files based on semantic search using the query
    """
    result = _call_return(
        "botCodeQueryFiles",
        {
            "query": query,
            "scope": scope,
            "catalog_ids": catalog_ids,
            "tags": tags,
            "limit": limit,
        },
    )
    return [FileChunk(**item) for item in result]

def email_send(
    user_id: Optional[str] = None,
    user_ids: Optional[List[str]] = None,
    subject: Optional[str] = None,
    text: Optional[str] = None,
    markdown: Optional[str] = None,
    file_id: Optional[str] = None,
) -> None:
    """
    Send an email to a user or multiple users
    """
    _call_no_return(
        "botCodeEmailSend",
        {
            "user_id": user_id,
            "user_ids": user_ids,
            "subject": subject,
            "text": text,
            "markdown": markdown,
            "file_id": file_id,
        },
    )

def conversation_users(
    type: Optional[str] = None,
    role: Optional[str] = None,
) -> List[User]:
    """
    Get users in the active conversation
    """
    result = _call_return(
        "botCodeConversationUsers",
        {
            "type": type,
            "role": role,
        },
    )
    return [User(**item) for item in result]

def conversation_bots(
    tag: Optional[BotTag] = None,
) -> List[Bot]:
    """
    Get bots in the active conversation
    """
    result = _call_return(
        "botCodeConversationBots",
        {
            "tag": tag,
        },
    )
    return [Bot(**item) for item in result]

def google_search(
    query: Optional[str] = None,
) -> List[SearchArticle]:
    """
    Search the web using Google
    """
    result = _call_return(
        "botCodeGoogleSearch",
        {
            "query": query,
        },
    )
    return [SearchArticle(**item) for item in result]

