A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
docs: ChatAttachment (#2495)
Akshay Agrawaldd000ae955ee
diff --git a/docs/api/inputs/chat.md b/docs/api/inputs/chat.mdindex a5ed5a9eac..a5873ac5ab 100644--- a/docs/api/inputs/chat.md+++ b/docs/api/inputs/chat.md@@ -223,3 +223,9 @@ Chatbots can be implemented with a function that receives a list of[`mo.ui.chat`](#marimo.ui.chat) can be instantiated with an initialconfiguration with a dictionary conforming to the config.++`ChatMessage`s can also include attachments.++```{eval-rst}+.. autoclass:: marimo.ai.ChatAttachment+```diff --git a/marimo/_plugins/ai/__init__.py b/marimo/_plugins/ai/__init__.pyindex 357404cb5b..2a321b916f 100644--- a/marimo/_plugins/ai/__init__.py+++ b/marimo/_plugins/ai/__init__.py@@ -6,8 +6,13 @@ from __future__ import annotations__all__ = ["ChatMessage","ChatModelConfig",+ "ChatAttachment","llm",]from marimo._plugins.ui._impl.chat import llm-from marimo._plugins.ui._impl.chat.types import ChatMessage, ChatModelConfig+from marimo._plugins.ui._impl.chat.types import (+ ChatAttachment,+ ChatMessage,+ ChatModelConfig,+)diff --git a/marimo/_plugins/ui/_impl/chat/llm.py b/marimo/_plugins/ui/_impl/chat/llm.pyindex 3589494cc3..6429d5f0a8 100644--- a/marimo/_plugins/ui/_impl/chat/llm.py+++ b/marimo/_plugins/ui/_impl/chat/llm.py@@ -28,7 +28,7 @@ class simple(ChatModel):**Args:**- - delegate (Callable[[str], str]): A callable that takes a+ - delegate: A callable that takes asingle prompt and returns a response"""@@ -49,13 +49,13 @@ class openai(ChatModel):**Args:**- - model (str): The model to use.+ - model: The model to use.Can be found on the [OpenAI models page](https://platform.openai.com/docs/models)- - system_message (str): The system message to use- - api_key (Optional[str]): The API key to use.+ - system_message: The system message to use+ - api_key: The API key to use.If not provided, the API key will be retrievedfrom the OPENAI_API_KEY environment variable or the user's config.- - base_url (Optional[str]): The base URL to use+ - base_url: The base URL to use"""def __init__(@@ -139,13 +139,13 @@ class anthropic(ChatModel):**Args:**- - model (str): The model to use.- - system_message (str): The system message to use- - api_key (Optional[str]): The API key to use.+ - model: The model to use.+ - system_message: The system message to use+ - api_key: The API key to use.If not provided, the API key will be retrievedfrom the ANTHROPIC_API_KEY environment variableor the user's config.- - base_url (Optional[str]): The base URL to use+ - base_url: The base URL to use"""def __init__(@@ -236,9 +236,9 @@ class google(ChatModel):**Args:**- - model (str): The model to use.- - system_message (str): The system message to use- - api_key (Optional[str]): The API key to use.+ - model: The model to use.+ - system_message: The system message to use+ - api_key: The API key to use.If not provided, the API key will be retrievedfrom the GOOGLE_AI_API_KEY environment variableor the user's config.