Skip to content

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.

docs: ChatAttachment (#2495)

Akshay Agrawaldd000ae955ee
diff --git a/docs/api/inputs/chat.md b/docs/api/inputs/chat.md
index 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 initial
configuration 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__.py
index 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.py
index 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 a
single 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 retrieved
from 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 retrieved
from the ANTHROPIC_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__(
@@ -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 retrieved
from the GOOGLE_AI_API_KEY environment variable
or the user's config.