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
Migrate to pydantic-ai for google & anthropic providers (#7425)
Shahmir Varqhae889872684e9
diff --git a/frontend/src/components/chat/chat-panel.tsx b/frontend/src/components/chat/chat-panel.tsxindex 8ebc66ad8d..359465136c 100644--- a/frontend/src/components/chat/chat-panel.tsx+++ b/frontend/src/components/chat/chat-panel.tsx@@ -4,7 +4,12 @@ import type { UIMessage } from "@ai-sdk/react";import { useChat } from "@ai-sdk/react";import { storePrompt } from "@marimo-team/codemirror-ai";import type { ReactCodeMirrorRef } from "@uiw/react-codemirror";-import { DefaultChatTransport, type ToolUIPart } from "ai";+import {+ DefaultChatTransport,+ type FileUIPart,+ type TextUIPart,+ type ToolUIPart,+} from "ai";import { useAtom, useAtomValue, useSetAtom, useStore } from "jotai";import {AtSignIcon,@@ -147,9 +152,13 @@ function isToolPart(part: UIMessage["parts"][number]): part is ToolUIPart {const ChatMessageDisplay: React.FC<ChatMessageProps> = memo(({ message, index, onEdit, isStreamingReasoning, isLast }) => {const renderUserMessage = (message: UIMessage) => {- const textParts = message.parts?.filter((p) => p.type === "text");+ const textParts = message.parts?.filter(+ (p): p is TextUIPart => p.type === "text",+ );const content = textParts?.map((p) => p.text).join("\n");- const fileParts = message.parts?.filter((p) => p.type === "file");+ const fileParts = message.parts?.filter(+ (p): p is FileUIPart => p.type === "file",+ );return (<div className="w-[95%] bg-background border p-1 rounded-sm">@@ -178,7 +187,9 @@ const ChatMessageDisplay: React.FC<ChatMessageProps> = memo(};const renderOtherMessage = (message: UIMessage) => {- const textParts = message.parts.filter((p) => p.type === "text");+ const textParts = message.parts.filter(+ (p): p is TextUIPart => p.type === "text",+ );const content = textParts.map((p) => p.text).join("\n");return (@@ -237,6 +248,11 @@ const ChatMessageDisplay: React.FC<ChatMessageProps> = memo(case "data-reasoning-signature":return null;+ // TODO: We could render lines, for now don't render them. They do not have information.+ case "step-start":+ Logger.debug("Found step-start part", part);+ return null;+/* handle other part types … */default:if (part.type.startsWith("data-")) {@@ -553,7 +569,7 @@ const ChatPanelBody = () => {status,regenerate,stop,- addToolResult,+ addToolOutput,id: chatId,} = useChat({id: activeChatId,@@ -599,7 +615,7 @@ const ChatPanelBody = () => {await handleToolCall({invokeAiTool,- addToolResult,+ addToolOutput,toolCall: {toolName: toolCall.toolName,toolCallId: toolCall.toolCallId,diff --git a/frontend/src/components/chat/chat-utils.ts b/frontend/src/components/chat/chat-utils.tsindex 190890e133..0bd4593ff2 100644--- a/frontend/src/components/chat/chat-utils.ts+++ b/frontend/src/components/chat/chat-utils.ts@@ -68,7 +68,8 @@ function stringifyTextParts(parts: UIMessage["parts"]): string {export async function buildCompletionRequestBody(messages: UIMessage[],): Promise<{- messages: ChatMessage[];+ messages: ChatMessage[]; // Deprecated. TODO: Remove in the future+ uiMessages: UIMessage[];context?: (null | components["schemas"]["AiCompletionContext"]) | undefined;includeOtherCode: string;selectedText?: string | null | undefined;@@ -76,8 +77,20 @@ export async function buildCompletionRequestBody(const input = stringifyTextParts(messages.flatMap((m) => m.parts));const completionBody = await getAICompletionBodyWithAttachments({ input });- // Map from UIMessage to our ChatMessage type// If it's the last message, add the attachments from the completion body+ function addAttachmentsToMessage(+ message: UIMessage,+ isLast: boolean,+ ): UIMessage {+ if (!isLast) {+ return message;+ }+ return {+ ...message,+ parts: [...message.parts, ...completionBody.attachments],+ };+ }+function toChatMessage(message: UIMessage, isLast: boolean): ChatMessage {// Clone parts to avoid mutating the original messageconst parts = [...message.parts];@@ -96,10 +109,13 @@ export async function buildCompletionRequestBody(messages: messages.map((m, idx) =>toChatMessage(m, idx === messages.length - 1),),+ uiMessages: messages.map((m, idx) =>+ addAttachmentsToMessage(m, idx === messages.length - 1),+ ),};}-interface AddToolResult {+interface AddToolOutput {tool: string;toolCallId: string;output: unknown;@@ -107,12 +123,12 @@ interface AddToolResult {export async function handleToolCall({invokeAiTool,- addToolResult, // Important that we don't await addToolResult to prevent potential deadlocks+ addToolOutput, // Important that we don't await addToolOutput to prevent potential deadlockstoolCall,toolContext,}: {invokeAiTool: (request: InvokeAiToolRequest) => Promise<InvokeAiToolResponse>;- addToolResult: (result: AddToolResult) => Promise<void>;+ addToolOutput: (output: AddToolOutput) => Promise<void>;toolCall: {toolName: string;toolCallId: string;@@ -128,7 +144,7 @@ export async function handleToolCall({toolCall.input,toolContext,);- addToolResult({+ addToolOutput({tool: toolCall.toolName,toolCallId: toolCall.toolCallId,output: response.result || response.error,@@ -137,9 +153,9 @@ export async function handleToolCall({// Invoke the backend/mcp toolconst response = await invokeAiTool({toolName: toolCall.toolName,- arguments: toolCall.input,+ arguments: toolCall.input ?? {}, // Some models pass in null, so we default to an empty object});- addToolResult({+ addToolOutput({tool: toolCall.toolName,toolCallId: toolCall.toolCallId,output: response.result || response.error,@@ -147,7 +163,7 @@ export async function handleToolCall({}} catch (error) {Logger.error("Tool call failed:", error);- addToolResult({+ addToolOutput({tool: toolCall.toolName,toolCallId: toolCall.toolCallId,output: `Error: ${error instanceof Error ? error.message : String(error)}`,diff --git a/frontend/src/components/editor/ai/add-cell-with-ai.tsx b/frontend/src/components/editor/ai/add-cell-with-ai.tsxindex 319728c4bf..e00905a82d 100644--- a/frontend/src/components/editor/ai/add-cell-with-ai.tsx+++ b/frontend/src/components/editor/ai/add-cell-with-ai.tsx@@ -98,7 +98,7 @@ export const AddCellWithAI: React.FC<{sendRun,};- const { sendMessage, stop, status, addToolResult } = useChat({+ const { sendMessage, stop, status, addToolOutput } = useChat({// Throttle the messages and data updates to 100msexperimental_throttle: 100,transport: new StreamingChunkTransport(@@ -129,7 +129,7 @@ export const AddCellWithAI: React.FC<{onToolCall: async ({ toolCall }) => {await handleToolCall({invokeAiTool,- addToolResult,+ addToolOutput,toolCall: {toolName: toolCall.toolName,toolCallId: toolCall.toolCallId,diff --git a/frontend/src/core/ai/staged-cells.ts b/frontend/src/core/ai/staged-cells.tsindex 89ec291da0..d16e785ef7 100644--- a/frontend/src/core/ai/staged-cells.ts+++ b/frontend/src/core/ai/staged-cells.ts@@ -8,6 +8,7 @@ import {} from "@/components/editor/ai/completion-utils";import { useDeleteCellCallback } from "@/components/editor/cell/useDeleteCell";import { CellId } from "@/core/cells/ids";+import { logNever } from "@/utils/assertNever";import { createReducerAndAtoms } from "@/utils/createReducer";import { Logger } from "@/utils/Logger";import { maybeAddMarimoImport } from "../cells/add-missing-import";@@ -154,8 +155,37 @@ export function useStagedCells(store: JotaiStore) {}cellCreationStream.current.stop();break;+ case "abort":+ case "error":+ case "tool-input-error":+ case "tool-output-error":+ Logger.error("Error", chunk.type, { chunk });+ break;+ // These logs are not useful for debugging+ case "start":+ case "start-step":+ case "finish-step":+ case "data-reasoning-signature":+ break;+ case "message-metadata":+ case "tool-input-available":+ case "tool-output-available":+ case "reasoning-start":+ case "reasoning-delta":+ case "reasoning-end":+ case "file":+ case "source-document":+ case "source-url":+ case "tool-input-start":+ case "tool-input-delta":+ Logger.debug(chunk.type, { chunk });+ break;default:- Logger.error("Unknown chunk type", { chunk });+ if (isDataChunk(chunk)) {+ Logger.debug("Data chunk", { chunk });+ break;+ }+ logNever(chunk);}};@@ -256,3 +286,9 @@ class CellCreationStream {this.buffer = "";}}++type DataChunk = Extract<UIMessageChunk, { type: `data-${string}` }>;++function isDataChunk(chunk: UIMessageChunk): chunk is DataChunk {+ return chunk.type.startsWith("data-");+}diff --git a/marimo/_ai/_convert.py b/marimo/_ai/_convert.pyindex 1acdf22e33..6a3e842b62 100644--- a/marimo/_ai/_convert.py+++ b/marimo/_ai/_convert.py@@ -135,7 +135,7 @@ def convert_to_openai_messages(elif media_type.startswith("text"):file_text_part: ChatCompletionContentPartTextParam = {"type": "text",- "text": _extract_text(part.url),+ "text": extract_text(part.url),}current_parts.append(file_text_part)else:@@ -307,7 +307,7 @@ def convert_to_anthropic_messages(elif media_type.startswith("text"):file_text_part: TextBlockParam = {"type": "text",- "text": _extract_text(part.url),+ "text": extract_text(part.url),}current_parts.append(file_text_part)else:@@ -337,7 +337,7 @@ def convert_to_groq_messages(text_content = str(message.content) # Explicitly convert to stringfor file in file_parts:if file.media_type.startswith("text"):- text_content += "\n" + _extract_text(file.url)+ text_content += "\n" + extract_text(file.url)else:raise ValueError(f"Unsupported content type {file.media_type}. Only text content is supported."@@ -454,7 +454,7 @@ def convert_to_google_messages(return google_messages-def _extract_text(url: str) -> str:+def extract_text(url: str) -> str:if url.startswith("data:"):# extract base64 encoding from urldata = url.split(",")[1]diff --git a/marimo/_ai/_pydantic_ai_utils.py b/marimo/_ai/_pydantic_ai_utils.pynew file mode 100644index 0000000000..d38a9ba6ca--- /dev/null+++ b/marimo/_ai/_pydantic_ai_utils.py@@ -0,0 +1,121 @@+# Copyright 2025 Marimo. All rights reserved.+from __future__ import annotations++import uuid+from typing import TYPE_CHECKING, Any, Callable++from marimo import _loggers+from marimo._messaging.msgspec_encoder import asdict+from marimo._server.ai.tools.types import ToolDefinition+from marimo._server.models.completion import UIMessage as ServerUIMessage++LOGGER = _loggers.marimo_logger()++if TYPE_CHECKING:+ from pydantic_ai import FunctionToolset+ from pydantic_ai.ui.vercel_ai.request_types import UIMessage, UIMessagePart+++def generate_id(prefix: str) -> str:+ return f"{prefix}_{uuid.uuid4().hex}"+++def form_toolsets(+ tools: list[ToolDefinition],+ tool_invoker: Callable[[str, dict[str, Any]], Any],+) -> tuple[FunctionToolset, bool]:+ """+ Because we have a list of tool definitions and call them in a separate event loop,+ we create a closure to invoke the tool (backend) or raise a CallDeferred (frontend).+ Ref: https://ai.pydantic.dev/toolsets/#function-toolset++ Returns a tuple of the toolset and whether deferred tool requests are needed.+ """+ from pydantic_ai import CallDeferred, FunctionToolset++ toolset = FunctionToolset()+ deferred_tool_requests = False++ for tool in tools:+ if tool.source == "frontend":+ deferred_tool_requests = True++ async def tool_fn(+ _tool_name: str = tool.name, **kwargs: Any+ ) -> Any:+ raise CallDeferred(+ metadata={+ "source": "frontend",+ "tool_name": _tool_name,+ "kwargs": kwargs,+ }+ )+ else:++ async def tool_fn(+ _tool_name: str = tool.name, **kwargs: Any+ ) -> Any:+ result = await tool_invoker(_tool_name, kwargs)+ # Convert to JSON-serializable object+ return asdict(result)++ tool_fn.__name__ = tool.name+ toolset.add_function(+ tool_fn, name=tool.name, description=tool.description+ )+ return toolset, deferred_tool_requests+++def convert_to_pydantic_messages(+ messages: list[ServerUIMessage],+ part_processor: Callable[[UIMessagePart], UIMessagePart] | None = None,+) -> list[UIMessage]:+ """+ The frontend SDK tends to generate messages with a messageId eventhough it's not valid.+ Remove them to prevent validation errors.+ If a part processor is provided, it will be applied to the parts of the message.+ """+ from pydantic_ai.ui.vercel_ai.request_types import UIMessage++ def safe_part_processor(+ part: UIMessagePart,+ part_processor: Callable[[UIMessagePart], UIMessagePart],+ ) -> UIMessagePart:+ try:+ return part_processor(part)+ except Exception as e:+ LOGGER.error(f"Error processing part {part}: {e}")+ return part++ pydantic_messages: list[UIMessage] = []+ for message in messages:+ message_id = (+ message.get("messageId")+ or message.get("id")+ or generate_id("message")+ )+ role = message.get("role", "assistant")+ parts = message.get("parts", [])+ metadata = message.get("metadata")++ ui_message = UIMessage(+ id=message_id, role=role, parts=parts, metadata=metadata+ )++ # Process parts after casting so the processor will work on typed parts+ if ui_message.parts and part_processor:+ new_parts = [+ safe_part_processor(part, part_processor)+ for part in ui_message.parts+ ]+ ui_message.parts = new_parts+ pydantic_messages.append(ui_message)++ return pydantic_messages+++def create_simple_prompt(text: str) -> UIMessage:+ from pydantic_ai.ui.vercel_ai.request_types import TextUIPart, UIMessage++ parts: list[UIMessagePart] = [TextUIPart(text=text)] if text else []+ return UIMessage(id=generate_id("message"), role="user", parts=parts)diff --git a/marimo/_dependencies/dependencies.py b/marimo/_dependencies/dependencies.pyindex f01b9c1489..7a4de21937 100644--- a/marimo/_dependencies/dependencies.py+++ b/marimo/_dependencies/dependencies.py@@ -238,6 +238,7 @@ class DependencyManager:litellm = Dependency("litellm")redshift_connector = Dependency("redshift_connector")mcp = Dependency("mcp")+ pydantic_ai = Dependency("pydantic_ai")# Version requirements to properly support the new superfences introduced in# pymdown#2470diff --git a/marimo/_output/formatters/ai_formatters.py b/marimo/_output/formatters/ai_formatters.pyindex 75b490c3e4..47764e83ee 100644--- a/marimo/_output/formatters/ai_formatters.py+++ b/marimo/_output/formatters/ai_formatters.py@@ -28,6 +28,11 @@ class GoogleAiFormatter(FormatterFactory):)except (ImportError, ModuleNotFoundError):return+ except AttributeError:+ # google.genai or its dependencies may use collections.MutableMapping+ # which was removed in Python 3.10+ (moved to collections.abc)+ LOGGER.exception("Error importing google.genai")+ returnfrom marimo._output import formattingdiff --git a/marimo/_server/ai/providers.py b/marimo/_server/ai/providers.pyindex f7f2c39180..c9a3b003e3 100644--- a/marimo/_server/ai/providers.py+++ b/marimo/_server/ai/providers.py@@ -24,41 +24,31 @@ from starlette.exceptions import HTTPExceptionfrom marimo import _loggersfrom marimo._ai._convert import (convert_to_ai_sdk_messages,- convert_to_anthropic_messages,- convert_to_anthropic_tools,- convert_to_google_messages,- convert_to_google_tools,convert_to_openai_messages,convert_to_openai_tools,+ extract_text,+)+from marimo._ai._pydantic_ai_utils import (+ convert_to_pydantic_messages,+ form_toolsets,+ generate_id,)from marimo._ai._types import ChatMessage-from marimo._dependencies.dependencies import DependencyManager+from marimo._dependencies.dependencies import Dependency, DependencyManagerfrom marimo._server.ai.config import AnyProviderConfigfrom marimo._server.ai.ids import AiModelId+from marimo._server.ai.tools.tool_manager import get_tool_managerfrom marimo._server.ai.tools.types import ToolDefinitionfrom marimo._server.api.status import HTTPStatus+from marimo._server.models.completion import UIMessage as ServerUIMessageTIMEOUT = 30# Long-thinking models can take a long time to complete, so we set a longer timeoutLONG_THINKING_TIMEOUT = 120if TYPE_CHECKING:- from anthropic import ( # type: ignore[import-not-found]- AsyncClient,- AsyncStream as AnthropicStream,- )- from anthropic.types import ( # type: ignore[import-not-found]- RawMessageStreamEvent,- )- from google.genai.client import ( # type: ignore[import-not-found]- AsyncClient as GoogleClient,- )- from google.genai.types import ( # type: ignore[import-not-found]- GenerateContentConfig,- GenerateContentResponse,- )-# Used for Bedrock, unified interface for all models+ from anthropic.types.beta import BetaThinkingConfigParamfrom litellm import ( # type: ignore[attr-defined]CustomStreamWrapper as LitellmStream,)@@ -72,6 +62,17 @@ if TYPE_CHECKING:from openai.types.chat import ( # type: ignore[import-not-found]ChatCompletionChunk,)+ from pydantic_ai import Agent, DeferredToolRequests, FunctionToolset+ from pydantic_ai.messages import ThinkingPart+ from pydantic_ai.providers import Provider+ from pydantic_ai.providers.anthropic import (+ AnthropicProvider as PydanticAnthropic,+ )+ from pydantic_ai.providers.google import GoogleProvider as PydanticGoogle+ from pydantic_ai.ui.vercel_ai import VercelAIAdapter+ from pydantic_ai.ui.vercel_ai.request_types import UIMessage, UIMessagePart+ from pydantic_ai.ui.vercel_ai.response_types import BaseChunk+ from starlette.responses import StreamingResponseResponseT = TypeVar("ResponseT")@@ -114,6 +115,7 @@ LOGGER = _loggers.marimo_logger()class StreamOptions:text_only: bool = Falseformat_stream: bool = False+ accept: str | None = None@dataclass@@ -123,6 +125,195 @@ class ActiveToolCall:tool_call_args: str+ProviderT = TypeVar("ProviderT", bound="Provider[Any]")+++class PydanticProvider(ABC, Generic[ProviderT]):+ def __init__(+ self,+ model: str,+ config: AnyProviderConfig,+ deps: list[Dependency] | None = None,+ ):+ DependencyManager.require_many(+ "for AI assistance", DependencyManager.pydantic_ai, *(deps or [])+ )++ self.model = model+ self.config = config+ self.provider = self.create_provider(config)++ @abstractmethod+ def create_provider(self, config: AnyProviderConfig) -> ProviderT:+ """Create a provider for the given config."""++ @abstractmethod+ def create_agent(+ self, max_tokens: int, tools: list[ToolDefinition], system_prompt: str+ ) -> Agent[None, DeferredToolRequests | str]:+ """Create a Pydantic AI agent"""++ def get_vercel_adapter(self) -> type[VercelAIAdapter[Any, Any]]:+ """Return the Vercel AI adapter for the given provider."""+ from pydantic_ai.ui.vercel_ai import VercelAIAdapter++ return VercelAIAdapter++ def convert_messages(+ self, messages: list[ServerUIMessage]+ ) -> list[UIMessage]:+ """Convert server messages to Pydantic AI messages. We expect AI SDK messages"""+ return convert_to_pydantic_messages(messages)++ async def stream_completion(+ self,+ messages: list[ServerUIMessage],+ system_prompt: str,+ max_tokens: int,+ additional_tools: list[ToolDefinition],+ stream_options: Optional[StreamOptions] = None,+ ) -> StreamingResponse:+ """Return a streaming response from the given messages. The response are AI SDK events."""+ from pydantic_ai.ui.vercel_ai.request_types import SubmitMessage++ tools = (self.config.tools or []) + additional_tools+ agent = self.create_agent(+ max_tokens=max_tokens, tools=tools, system_prompt=system_prompt+ )++ run_input = SubmitMessage(+ id=generate_id("submit-message"),+ trigger="submit-message",+ messages=self.convert_messages(messages),+ )++ # TODO: Text only and format stream are not supported yet+ stream_options = stream_options or StreamOptions()++ vercel_adapter = self.get_vercel_adapter()+ adapter = vercel_adapter(+ agent=agent, run_input=run_input, accept=stream_options.accept+ )+ event_stream = adapter.run_stream()+ return adapter.streaming_response(event_stream)++ async def stream_text(+ self,+ user_prompt: str,+ messages: list[ServerUIMessage],+ system_prompt: str,+ max_tokens: int,+ additional_tools: list[ToolDefinition],+ ) -> AsyncGenerator[str]:+ """Return a stream of text from the given messages."""++ tools = (self.config.tools or []) + additional_tools+ agent = self.create_agent(+ max_tokens=max_tokens, tools=tools, system_prompt=system_prompt+ )+ vercel_adapter = self.get_vercel_adapter()++ async with agent.run_stream(+ user_prompt=user_prompt,+ message_history=vercel_adapter.load_messages(+ self.convert_messages(messages)+ ),+ instructions=system_prompt,+ ) as result:+ async for message in result.stream_text(delta=True):+ yield message++ async def completion(+ self,+ messages: list[UIMessage],+ system_prompt: str,+ max_tokens: int,+ additional_tools: list[ToolDefinition],+ ) -> str:+ """Return a string response from the given messages."""++ from pydantic_ai.ui.vercel_ai import VercelAIAdapter++ tools = (self.config.tools or []) + additional_tools+ agent = self.create_agent(+ max_tokens=max_tokens, tools=tools, system_prompt=system_prompt+ )+ result = await agent.run(+ user_prompt=None,+ message_history=VercelAIAdapter.load_messages(messages),+ instructions=system_prompt,+ )++ return str(result.output)++ def _get_toolsets_and_output_type(+ self, tools: list[ToolDefinition]+ ) -> tuple[FunctionToolset, list[Any] | type[str]]:+ from pydantic_ai import DeferredToolRequests++ tool_manager = get_tool_manager()+ toolset, deferred_tool_requests = form_toolsets(+ tools, tool_manager.invoke_tool+ )+ output_type = (+ [str, DeferredToolRequests] if deferred_tool_requests else str+ )+ return toolset, output_type+++class GoogleProvider(PydanticProvider["PydanticGoogle"]):+ def create_provider(self, config: AnyProviderConfig) -> PydanticGoogle:+ from pydantic_ai.providers.google import (+ GoogleProvider as PydanticGoogle,+ )++ if config.api_key:+ return PydanticGoogle(api_key=config.api_key)++ # Try to use environment variables and ADC+ # This supports Google Vertex AI usage without explicit API keys+ use_vertex = (+ os.getenv("GOOGLE_GENAI_USE_VERTEXAI", "").lower() == "true"+ )+ if use_vertex:+ project = os.getenv("GOOGLE_CLOUD_PROJECT")+ location = os.getenv("GOOGLE_CLOUD_LOCATION", "us-central1")+ # The type stubs don't have an overload that combines vertexai+ # with project/location, but the runtime supports it+ provider: PydanticGoogle = PydanticGoogle( # type: ignore[call-overload]+ vertexai=True,+ project=project,+ location=location,+ )+ else:+ # Try default initialization which may work with environment variables+ provider = PydanticGoogle()+ return provider++ def create_agent(+ self, max_tokens: int, tools: list[ToolDefinition], system_prompt: str+ ) -> Agent[None, DeferredToolRequests | str]:+ from pydantic_ai import Agent+ from pydantic_ai.models.google import GoogleModel, GoogleModelSettings++ toolset, output_type = self._get_toolsets_and_output_type(tools)++ return Agent(+ GoogleModel(+ model_name=self.model,+ provider=self.provider,+ settings=GoogleModelSettings(+ max_tokens=max_tokens,+ # Works on non-thinking models too+ google_thinking_config={"include_thoughts": True},+ ),+ ),+ toolsets=[toolset] if tools else None,+ instructions=system_prompt,+ output_type=output_type,+ )++class CompletionProvider(Generic[ResponseT, StreamT], ABC):"""Base class for AI completion providers."""@@ -359,15 +550,8 @@ class CompletionProvider(Generic[ResponseT, StreamT], ABC):if not tool_call:continue- if isinstance(self, GoogleProvider):- # For GoogleProvider, each chunk contains the full (possibly updated) args dict as a JSON string.- # Example: first chunk: {"location": "San Francisco"}- # second chunk: {"location": "San Francisco", "zip": "94107"}- # We overwrite tool_call_args with the latest chunk.- tool_call.tool_call_args = tool_call_delta- else:- # For other providers, tool_call_args is built up incrementally from deltas.- tool_call.tool_call_args += tool_call_delta+ # tool_call_args is built up incrementally from deltas.+ tool_call.tool_call_args += tool_call_delta# update tool_call_delta to ai-sdk-ui structure# based on https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol#tool-call-delta-partcontent_data = {@@ -743,11 +927,7 @@ class AzureOpenAIProvider(OpenAIProvider):)-class AnthropicProvider(- CompletionProvider[- "RawMessageStreamEvent", "AnthropicStream[RawMessageStreamEvent]"- ]-):+class AnthropicProvider(PydanticProvider["PydanticAnthropic"]):# Temperature of 0.2 was recommended for coding and data science in these links:# https://community.openai.com/t/cheat-sheet-mastering-temperature-and-top-p-in-chatgpt-api/172683# https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/reduce-latency?utm_source=chatgpt.com@@ -760,338 +940,152 @@ class AnthropicProvider(EXTENDED_THINKING_MODEL_PREFIXES = ["claude-opus-4","claude-sonnet-4",+ "claude-haiku-4-5","claude-3-7-sonnet",]# 1024 tokens is the minimum budget for extended thinkingDEFAULT_EXTENDED_THINKING_BUDGET_TOKENS = 1024- # Map of block index to tool call id for tool call delta chunks- block_index_to_tool_call_id_map: dict[int, str] = {}-- def is_extended_thinking_model(self, model: str) -> bool:- return any(- model.startswith(prefix)- for prefix in self.EXTENDED_THINKING_MODEL_PREFIXES+ def create_provider(self, config: AnyProviderConfig) -> PydanticAnthropic:+ from pydantic_ai.providers.anthropic import (+ AnthropicProvider as PydanticAnthropic,)- def get_temperature(self) -> float:- return (- self.DEFAULT_EXTENDED_THINKING_TEMPERATURE- if self.is_extended_thinking_model(self.model)- else self.DEFAULT_TEMPERATURE- )+ return PydanticAnthropic(api_key=config.api_key)- def get_client(self, config: AnyProviderConfig) -> AsyncClient:- DependencyManager.anthropic.require(- why="for AI assistance with Anthropic"+ def create_agent(+ self, max_tokens: int, tools: list[ToolDefinition], system_prompt: str+ ) -> Agent[None, DeferredToolRequests | str]:+ from pydantic_ai import Agent+ from pydantic_ai.models.anthropic import (+ AnthropicModel,+ AnthropicModelSettings,)- from anthropic import AsyncClient-- return AsyncClient(api_key=config.api_key)-- def maybe_get_tool_call_id(self, block_index: int) -> Optional[str]:- return self.block_index_to_tool_call_id_map.get(block_index, None)- async def stream_completion(- self,- messages: list[ChatMessage],- system_prompt: str,- max_tokens: int,- additional_tools: list[ToolDefinition],- ) -> AnthropicStream[RawMessageStreamEvent]:- client = self.get_client(self.config)- tools = self.config.tools- create_params = {- "model": self.model,- "max_tokens": max_tokens,- "messages": cast(- Any,- convert_to_anthropic_messages(messages),- ),- "system": system_prompt,- "stream": True,- "temperature": self.get_temperature(),- }- if tools:- all_tools = tools + additional_tools- create_params["tools"] = convert_to_anthropic_tools(all_tools)- if self.is_extended_thinking_model(self.model):- create_params["thinking"] = {+ toolset, output_type = self._get_toolsets_and_output_type(tools)+ is_thinking_model = self.is_extended_thinking_model(self.model)+ thinking_config: BetaThinkingConfigParam = {"type": "disabled"}+ if is_thinking_model:+ thinking_config = {"type": "enabled","budget_tokens": self.DEFAULT_EXTENDED_THINKING_BUDGET_TOKENS,}- return cast(- "AnthropicStream[RawMessageStreamEvent]",- await client.messages.create(**create_params),- )- def block_index_to_tool_call_id(self, block_index: int) -> str:- return f"tool_call_{block_index}"-- def extract_content(- self,- response: RawMessageStreamEvent,- tool_call_ids: Optional[list[str]] = None,- ) -> Optional[ExtractedContentList]:- del tool_call_ids- from anthropic.types import (- InputJSONDelta,- RawContentBlockDeltaEvent,- RawContentBlockStartEvent,- SignatureDelta,- TextDelta,- ThinkingDelta,- ToolUseBlock,+ return Agent(+ AnthropicModel(+ model_name=self.model,+ provider=self.provider,+ settings=AnthropicModelSettings(+ max_tokens=max_tokens,+ temperature=self.get_temperature(),+ anthropic_thinking=thinking_config,+ ),+ ),+ toolsets=[toolset] if tools else None,+ instructions=system_prompt,+ output_type=output_type,)- # For streaming content- if isinstance(response, RawContentBlockDeltaEvent):- if isinstance(response.delta, TextDelta):- return [(response.delta.text, "text")]- if isinstance(response.delta, ThinkingDelta):- return [(response.delta.thinking, "reasoning")]- if isinstance(response.delta, InputJSONDelta):- block_index = response.index- tool_call_id = self.maybe_get_tool_call_id(block_index)- if not tool_call_id:- LOGGER.error(- f"Tool call id not found for block index: {response.index}"- )- return None- delta_json = response.delta.partial_json- tool_delta = {- "toolCallId": tool_call_id,- "inputTextDelta": delta_json,- }- return [(tool_delta, "tool_call_delta")]- if isinstance(response.delta, SignatureDelta):- return [- (- {"signature": response.delta.signature},- "reasoning_signature",- )- ]-- # For the beginning of a tool use block- if isinstance(response, RawContentBlockStartEvent):- if isinstance(response.content_block, ToolUseBlock):- tool_call_id = response.content_block.id- tool_call_name = response.content_block.name- block_index = response.index- # Store the tool call id for the block index- self.block_index_to_tool_call_id_map[block_index] = (- tool_call_id- )- tool_info = {- "toolCallId": tool_call_id,- "toolName": tool_call_name,- }- return [(tool_info, "tool_call_start")]-- return None-- def get_finish_reason(- self, response: RawMessageStreamEvent- ) -> Optional[FinishReason]:- from anthropic.types import RawMessageDeltaEvent-- # Check for message_delta events which contain the stop_reason- if isinstance(response, RawMessageDeltaEvent):- if (- hasattr(response, "delta")- and hasattr(response.delta, "stop_reason")- and response.delta.stop_reason- ):- stop_reason = response.delta.stop_reason- # Anthropic uses "end_turn" for normal completion, "tool_use" for tool calls- return "tool_calls" if stop_reason == "tool_use" else "stop"-- return None---class GoogleProvider(- CompletionProvider[- "GenerateContentResponse", "AsyncIterator[GenerateContentResponse]"- ]-):- # Based on the docs:- # https://cloud.google.com/vertex-ai/generative-ai/docs/thinking- THINKING_MODEL_PREFIXES = [- "gemini-2.5-pro",- "gemini-2.5-flash",- ]-- # Keep a persistent async client to avoid closing during stream iteration- _client: Optional[GoogleClient] = None-- def is_thinking_model(self, model: str) -> bool:+ def is_extended_thinking_model(self, model: str) -> bool:return any(- model.startswith(prefix) for prefix in self.THINKING_MODEL_PREFIXES+ model.startswith(prefix)+ for prefix in self.EXTENDED_THINKING_MODEL_PREFIXES)- def get_config(- self,- system_prompt: str,- max_tokens: int,- additional_tools: list[ToolDefinition],- ) -> GenerateContentConfig:- tools = self.config.tools- config = {- "system_instruction": system_prompt,- "temperature": 0,- "max_output_tokens": max_tokens,- }- if tools:- all_tools = tools + additional_tools- config["tools"] = convert_to_google_tools(all_tools)- if self.is_thinking_model(self.model):- config["thinking_config"] = {- "include_thoughts": True,- }- return cast("GenerateContentConfig", config)-- def get_client(self, config: AnyProviderConfig) -> GoogleClient:- try:- from google import genai- except ImportError:- DependencyManager.google_ai.require(- why="for AI assistance with Google AI"- )- from google import genai # type: ignore-- # Reuse a stored async client if already created- if self._client is not None:- return self._client-- # If no API key is provided, try to use environment variables and ADC- # This supports Google Vertex AI usage without explicit API keys- if not config.api_key:- # Check if GOOGLE_GENAI_USE_VERTEXAI is set to enable Vertex AI mode- use_vertex = (- os.getenv("GOOGLE_GENAI_USE_VERTEXAI", "").lower() == "true"- )- if use_vertex:- project = os.getenv("GOOGLE_CLOUD_PROJECT")- location = os.getenv("GOOGLE_CLOUD_LOCATION", "us-central1")- self._client = genai.Client(- vertexai=True, project=project, location=location- ).aio- else:- # Try default initialization which may work with environment variables- self._client = genai.Client().aio-- # Return vertex or default client- return self._client+ def get_temperature(self) -> float:+ return (+ self.DEFAULT_EXTENDED_THINKING_TEMPERATURE+ if self.is_extended_thinking_model(self.model)+ else self.DEFAULT_TEMPERATURE+ )- self._client = genai.Client(api_key=config.api_key).aio- return self._client+ def convert_messages(+ self, messages: list[ServerUIMessage]+ ) -> list[UIMessage]:+ return convert_to_pydantic_messages(messages, self.process_part)- async def stream_completion(- self,- messages: list[ChatMessage],- system_prompt: str,- max_tokens: int,- additional_tools: list[ToolDefinition],- ) -> AsyncIterator[GenerateContentResponse]:- client = self.get_client(self.config)- return await client.models.generate_content_stream( # type: ignore[reportReturnType]- model=self.model,- contents=convert_to_google_messages(messages),- config=self.get_config(- system_prompt=system_prompt,- max_tokens=max_tokens,- additional_tools=additional_tools,- ),+ def process_part(self, part: UIMessagePart) -> UIMessagePart:+ """+ Anthropic does not support binary content for text files, so we convert to text parts.+ Ideally, we would use DocumentUrl parts with a url, but we only have the binary data from the frontend+ Refer to: https://ai.pydantic.dev/input/#user-side-download-vs-direct-file-url+ """+ from pydantic_ai.ui.vercel_ai.request_types import (+ FileUIPart,+ TextUIPart,)- def _get_tool_call_id(self, tool_call_id: Optional[str]) -> str:- # Custom tools don't have an id, so we have to generate a random uuid- # https://ai.google.dev/gemini-api/docs/function-calling?example=meeting- if not tool_call_id:- # generate a random uuid- return str(uuid.uuid4())- return tool_call_id+ if isinstance(part, FileUIPart) and part.media_type.startswith("text"):+ return TextUIPart(+ type="text",+ text=extract_text(part.url),+ provider_metadata=part.provider_metadata,+ )+ return part- def extract_content(+ def get_vercel_adapter(self,- response: GenerateContentResponse,- tool_call_ids: Optional[list[str]] = None,- ) -> Optional[ExtractedContentList]:- tool_call_ids = tool_call_ids or []- if not response.candidates:- return None+ ) -> type[VercelAIAdapter[None, DeferredToolRequests | str]]:+ """+ Return a custom adapter that includes thinking signatures in ReasoningEndChunk.- candidate = response.candidates[0]- if not candidate or not candidate.content:- return None+ pydantic_ai's VercelAIEventStream.handle_thinking_end doesn't pass the signature+ from ThinkingPart to ReasoningEndChunk, which breaks Anthropic's extended thinking+ on follow-up messages (Anthropic requires signatures on thinking blocks).- if not candidate.content.parts:- return None+ TODO: Remove this once https://github.com/pydantic/pydantic-ai/pull/3754 is released+ """+ from pydantic_ai import DeferredToolRequests+ from pydantic_ai.ui.vercel_ai import VercelAIAdapter+ from pydantic_ai.ui.vercel_ai._event_stream import VercelAIEventStream+ from pydantic_ai.ui.vercel_ai.response_types import ReasoningEndChunk- # Build events by first scanning parts and rectifying tool calls by position- content: ExtractedContentList = []- function_call_index = -1- seen_in_frame: set[int] = set()-- for part in candidate.content.parts:- # Handle function calls (may appear multiple times per chunk)- if part.function_call:- function_call_index += 1- # Resolve a stable id by position if provided from the caller; else synthesize- stable_id = (- tool_call_ids[function_call_index]- if function_call_index < len(tool_call_ids)- and tool_call_ids[function_call_index]- else self._get_tool_call_id(part.function_call.id)- )+ AnthropicOutputType = DeferredToolRequests | str- # First sight of this call index in this frame => emit start- if function_call_index not in seen_in_frame:- tool_info = {- "toolCallId": stable_id,- "toolName": part.function_call.name,- "args": json.dumps(part.function_call.args),- }- content.append((tool_info, "tool_call_start"))- seen_in_frame.add(function_call_index)- else:- # Subsequent occurrences for the same index => treat as delta (snapshot semantics)- if part.function_call.args is not None:- tool_delta = {- "toolCallId": stable_id,- "inputTextDelta": json.dumps(- part.function_call.args- ),+ # Custom event stream that includes signature in ReasoningEndChunk+ class AnthropicVercelAIEventStream(+ VercelAIEventStream[None, AnthropicOutputType]+ ):+ async def handle_thinking_end(+ self, part: ThinkingPart, followed_by_thinking: bool = False+ ) -> AsyncIterator[BaseChunk]:+ """Override to include signature in provider_metadata."""+ try:+ provider_metadata = None+ if part.signature:+ pydantic_ai_meta: dict[str, Any] = {+ "signature": part.signature}- content.append((tool_delta, "tool_call_delta"))- continue-- # Text/Reasoning handling- if part.text:- if part.thought:- content.append((part.text, "reasoning"))- else:- content.append((part.text, "text"))- continue+ if part.provider_name:+ pydantic_ai_meta["provider_name"] = (+ part.provider_name+ )+ if part.id:+ pydantic_ai_meta["id"] = part.id+ provider_metadata = {"pydantic_ai": pydantic_ai_meta}- # Ignore other non-text parts (e.g., images) at this layer- continue+ yield ReasoningEndChunk(+ id=self.message_id, provider_metadata=provider_metadata+ )+ except Exception as e:+ LOGGER.warning(+ f"Error in AnthropicVercelAIEventStream.handle_thinking_end: {e}"+ )+ async for chunk in super().handle_thinking_end(+ part, followed_by_thinking+ ):+ yield chunk- return content+ # Custom adapter that uses the custom event stream+ class AnthropicVercelAIAdapter(+ VercelAIAdapter[None, AnthropicOutputType]+ ):+ def build_event_stream(self) -> AnthropicVercelAIEventStream:+ return AnthropicVercelAIEventStream(+ self.run_input, accept=self.accept+ )- def get_finish_reason(- self, response: GenerateContentResponse- ) -> Optional[FinishReason]:- if not response.candidates:- return None- first_candidate = response.candidates[0]- if first_candidate.content and first_candidate.content.parts:- for part in first_candidate.content.parts:- if part.function_call:- return "tool_calls"- if response.candidates and response.candidates[0].finish_reason:- return "stop"- return None+ return AnthropicVercelAIAdapterclass BedrockProvider(@@ -1226,13 +1220,17 @@ class BedrockProvider(def get_completion_provider(config: AnyProviderConfig, model: str-) -> CompletionProvider[Any, Any]:+) -> CompletionProvider[Any, Any] | PydanticProvider[Any]:model_id = AiModelId.from_model(model)if model_id.provider == "anthropic":- return AnthropicProvider(model_id.model, config)+ return AnthropicProvider(+ model_id.model, config, [DependencyManager.anthropic]+ )elif model_id.provider == "google":- return GoogleProvider(model_id.model, config)+ return GoogleProvider(+ model_id.model, config, [DependencyManager.google_ai]+ )elif model_id.provider == "bedrock":return BedrockProvider(model_id.model, config)elif model_id.provider == "azure":diff --git a/marimo/_server/api/endpoints/ai.py b/marimo/_server/api/endpoints/ai.pyindex c11a490236..0bd0db57ff 100644--- a/marimo/_server/api/endpoints/ai.py+++ b/marimo/_server/api/endpoints/ai.py@@ -13,6 +13,7 @@ from starlette.responses import (from marimo import _loggersfrom marimo._ai._convert import convert_to_ai_sdk_messages+from marimo._ai._pydantic_ai_utils import create_simple_promptfrom marimo._ai._types import ChatMessagefrom marimo._config.config import AiConfig, MarimoConfigfrom marimo._server.ai.config import (@@ -32,6 +33,7 @@ from marimo._server.ai.prompts import (get_refactor_or_insert_notebook_cell_system_prompt,)from marimo._server.ai.providers import (+ PydanticProvider,StreamOptions,get_completion_provider,without_wrapping_backticks,@@ -60,6 +62,9 @@ if TYPE_CHECKING:from starlette.requests import Requestfrom starlette.responses import ContentStream+# Taken from pydantic_ai.ui import SSE_CONTENT_TYPE+SSE_CONTENT_TYPE = "text/event-stream"+LOGGER = _loggers.marimo_logger()@@ -137,12 +142,13 @@ async def ai_completion(ai_config = get_ai_config(config)custom_rules = ai_config.get("rules", None)- use_messages = len(body.messages) >= 1+ use_messages = len(body.messages) >= 1 # Deprecated+ use_ui_messages = len(body.ui_messages) >= 1system_prompt = get_refactor_or_insert_notebook_cell_system_prompt(language=body.language,is_insert=False,- support_multiple_cells=use_messages,+ support_multiple_cells=use_messages or use_ui_messages,custom_rules=custom_rules,cell_code=body.code,selected_text=body.selected_text,@@ -157,6 +163,31 @@ async def ai_completion(model=model,)+ if isinstance(provider, PydanticProvider):+ # Currently, only useChat (use_messages=True) supports UI messages+ # So, we can stream back the UI messages here. Else, we stream back the text.+ if use_ui_messages:+ return await provider.stream_completion(+ messages=body.ui_messages,+ system_prompt=system_prompt,+ max_tokens=get_max_tokens(config),+ additional_tools=[],+ )+ response = provider.stream_text(+ user_prompt=prompt,+ messages=body.ui_messages,+ system_prompt=system_prompt,+ max_tokens=get_max_tokens(config),+ additional_tools=[],+ )+ safe_content = safe_stream_wrapper(response, text_only=False)+ content_without_wrapping = without_wrapping_backticks(safe_content)+ return StreamingResponse(+ content=content_without_wrapping,+ media_type="application/json",+ headers={"x-vercel-ai-data-stream": "v1"},+ )+messages = (body.messagesif use_messages@@ -214,6 +245,7 @@ async def ai_chat(app_state = AppState(request)app_state.require_current_session()session_id = app_state.require_current_session_id()+ accept = request.headers.get("accept", SSE_CONTENT_TYPE)config = app_state.app_config_manager.get_config(hide_secrets=False)body = await parse_request(request, cls=ChatRequest, allow_unknown_keys=True@@ -239,6 +271,20 @@ async def ai_chat(model=model,)additional_tools = body.tools or []++ stream_options = StreamOptions(+ format_stream=True, text_only=False, accept=accept+ )++ if isinstance(provider, PydanticProvider):+ return await provider.stream_completion(+ messages=body.ui_messages,+ system_prompt=system_prompt,+ max_tokens=max_tokens,+ additional_tools=additional_tools,+ stream_options=stream_options,+ )+response = await provider.stream_completion(messages=messages,system_prompt=system_prompt,@@ -305,14 +351,21 @@ async def ai_inline_completion(provider = get_completion_provider(provider_config, model=model)try:- response = await provider.stream_completion(- messages=messages,- system_prompt=system_prompt,- max_tokens=INLINE_COMPLETION_MAX_TOKENS,- additional_tools=[],- )-- content = await provider.collect_stream(response)+ if isinstance(provider, PydanticProvider):+ content = await provider.completion(+ messages=[create_simple_prompt(prompt)],+ system_prompt=system_prompt,+ max_tokens=INLINE_COMPLETION_MAX_TOKENS,+ additional_tools=[],+ )+ else:+ response = await provider.stream_completion(+ messages=messages,+ system_prompt=system_prompt,+ max_tokens=INLINE_COMPLETION_MAX_TOKENS,+ additional_tools=[],+ )+ content = await provider.collect_stream(response)except Exception as e:LOGGER.error("Error in AI inline completion: %s", str(e))raise HTTPException(diff --git a/marimo/_server/models/completion.py b/marimo/_server/models/completion.pyindex cf53ce3705..3bb2a84ef3 100644--- a/marimo/_server/models/completion.py+++ b/marimo/_server/models/completion.py@@ -36,12 +36,20 @@ class AiCompletionContext(msgspec.Struct, rename="camel"):Language = Literal["python", "markdown", "sql"]+UIMessage = dict[str, Any]+class AiCompletionRequest(msgspec.Struct, rename="camel"):+ """+ UIMessages are expected to be AI SDK messages.+ See pydantic_ai.ui.vercel_ai.request_types.UIMessage or Vercel AI SDK documentation.+ """+prompt: strinclude_other_code: strcode: str- messages: list[ChatMessage] = []+ messages: list[ChatMessage] = [] # Deprecated+ ui_messages: list[UIMessage] = []selected_text: Optional[str] = Nonecontext: Optional[AiCompletionContext] = Nonelanguage: Language = "python"@@ -54,9 +62,15 @@ class AiInlineCompletionRequest(msgspec.Struct, rename="camel"):class ChatRequest(msgspec.Struct, rename="camel"):+ """+ UIMessages are expected to be AI SDK messages.+ See pydantic_ai.ui.vercel_ai.request_types.UIMessage or Vercel AI SDK documentation.+ """+context: AiCompletionContextinclude_other_code: str- messages: list[ChatMessage]+ messages: list[ChatMessage] # Deprecated+ ui_messages: list[UIMessage]tools: Optional[list[ToolDefinition]] = Nonemodel: Optional[str] = Nonevariables: Optional[list[Union[VariableContext, str]]] = Nonediff --git a/packages/openapi/api.yaml b/packages/openapi/api.yamlindex 6f70da5f87..7182e2c928 100644--- a/packages/openapi/api.yaml+++ b/packages/openapi/api.yaml@@ -56,6 +56,9 @@ components:title: AiCompletionContexttype: objectAiCompletionRequest:+ description: 'UIMessages are expected to be AI SDK messages.++ See pydantic_ai.ui.vercel_ai.request_types.UIMessage or Vercel AI SDK documentation.'properties:code:type: string@@ -84,6 +87,11 @@ components:- type: string- type: 'null'default: null+ uiMessages:+ default: []+ items:+ type: object+ type: arrayrequired:- prompt- includeOtherCode@@ -522,6 +530,9 @@ components:title: ChatMessagetype: objectChatRequest:+ description: 'UIMessages are expected to be AI SDK messages.++ See pydantic_ai.ui.vercel_ai.request_types.UIMessage or Vercel AI SDK documentation.'properties:context:$ref: '#/components/schemas/AiCompletionContext'@@ -543,6 +554,10 @@ components:type: array- type: 'null'default: null+ uiMessages:+ items:+ type: object+ type: arrayvariables:anyOf:- items:@@ -556,6 +571,7 @@ components:- context- includeOtherCode- messages+ - uiMessagestitle: ChatRequesttype: objectClearCacheCommand:diff --git a/packages/openapi/src/api.ts b/packages/openapi/src/api.tsindex 2eefb8e110..f8f30188ca 100644--- a/packages/openapi/src/api.ts+++ b/packages/openapi/src/api.ts@@ -2802,7 +2802,11 @@ export interface components {/** @default [] */variables?: (string | components["schemas"]["VariableContext"])[];};- /** AiCompletionRequest */+ /**+ * AiCompletionRequest+ * @description UIMessages are expected to be AI SDK messages.+ * See pydantic_ai.ui.vercel_ai.request_types.UIMessage or Vercel AI SDK documentation.+ */AiCompletionRequest: {code: string;/** @default null */@@ -2818,6 +2822,8 @@ export interface components {prompt: string;/** @default null */selectedText?: string | null;+ /** @default [] */+ uiMessages?: Record<string, any>[];};/*** AiConfig@@ -3106,7 +3112,11 @@ export interface components {/** @enum {unknown} */role: "assistant" | "system" | "user";};- /** ChatRequest */+ /**+ * ChatRequest+ * @description UIMessages are expected to be AI SDK messages.+ * See pydantic_ai.ui.vercel_ai.request_types.UIMessage or Vercel AI SDK documentation.+ */ChatRequest: {context: components["schemas"]["AiCompletionContext"];includeOtherCode: string;@@ -3115,6 +3125,7 @@ export interface components {model?: string | null;/** @default null */tools?: components["schemas"]["ToolDefinition"][] | null;+ uiMessages: Record<string, any>[];/** @default null */variables?: (string | components["schemas"]["VariableContext"])[] | null;};diff --git a/pixi.lock b/pixi.lockindex ba625af33e..8c558f7325 100644--- a/pixi.lock+++ b/pixi.lock@@ -26,7 +26,7 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/editables-0.5-pyhd8ed1ab_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.20.0-pyhd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.20.1-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/hatch-1.16.2-pyhcf101f3_0.conda@@ -42,11 +42,11 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-8.7.0-pyhe01879c_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/importlib_resources-6.5.2-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.classes-3.4.0-pyhd8ed1ab_2.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.context-6.0.1-pyhd8ed1ab_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.functools-4.3.0-pyhd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.context-6.0.2-pyhcf101f3_1.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.functools-4.4.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/jeepney-0.9.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/keyring-25.7.0-pyha804496_0.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_104.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_105.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libexpat-2.7.3-hecca717_0.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libffi-3.5.2-h9ec8514_0.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libgcc-15.2.0-he0feb66_16.conda@@ -56,10 +56,10 @@ environments:- conda: https://conda.anaconda.org/conda-forge/linux-64/libiconv-1.18-h3b78370_2.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/liblzma-5.8.1-hb9d3cd8_2.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libnsl-2.0.1-hb9d3cd8_1.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_0.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_1.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_16.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-15.2.0-hdf11a46_16.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.41.2-h5347b49_1.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.41.3-h5347b49_0.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libuv-1.51.0-hb03c661_1.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libxcrypt-4.4.36-hd590300_1.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/libzlib-1.3.1-hb9d3cd8_2.conda@@ -68,8 +68,8 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/more-itertools-10.8.0-pyhcf101f3_1.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.5-h2d0b736_3.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.9.1-pyhd8ed1ab_1.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/nodejs-22.19.0-h4a9c4b4_1.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/nodejs-22.21.1-h4a9c4b4_0.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/openssl-3.6.0-h26f9b46_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/packaging-25.0-pyh29332c3_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pathspec-0.12.1-pyhd8ed1ab_1.conda@@ -78,9 +78,9 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.3-pyh8b19718_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/platformdirs-4.5.1-pyhcf101f3_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/pnpm-10.25.0-h52a9d3b_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/pre-commit-4.5.0-pyha770c72_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/pre_commit-4.5.0-hd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/pnpm-10.26.2-h52a9d3b_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/pre-commit-4.5.1-pyha770c72_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/pre_commit-4.5.1-hd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda@@ -88,7 +88,7 @@ environments:- conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.12.12-hd63d673_1_cpython.conda- conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.12-8_cp312.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/pyyaml-6.0.3-py312h8a5da7c_0.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.2-h8c095d6_2.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.3-h853b02a_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/rich-14.2.0-pyhcf101f3_0.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/secretstorage-3.4.1-py312h7900ff3_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda@@ -100,28 +100,27 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/tomlkit-0.13.3-pyha770c72_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/trove-classifiers-2025.12.1.14-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/ukkonen-1.0.1-py312hd9148b4_6.conda- conda: https://conda.anaconda.org/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/linux-64/uv-0.6.17-h3b53078_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/virtualenv-20.35.4-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/wheel-0.45.1-pyhd8ed1ab_1.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/yaml-0.2.5-h7f98852_2.tar.bz2- - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.22.0-pyhd8ed1ab_0.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/zlib-1.3.1-hb9d3cd8_2.conda- - conda: https://conda.anaconda.org/conda-forge/linux-64/zstandard-0.23.0-py312h66e93f0_2.conda- - pypi: https://files.pythonhosted.org/packages/11/a8/c6a4b901d17399c77cd81fb001ce8961e9f5e04d3daf27e8925cb012e163/docutils-0.22.3-py3-none-any.whl+ - conda: https://conda.anaconda.org/conda-forge/linux-64/yaml-0.2.5-h280c20c_3.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.23.0-pyhcf101f3_1.conda+ - conda: https://conda.anaconda.org/conda-forge/linux-64/zstd-1.5.7-hb78ec9c_6.conda+ - pypi: https://files.pythonhosted.org/packages/02/10/5da547df7a391dcde17f59520a231527b8571e6f46fc8efb02ccb370ab12/docutils-0.22.4-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/b2/70/00dc4246d9f3c69ecbb9bc36d5ad1a359884464a44711c665cb0afb1e9de/loro-1.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl- pypi: https://files.pythonhosted.org/packages/70/81/54e3ce63502cd085a0c556652a4e1b919c45a446bd1e5300e10c44c8c521/markdown-3.10-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/5c/a2/488517a43ccf5a4b6b6eca6dd4ede0bd82b043d1539dd6bb908a19f8efd3/msgspec-0.20.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl- - pypi: https://files.pythonhosted.org/packages/87/0d/1861d1599571974b15b025e12b142d8e6b42ad66c8a07a89cb0fc21f1e03/narwhals-2.13.0-py3-none-any.whl+ - pypi: https://files.pythonhosted.org/packages/79/3e/b8ecc67e178919671695f64374a7ba916cf0adbf86efedc6054f38b5b8ae/narwhals-2.14.0-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/16/32/f8e3c85d1d5250232a5d3477a2a28cc291968ff175caeadaf3cc19ce0e4a/parso-0.8.5-py2.py3-none-any.whl- - pypi: https://files.pythonhosted.org/packages/ce/b1/5f49af514f76431ba4eea935b8ad3725cdeb397e9245ab919dbc1d1dc20f/psutil-7.1.3-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl+ - pypi: https://files.pythonhosted.org/packages/29/f8/40e01c350ad9a2b3cb4e6adbcc8a83b17ee50dd5792102b6142385937db5/psutil-7.2.1-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl- pypi: https://files.pythonhosted.org/packages/fb/35/b763e8fbcd51968329b9adc52d188fc97859f85f2ee15fe9f379987d99c5/pymdown_extensions-10.19.1-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl- - pypi: https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl+ - pypi: https://files.pythonhosted.org/packages/3d/d8/2083a1daa7439a66f3a48589a57d576aa117726762618f6bb09fe3798796/uvicorn-0.40.0-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/14/8f/aa61f528fba38578ec553c145857a181384c72b98156f858ca5c8e82d9d3/websockets-15.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl- pypi: ./osx-arm64:@@ -138,7 +137,7 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/distlib-0.4.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/editables-0.5-pyhd8ed1ab_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.3.1-pyhd8ed1ab_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.20.0-pyhd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.20.1-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/h2-4.3.0-pyhcf101f3_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/hatch-1.16.2-pyhcf101f3_0.conda@@ -154,14 +153,14 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/importlib-metadata-8.7.0-pyhe01879c_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/importlib_resources-6.5.2-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.classes-3.4.0-pyhd8ed1ab_2.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.context-6.0.1-pyhd8ed1ab_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.functools-4.3.0-pyhd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.context-6.0.2-pyhcf101f3_1.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.functools-4.4.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/keyring-25.7.0-pyh534df25_0.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-21.1.7-hf598326_0.conda+ - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-21.1.8-hf598326_0.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libexpat-2.7.3-haf25636_0.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libffi-3.5.2-he5f378a_0.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/liblzma-5.8.1-h39f12f2_2.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsqlite-3.51.1-h9a5124b_0.conda+ - conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsqlite-3.51.1-h1b79a29_1.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libuv-1.51.0-h6caf38d_1.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.3.1-h8359307_2.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/make-4.4.1-hc9fafa5_2.conda@@ -169,7 +168,7 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/mdurl-0.1.2-pyhd8ed1ab_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/more-itertools-10.8.0-pyhcf101f3_1.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ncurses-6.5-h5e97a16_3.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.9.1-pyhd8ed1ab_1.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/nodejs-22.21.1-hf2fe37f_0.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/openssl-3.6.0-h5503f6c_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/packaging-25.0-pyh29332c3_1.conda@@ -178,9 +177,9 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/pip-25.3-pyh8b19718_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/platformdirs-4.5.1-pyhcf101f3_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pluggy-1.6.0-pyhf9edf01_1.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/pnpm-10.25.0-hbbe5caa_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/pre-commit-4.5.0-pyha770c72_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/pre_commit-4.5.0-hd8ed1ab_0.conda+ - conda: https://conda.anaconda.org/conda-forge/osx-arm64/pnpm-10.26.2-h803e193_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/pre-commit-4.5.1-pyha770c72_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/pre_commit-4.5.1-hd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pycparser-2.22-pyh29332c3_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda@@ -188,7 +187,7 @@ environments:- conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.12.12-h18782d2_1_cpython.conda- conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.12-8_cp312.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/pyyaml-6.0.3-py312h5748b74_0.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.2-h1d1bf99_2.conda+ - conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.3-h46df422_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/rich-14.2.0-pyhcf101f3_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/shellingham-1.5.4-pyhd8ed1ab_2.conda@@ -199,28 +198,27 @@ environments:- conda: https://conda.anaconda.org/conda-forge/noarch/tomlkit-0.13.3-pyha770c72_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/trove-classifiers-2025.12.1.14-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.15.0-pyhcf101f3_0.conda- - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/ukkonen-1.0.1-py312ha0dd364_6.conda- conda: https://conda.anaconda.org/conda-forge/noarch/userpath-1.9.2-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/osx-arm64/uv-0.6.17-hd4c9240_1.conda- conda: https://conda.anaconda.org/conda-forge/noarch/virtualenv-20.35.4-pyhd8ed1ab_0.conda- conda: https://conda.anaconda.org/conda-forge/noarch/wheel-0.45.1-pyhd8ed1ab_1.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/yaml-0.2.5-h3422bc3_2.tar.bz2- - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.22.0-pyhd8ed1ab_0.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zlib-1.3.1-h8359307_2.conda- - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstandard-0.23.0-py312hea69d52_2.conda- - pypi: https://files.pythonhosted.org/packages/11/a8/c6a4b901d17399c77cd81fb001ce8961e9f5e04d3daf27e8925cb012e163/docutils-0.22.3-py3-none-any.whl+ - conda: https://conda.anaconda.org/conda-forge/osx-arm64/yaml-0.2.5-h925e9cb_3.conda+ - conda: https://conda.anaconda.org/conda-forge/noarch/zipp-3.23.0-pyhcf101f3_1.conda+ - conda: https://conda.anaconda.org/conda-forge/osx-arm64/zstd-1.5.7-hbf9d68e_6.conda+ - pypi: https://files.pythonhosted.org/packages/02/10/5da547df7a391dcde17f59520a231527b8571e6f46fc8efb02ccb370ab12/docutils-0.22.4-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/78/e4/7b614260bf16c5e33c0bea6ac47ab0284efd21f89f2e5e4e15cd93bead40/loro-1.10.3-cp312-cp312-macosx_11_0_arm64.whl- pypi: https://files.pythonhosted.org/packages/70/81/54e3ce63502cd085a0c556652a4e1b919c45a446bd1e5300e10c44c8c521/markdown-3.10-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/7f/ee/af51d090ada641d4b264992a486435ba3ef5b5634bc27e6eb002f71cef7d/msgspec-0.20.0-cp312-cp312-macosx_11_0_arm64.whl- - pypi: https://files.pythonhosted.org/packages/87/0d/1861d1599571974b15b025e12b142d8e6b42ad66c8a07a89cb0fc21f1e03/narwhals-2.13.0-py3-none-any.whl+ - pypi: https://files.pythonhosted.org/packages/79/3e/b8ecc67e178919671695f64374a7ba916cf0adbf86efedc6054f38b5b8ae/narwhals-2.14.0-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/16/32/f8e3c85d1d5250232a5d3477a2a28cc291968ff175caeadaf3cc19ce0e4a/parso-0.8.5-py2.py3-none-any.whl- - pypi: https://files.pythonhosted.org/packages/68/3a/9f93cff5c025029a36d9a92fef47220ab4692ee7f2be0fba9f92813d0cb8/psutil-7.1.3-cp36-abi3-macosx_11_0_arm64.whl+ - pypi: https://files.pythonhosted.org/packages/c5/2c/78e4a789306a92ade5000da4f5de3255202c534acdadc3aac7b5458fadef/psutil-7.2.1-cp36-abi3-macosx_11_0_arm64.whl- pypi: https://files.pythonhosted.org/packages/fb/35/b763e8fbcd51968329b9adc52d188fc97859f85f2ee15fe9f379987d99c5/pymdown_extensions-10.19.1-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whl- - pypi: https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl+ - pypi: https://files.pythonhosted.org/packages/3d/d8/2083a1daa7439a66f3a48589a57d576aa117726762618f6bb09fe3798796/uvicorn-0.40.0-py3-none-any.whl- pypi: https://files.pythonhosted.org/packages/3d/69/1a681dd6f02180916f116894181eab8b2e25b31e484c5d0eae637ec01f7c/websockets-15.0.1-cp312-cp312-macosx_11_0_arm64.whl- pypi: ./packages:@@ -450,12 +448,12 @@ packages:license_family: APACHEpurls:- pkg:pypi/distlib?source=hash-mapping- size: 274151- timestamp: 1733238487461-- pypi: https://files.pythonhosted.org/packages/11/a8/c6a4b901d17399c77cd81fb001ce8961e9f5e04d3daf27e8925cb012e163/docutils-0.22.3-py3-none-any.whl+ size: 275642+ timestamp: 1752823081585+- pypi: https://files.pythonhosted.org/packages/02/10/5da547df7a391dcde17f59520a231527b8571e6f46fc8efb02ccb370ab12/docutils-0.22.4-py3-none-any.whlname: docutils- version: 0.22.3- sha256: bd772e4aca73aff037958d44f2be5229ded4c09927fcf8690c577b66234d6ceb+ version: 0.22.4+ sha256: d0013f540772d1420576855455d050a2180186c91c15779301ac2ccb3eeb68derequires_python: '>=3.9'- conda: https://conda.anaconda.org/conda-forge/noarch/editables-0.5-pyhd8ed1ab_1.condasha256: 8d4f908e670be360617d418c328213bc46e7100154c3742db085148141712f60@@ -479,16 +477,16 @@ packages:- pkg:pypi/exceptiongroup?source=compressed-mappingsize: 21333timestamp: 1763918099466-- conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.20.0-pyhd8ed1ab_0.conda- sha256: 19025a4078ff3940d97eb0da29983d5e0deac9c3e09b0eabf897daeaf9d1114e- md5: 66b8b26023b8efdf8fcb23bac4b6325d+- conda: https://conda.anaconda.org/conda-forge/noarch/filelock-3.20.1-pyhd8ed1ab_0.conda+ sha256: 8028582d956ab76424f6845fa1bdf5cb3e629477dd44157ca30d45e06d8a9c7c+ md5: 81a651287d3000eb12f0860ade0a1b41depends:- python >=3.10license: Unlicensepurls:- pkg:pypi/filelock?source=hash-mapping- size: 17976- timestamp: 1759948208140+ size: 18609+ timestamp: 1765846639623- conda: https://conda.anaconda.org/conda-forge/noarch/h11-0.16.0-pyhd8ed1ab_0.condasha256: f64b68148c478c3bfc8f8d519541de7d2616bf59d44485a5271041d40c061887md5: 4b69232755285701bc86a5afe4d9933a@@ -512,7 +510,7 @@ packages:license: MITlicense_family: MITpurls:- - pkg:pypi/h2?source=compressed-mapping+ - pkg:pypi/h2?source=hash-mappingsize: 95967timestamp: 1756364871835- conda: https://conda.anaconda.org/conda-forge/noarch/hatch-1.16.2-pyhcf101f3_0.conda@@ -719,30 +717,30 @@ packages:- pkg:pypi/jaraco-classes?source=hash-mappingsize: 12109timestamp: 1733326001034-- conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.context-6.0.1-pyhd8ed1ab_0.conda- sha256: bfaba92cd33a0ae2488ab64a1d4e062bcf52b26a71f88292c62386ccac4789d7- md5: bcc023a32ea1c44a790bbf1eae473486+- conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.context-6.0.2-pyhcf101f3_1.conda+ sha256: 0b138d1d65e319a9b58a4e5fefe26c47cc29a52a393b2dbc6c1413da3c711e60+ md5: 9e0af166f43d9174a254eab468b5380cdepends:+ - python >=3.10- backports.tarfile- - python >=3.9+ - pythonlicense: MIT- license_family: MITpurls:- pkg:pypi/jaraco-context?source=hash-mapping- size: 12483- timestamp: 1733382698758-- conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.functools-4.3.0-pyhd8ed1ab_0.conda- sha256: 89320bb2c6bef18f5109bee6cb07a193701cf00552a4cfc6f75073cf0d3e44f6- md5: b86839fa387a5b904846e77c84167e57+ size: 15501+ timestamp: 1766828725330+- conda: https://conda.anaconda.org/conda-forge/noarch/jaraco.functools-4.4.0-pyhd8ed1ab_0.conda+ sha256: 3e297f27f24d56391b937a388d37a95ccf4eb869fb11a07383eb50444e0a3445+ md5: 0d6555c4a8b8631cc8a89cdd27c64557depends:- more-itertools- - python >=3.9+ - python >=3.10license: MITlicense_family: MITpurls:- pkg:pypi/jaraco-functools?source=hash-mapping- size: 16238- timestamp: 1755584796828+ size: 16387+ timestamp: 1766318885381- pypi: https://files.pythonhosted.org/packages/c0/5a/9cac0c82afec3d09ccd97c8b6502d48f165f9124db81b4bcb90b4af974ee/jedi-0.19.2-py2.py3-none-any.whlname: jediversion: 0.19.2@@ -830,29 +828,28 @@ packages:- pkg:pypi/keyring?source=hash-mappingsize: 37717timestamp: 1763320674488-- conda: https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_104.conda- sha256: 9e191baf2426a19507f1d0a17be0fdb7aa155cdf0f61d5a09c808e0a69464312- md5: a6abd2796fc332536735f68ba23f7901+- conda: https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.45-default_hbd61a6d_105.conda+ sha256: 1027bd8aa0d5144e954e426ab6218fd5c14e54a98f571985675468b339c808ca+ md5: 3ec0aa5037d39b06554109a01e6fb0c6depends:- __glibc >=2.17,<3.0.a0- zstd >=1.5.7,<1.6.0a0constrains:- binutils_impl_linux-64 2.45license: GPL-3.0-only- license_family: GPLpurls: []- size: 725545- timestamp: 1764007826689-- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-21.1.7-hf598326_0.conda- sha256: 4bdbef0241b52e7a8552e8af7425f0b56d5621dd69df46c816546fefa17d77ab- md5: 0de94f39727c31c0447e408c5a210a56+ size: 730831+ timestamp: 1766513089214+- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-21.1.8-hf598326_0.conda+ sha256: 82e228975fd491bcf1071ecd0a6ec2a0fcc5f57eb0bd1d52cb13a18d57c67786+ md5: 780f0251b757564e062187044232c2b7depends:- __osx >=11.0license: Apache-2.0 WITH LLVM-exceptionlicense_family: Apachepurls: []- size: 568715- timestamp: 1764676451068+ size: 569118+ timestamp: 1765919724254- conda: https://conda.anaconda.org/conda-forge/linux-64/libexpat-2.7.3-hecca717_0.condasha256: 1e1b08f6211629cbc2efe7a5bca5953f8f6b3cae0eeb04ca4dacee1bd4e2db2fmd5: 8b09ae86839581147ef2e5c5e229d164@@ -909,6 +906,7 @@ packages:- libgcc-ng ==15.2.0=*_16- libgomp 15.2.0 he0feb66_16license: GPL-3.0-only WITH GCC-exception-3.1+ license_family: GPLpurls: []size: 1042798timestamp: 1765256792743@@ -918,6 +916,7 @@ packages:depends:- libgcc 15.2.0 he0feb66_16license: GPL-3.0-only WITH GCC-exception-3.1+ license_family: GPLpurls: []size: 27256timestamp: 1765256804124@@ -943,6 +942,7 @@ packages:depends:- __glibc >=2.17,<3.0.a0license: GPL-3.0-only WITH GCC-exception-3.1+ license_family: GPLpurls: []size: 603284timestamp: 1765256703881@@ -990,27 +990,27 @@ packages:purls: []size: 33731timestamp: 1750274110928-- conda: https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_0.conda- sha256: 6f0e8a812e8e33a4d8b7a0e595efe28373080d27b78ee4828aa4f6649a088454- md5: 2e1b84d273b01835256e53fd938de355+- conda: https://conda.anaconda.org/conda-forge/linux-64/libsqlite-3.51.1-h0c1763c_1.conda+ sha256: 5ef162b2a1390d1495a759734afe2312a358a58441cf8f378be651903646f3b7+ md5: ad1fd565aff83b543d726382c0ab0af2depends:- __glibc >=2.17,<3.0.a0- libgcc >=14- libzlib >=1.3.1,<2.0a0license: blessingpurls: []- size: 938979- timestamp: 1764359444435-- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsqlite-3.51.1-h9a5124b_0.conda- sha256: a46b167447e2a9e38586320c30b29e3b68b6f7e6b873c18d6b1aa2efd2626917- md5: 67e50e5bd4e5e2310d66b88c4da50096+ size: 940686+ timestamp: 1766319628770+- conda: https://conda.anaconda.org/conda-forge/osx-arm64/libsqlite-3.51.1-h1b79a29_1.conda+ sha256: f2c3cbf2ca7d697098964a748fbf19d6e4adcefa23844ec49f0166f1d36af83c+ md5: 8c3951797658e10b610929c3e57e9ad9depends:- __osx >=11.0- libzlib >=1.3.1,<2.0a0license: blessingpurls: []- size: 906292- timestamp: 1764359907797+ size: 905861+ timestamp: 1766319901587- conda: https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-15.2.0-h934c35e_16.condasha256: 813427918316a00c904723f1dfc3da1bbc1974c5cfe1ed1e704c6f4e0798cbc6md5: 68f68355000ec3f1d6f26ea13e8f525f@@ -1020,6 +1020,7 @@ packages:constrains:- libstdcxx-ng ==15.2.0=*_16license: GPL-3.0-only WITH GCC-exception-3.1+ license_family: GPLpurls: []size: 5856456timestamp: 1765256838573@@ -1029,20 +1030,20 @@ packages:depends:- libstdcxx 15.2.0 h934c35e_16license: GPL-3.0-only WITH GCC-exception-3.1+ license_family: GPLpurls: []size: 27300timestamp: 1765256885128-- conda: https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.41.2-h5347b49_1.conda- sha256: 030447cf827c471abd37092ab9714fde82b8222106f22fde94bc7a64e2704c40- md5: 41f5c09a211985c3ce642d60721e7c3e+- conda: https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.41.3-h5347b49_0.conda+ sha256: 1a7539cfa7df00714e8943e18de0b06cceef6778e420a5ee3a2a145773758aee+ md5: db409b7c1720428638e7c0d509d3e1b5depends:- __glibc >=2.17,<3.0.a0- libgcc >=14license: BSD-3-Clause- license_family: BSDpurls: []- size: 40235- timestamp: 1764790744114+ size: 40311+ timestamp: 1766271528534- conda: https://conda.anaconda.org/conda-forge/linux-64/libuv-1.51.0-hb03c661_1.condasha256: c180f4124a889ac343fc59d15558e93667d894a966ec6fdb61da1604481be26bmd5: 0f03292cc56bf91a077a134ea8747118@@ -1132,7 +1133,7 @@ packages:- pypi: ./name: marimoversion: 0.18.4- sha256: fb2108ee97d3535ebb2404fef034bc15f52aa9bc16757ae68d988d8cd4f1f12c+ sha256: ce333609b9b918f5f9c265eb66b70f0fe7dab0c3c6d9c7260625cb9758157ebcrequires_dist:- click>=8.0,<9- jedi>=0.18.0@@ -1160,17 +1161,17 @@ packages:- polars[pyarrow]>=1.9.0 ; extra == 'recommended'- sqlglot[rs]>=26.2.0 ; extra == 'recommended'- openai>=1.55.3 ; extra == 'recommended'- - google-genai>=1.20.0 ; extra == 'recommended'- ruff ; extra == 'recommended'- nbformat>=5.7.0 ; extra == 'recommended'- click>=8.0,<9 ; extra == 'dev'- black~=23.12.1 ; extra == 'dev'- - opentelemetry-api~=1.26.0 ; extra == 'dev'- - opentelemetry-sdk~=1.26.0 ; extra == 'dev'+ - opentelemetry-api~=1.28.0 ; extra == 'dev'+ - opentelemetry-sdk~=1.28.0 ; extra == 'dev'- duckdb>=1.0.0 ; extra == 'dev'- sqlglot[rs]>=26.2.0 ; extra == 'dev'- ruff>=0.13.2 ; extra == 'dev'- openai>=1.55.3 ; extra == 'dev'+ - pydantic-ai-slim[google,anthropic]>=1.39.0 ; extra == 'dev'- python-lsp-server>=1.13.0 ; extra == 'lsp'- python-lsp-ruff>=2.0.0 ; extra == 'lsp'- mcp>=1.0.0 ; python_full_version >= '3.10' and extra == 'mcp'@@ -1192,9 +1193,9 @@ packages:- mkdocs-section-index ; extra == 'docs'- mkdocs-literate-nav ; extra == 'docs'requires_python: '>=3.10'-- conda: https://conda.anaconda.org/conda-forge/noarch/markdown-it-py-3.0.0-pyhd8ed1ab_1.conda- sha256: 0fbacdfb31e55964152b24d5567e9a9996e1e7902fb08eb7d91b5fd6ce60803a- md5: fee3164ac23dfca50cfcc8b85ddefb81+- conda: https://conda.anaconda.org/conda-forge/noarch/markdown-it-py-4.0.0-pyhd8ed1ab_0.conda+ sha256: 7b1da4b5c40385791dbc3cc85ceea9fad5da680a27d5d3cb8bfaa185e304a89e+ md5: 5b5203189eb668f042ac2b0826244964depends:- mdurl >=0.1,<1- python >=3.10@@ -1245,10 +1246,10 @@ packages:- tomli-w ; extra == 'toml'- pyyaml ; extra == 'yaml'requires_python: '>=3.9'-- pypi: https://files.pythonhosted.org/packages/87/0d/1861d1599571974b15b025e12b142d8e6b42ad66c8a07a89cb0fc21f1e03/narwhals-2.13.0-py3-none-any.whl+- pypi: https://files.pythonhosted.org/packages/79/3e/b8ecc67e178919671695f64374a7ba916cf0adbf86efedc6054f38b5b8ae/narwhals-2.14.0-py3-none-any.whlname: narwhals- version: 2.13.0- sha256: 9b795523c179ca78204e3be53726da374168f906e38de2ff174c2363baaaf481+ version: 2.14.0+ sha256: b56796c9a00179bd757d15282c540024e1d5c910b19b8c9944d836566c030acfrequires_dist:- cudf>=24.10.0 ; extra == 'cudf'- dask[dataframe]>=2024.8 ; extra == 'dask'@@ -1284,34 +1285,34 @@ packages:purls: []size: 797030timestamp: 1738196177597-- conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.9.1-pyhd8ed1ab_1.conda- sha256: 3636eec0e60466a00069b47ce94b6d88b01419b6577d8e393da44bb5bc8d3468- md5: 7ba3f09fceae6a120d664217e58fe686+- conda: https://conda.anaconda.org/conda-forge/noarch/nodeenv-1.10.0-pyhd8ed1ab_0.conda+ sha256: 4fa40e3e13fc6ea0a93f67dfc76c96190afd7ea4ffc1bac2612d954b42cdc3ee+ md5: eb52d14a901e23c39e9e7b4a1a5c015fdepends:- - python >=3.9+ - python >=3.10- setuptoolslicense: BSD-3-Clauselicense_family: BSDpurls:- pkg:pypi/nodeenv?source=hash-mapping- size: 34574- timestamp: 1734112236147-- conda: https://conda.anaconda.org/conda-forge/linux-64/nodejs-22.19.0-h4a9c4b4_1.conda- sha256: 371f7cdd45979e1c7ecad5db710625c9a39ca0e79418dd4b06fa11ce0c210b02- md5: 4c246c291d6b7a208c7b7080a6304dcf+ size: 40866+ timestamp: 1766261270149+- conda: https://conda.anaconda.org/conda-forge/linux-64/nodejs-22.21.1-h4a9c4b4_0.conda+ sha256: 7808695078b286548a56a0833bbe65f0d2a547bc134bc8a12d106b384d048e17+ md5: 3fe7cdb8ea3181917e358f31a9a0b514depends:- libgcc >=14- __glibc >=2.28,<3.0.a0- libstdcxx >=14- - libuv >=1.51.0,<2.0a0- - icu >=75.1,<76.0a0- openssl >=3.5.4,<4.0a0+ - icu >=75.1,<76.0a0+ - libuv >=1.51.0,<2.0a0- libzlib >=1.3.1,<2.0a0license: MITlicense_family: MITpurls: []- size: 24442349- timestamp: 1764765266486+ size: 24194392+ timestamp: 1765444695531- conda: https://conda.anaconda.org/conda-forge/osx-arm64/nodejs-22.21.1-hf2fe37f_0.condasha256: 16fc66a8f7c566aa626833482bfeb20f6a1953861ba5d7e91eb4f72c600c4151md5: cd2e913e4e61a013e1707daf551165d3@@ -1323,6 +1324,7 @@ packages:- icu >=75.1,<76.0a0- libuv >=1.51.0,<2.0a0license: MIT+ license_family: MITpurls: []size: 16727525timestamp: 1765374502949@@ -1444,36 +1446,34 @@ packages:- pkg:pypi/pluggy?source=compressed-mappingsize: 25877timestamp: 1764896838868-- conda: https://conda.anaconda.org/conda-forge/linux-64/pnpm-10.25.0-h52a9d3b_0.conda- sha256: c7ac595be694c18e830a59c37a0e37ec269accf5fab64d6f318d8ff4d8224442- md5: bc1e275ffecc72f053dde6450eca5f69+- conda: https://conda.anaconda.org/conda-forge/linux-64/pnpm-10.26.2-h52a9d3b_0.conda+ sha256: cfcfed9f5ece7dde664e951ccbd9fa9c1da414a255fcbc035e8be1800eed94a8+ md5: 578b364044f604c434f1c6b01e0c2db1depends:- nodejs- - libstdcxx >=14- - libgcc >=14- __glibc >=2.17,<3.0.a0- - nodejs >=22.19.0,<23.0a0+ - libgcc >=14+ - libstdcxx >=14+ - nodejs >=22.21.1,<23.0a0license: MIT- license_family: MITpurls: []- size: 3242519- timestamp: 1765207099697-- conda: https://conda.anaconda.org/conda-forge/osx-arm64/pnpm-10.25.0-hbbe5caa_0.conda- sha256: 3120533709e8900e73341e76c30ee3ef866648bd102d8fc24c40d3fd36df7b33- md5: 684354e5f397c16cfe09c91ea0d6c4ba+ size: 3241018+ timestamp: 1766502274250+- conda: https://conda.anaconda.org/conda-forge/osx-arm64/pnpm-10.26.2-h803e193_0.conda+ sha256: 7996a811b46ae0b92d4a77213b8b8c7c88dcd289e2d08b3c67a5fcaa6a4bd43c+ md5: eb7aeb85d5af180fc153db6e872be540depends:- nodejs- - libcxx >=19- __osx >=11.0- - nodejs >=22.19.0,<23.0a0+ - libcxx >=19+ - nodejs >=22.21.1,<23.0a0license: MIT- license_family: MITpurls: []- size: 3247568- timestamp: 1765207136551-- conda: https://conda.anaconda.org/conda-forge/noarch/pre-commit-4.5.0-pyha770c72_0.conda- sha256: 8481f4939b1f81cf0db12456819368b41e3f998e4463e41611de4b13752b2c08- md5: af8d4882203bccefec6f1aeed70030c6+ size: 3247107+ timestamp: 1766502315764+- conda: https://conda.anaconda.org/conda-forge/noarch/pre-commit-4.5.1-pyha770c72_0.conda+ sha256: 5b81b7516d4baf43d0c185896b245fa7384b25dc5615e7baa504b7fa4e07b706+ md5: 7f3ac694319c7eaf81a0325d6405e974depends:- cfgv >=2.0.0- identify >=1.0.0@@ -1485,26 +1485,26 @@ packages:license_family: MITpurls:- pkg:pypi/pre-commit?source=hash-mapping- size: 201265- timestamp: 1764067809524-- conda: https://conda.anaconda.org/conda-forge/noarch/pre_commit-4.5.0-hd8ed1ab_0.conda- sha256: d25f0d91e33dde8866a7221009fd38320e4f2f16a8b2148b0164c6d2a95d8084- md5: d6ac0990dccfa0c985935a09306ff137+ size: 200827+ timestamp: 1765937577534+- conda: https://conda.anaconda.org/conda-forge/noarch/pre_commit-4.5.1-hd8ed1ab_0.conda+ sha256: d16e36b353076d3d85d815d2898ffb84a73120f037cec977aa3edb90249fa2e1+ md5: 6611e691b784bfbc7126deca525d971adepends:- - pre-commit >=4.5.0,<4.5.1.0a0+ - pre-commit >=4.5.1,<4.5.2.0a0license: MITlicense_family: MITpurls: []- size: 6850- timestamp: 1742475657138-- pypi: https://files.pythonhosted.org/packages/68/3a/9f93cff5c025029a36d9a92fef47220ab4692ee7f2be0fba9f92813d0cb8/psutil-7.1.3-cp36-abi3-macosx_11_0_arm64.whl+ size: 6971+ timestamp: 1765937578285+- pypi: https://files.pythonhosted.org/packages/29/f8/40e01c350ad9a2b3cb4e6adbcc8a83b17ee50dd5792102b6142385937db5/psutil-7.2.1-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whlname: psutil- version: 7.1.3- sha256: bc31fa00f1fbc3c3802141eede66f3a2d51d89716a194bf2cd6fc68310a19880+ version: 7.2.1+ sha256: 5e38404ca2bb30ed7267a46c02f06ff842e92da3bb8c5bfdadbd35a5722314d8requires_dist:+ - psleak ; extra == 'dev'- pytest ; extra == 'dev'- pytest-instafail ; extra == 'dev'- - pytest-subtests ; extra == 'dev'- pytest-xdist ; extra == 'dev'- setuptools ; extra == 'dev'- abi3audit ; extra == 'dev'@@ -1527,28 +1527,20 @@ packages:- virtualenv ; extra == 'dev'- vulture ; extra == 'dev'- wheel ; extra == 'dev'- - colorama ; os_name == 'nt' and extra == 'dev'- - pyreadline ; os_name == 'nt' and extra == 'dev'- - pywin32 ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'dev'- - wheel ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'dev'- - wmi ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'dev'+ - psleak ; extra == 'test'- pytest ; extra == 'test'- pytest-instafail ; extra == 'test'- - pytest-subtests ; extra == 'test'- pytest-xdist ; extra == 'test'- setuptools ; extra == 'test'- - pywin32 ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'test'- - wheel ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'test'- - wmi ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'test'requires_python: '>=3.6'-- pypi: https://files.pythonhosted.org/packages/ce/b1/5f49af514f76431ba4eea935b8ad3725cdeb397e9245ab919dbc1d1dc20f/psutil-7.1.3-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl+- pypi: https://files.pythonhosted.org/packages/c5/2c/78e4a789306a92ade5000da4f5de3255202c534acdadc3aac7b5458fadef/psutil-7.2.1-cp36-abi3-macosx_11_0_arm64.whlname: psutil- version: 7.1.3- sha256: 3bb428f9f05c1225a558f53e30ccbad9930b11c3fc206836242de1091d3e7dd3+ version: 7.2.1+ sha256: 05cc68dbb8c174828624062e73078e7e35406f4ca2d0866c272c2410d8ef06d1requires_dist:+ - psleak ; extra == 'dev'- pytest ; extra == 'dev'- pytest-instafail ; extra == 'dev'- - pytest-subtests ; extra == 'dev'- pytest-xdist ; extra == 'dev'- setuptools ; extra == 'dev'- abi3audit ; extra == 'dev'@@ -1571,19 +1563,11 @@ packages:- virtualenv ; extra == 'dev'- vulture ; extra == 'dev'- wheel ; extra == 'dev'- - colorama ; os_name == 'nt' and extra == 'dev'- - pyreadline ; os_name == 'nt' and extra == 'dev'- - pywin32 ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'dev'- - wheel ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'dev'- - wmi ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'dev'+ - psleak ; extra == 'test'- pytest ; extra == 'test'- pytest-instafail ; extra == 'test'- - pytest-subtests ; extra == 'test'- pytest-xdist ; extra == 'test'- setuptools ; extra == 'test'- - pywin32 ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'test'- - wheel ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'test'- - wmi ; os_name == 'nt' and platform_python_implementation != 'PyPy' and extra == 'test'requires_python: '>=3.6'- conda: https://conda.anaconda.org/conda-forge/noarch/ptyprocess-0.7.0-pyhd8ed1ab_1.condasha256: a7713dfe30faf17508ec359e0bc7e0983f5d94682492469bd462cdaae9c64d83@@ -1616,8 +1600,8 @@ packages:license_family: BSDpurls:- pkg:pypi/pygments?source=hash-mapping- size: 888600- timestamp: 1736243563082+ size: 889287+ timestamp: 1750615908735- pypi: https://files.pythonhosted.org/packages/fb/35/b763e8fbcd51968329b9adc52d188fc97859f85f2ee15fe9f379987d99c5/pymdown_extensions-10.19.1-py3-none-any.whlname: pymdown-extensionsversion: 10.19.1@@ -1731,27 +1715,29 @@ packages:- pkg:pypi/pyyaml?source=hash-mappingsize: 190579timestamp: 1758891996097-- conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.2-h8c095d6_2.conda- sha256: 2d6d0c026902561ed77cd646b5021aef2d4db22e57a5b0178dfc669231e06d2c- md5: 283b96675859b20a825f8fa30f311446+- conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.3-h853b02a_0.conda+ sha256: 12ffde5a6f958e285aa22c191ca01bbd3d6e710aa852e00618fa6ddc59149002+ md5: d7d95fc8287ea7bf33e0e7116d2b95ecdepends:- - libgcc >=13+ - __glibc >=2.17,<3.0.a0+ - libgcc >=14- ncurses >=6.5,<7.0a0license: GPL-3.0-onlylicense_family: GPLpurls: []- size: 282480- timestamp: 1740379431762-- conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.2-h1d1bf99_2.conda- sha256: 7db04684d3904f6151eff8673270922d31da1eea7fa73254d01c437f49702e34- md5: 63ef3f6e6d6d5c589e64f11263dc5676+ size: 345073+ timestamp: 1765813471974+- conda: https://conda.anaconda.org/conda-forge/osx-arm64/readline-8.3-h46df422_0.conda+ sha256: a77010528efb4b548ac2a4484eaf7e1c3907f2aec86123ed9c5212ae44502477+ md5: f8381319127120ce51e081dce4865cf4depends:+ - __osx >=11.0- ncurses >=6.5,<7.0a0license: GPL-3.0-onlylicense_family: GPLpurls: []- size: 252359- timestamp: 1740379663071+ size: 313930+ timestamp: 1765813902568- conda: https://conda.anaconda.org/conda-forge/noarch/rich-14.2.0-pyhcf101f3_0.condasha256: edfb44d0b6468a8dfced728534c755101f06f1a9870a7ad329ec51389f16b086md5: a247579d8a59931091b16a1e932bbed6@@ -1812,9 +1798,9 @@ packages:license: Apache-2.0license_family: Apachepurls:- - pkg:pypi/sniffio?source=hash-mapping- size: 15019- timestamp: 1733244175724+ - pkg:pypi/sniffio?source=compressed-mapping+ size: 15698+ timestamp: 1762941572482- pypi: https://files.pythonhosted.org/packages/d9/52/1064f510b141bd54025f9b55105e26d1fa970b9be67ad766380a3c9b74b0/starlette-0.50.0-py3-none-any.whlname: starletteversion: 0.50.0@@ -1828,9 +1814,9 @@ packages:- python-multipart>=0.0.18 ; extra == 'full'- pyyaml ; extra == 'full'requires_python: '>=3.10'-- conda: https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_h4845f30_101.conda- sha256: e0569c9caa68bf476bead1bed3d79650bb080b532c64a4af7d8ca286c08dea4e- md5: d453b98d9c83e71da0741bb0ff4d76bc+- conda: https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.13-noxft_ha0e22de_103.conda+ sha256: 1544760538a40bcd8ace2b1d8ebe3eb5807ac268641f8acdc18c69c5ebfeaf64+ md5: 86bc20552bf46075e3d92b67f089172ddepends:- __glibc >=2.17,<3.0.a0- libgcc >=13@@ -1862,7 +1848,7 @@ packages:license: MITlicense_family: MITpurls:- - pkg:pypi/tomli?source=compressed-mapping+ - pkg:pypi/tomli?source=hash-mappingsize: 20973timestamp: 1760014679845- conda: https://conda.anaconda.org/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda@@ -1910,13 +1896,13 @@ packages:- pkg:pypi/typing-extensions?source=hash-mappingsize: 51692timestamp: 1756220668932-- conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025b-h78e105d_0.conda- sha256: 5aaa366385d716557e365f0a4e9c3fca43ba196872abbbe3d56bb610d131e192- md5: 4222072737ccff51314b5ece9c7d6f5a+- conda: https://conda.anaconda.org/conda-forge/noarch/tzdata-2025c-hc9c84f9_1.conda+ sha256: 1d30098909076af33a35017eed6f2953af1c769e273a0626a04722ac4acaba3c+ md5: ad659d0a2b3e47e38d829aa8cad2d610license: LicenseRef-Public-Domainpurls: []- size: 122968- timestamp: 1742727099393+ size: 119135+ timestamp: 1767016325805- conda: https://conda.anaconda.org/conda-forge/linux-64/ukkonen-1.0.1-py312hd9148b4_6.condasha256: e1ecdfe8b0df725436e1d307e8672010d92b9aa96148f21ddf9be9b9596c75b0md5: f30ece80e76f9cc96e30cc5c71d2818e@@ -1987,10 +1973,10 @@ packages:purls: []size: 12337543timestamp: 1745938010152-- pypi: https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl+- pypi: https://files.pythonhosted.org/packages/3d/d8/2083a1daa7439a66f3a48589a57d576aa117726762618f6bb09fe3798796/uvicorn-0.40.0-py3-none-any.whlname: uvicorn- version: 0.38.0- sha256: 48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02+ version: 0.40.0+ sha256: c6c8f55bc8bf13eb6fa9ff87ad62308bbbc33d0b67f84293151efe87e0d5f2eerequires_dist:- click>=7.0- h11>=0.8@@ -2002,7 +1988,7 @@ packages:- uvloop>=0.15.1 ; platform_python_implementation != 'PyPy' and sys_platform != 'cygwin' and sys_platform != 'win32' and extra == 'standard'- watchfiles>=0.13 ; extra == 'standard'- websockets>=10.4 ; extra == 'standard'- requires_python: '>=3.9'+ requires_python: '>=3.10'- conda: https://conda.anaconda.org/conda-forge/noarch/virtualenv-20.35.4-pyhd8ed1ab_0.condasha256: 77193c99c6626c58446168d3700f9643d8c0dab1f6deb6b9dd039e6872781bfbmd5: cfccfd4e8d9de82ed75c8e2c91cab375diff --git a/pyproject.toml b/pyproject.tomlindex 5c49205f3c..df47a0a4eb 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -95,7 +95,6 @@ recommended = ["polars[pyarrow]>=1.9.0", # SQL output back in Python"sqlglot[rs]>=26.2.0", # SQL cells parsing"openai>=1.55.3", # AI features- "google-genai>=1.20.0", # Google AI features"ruff", # Formatting"nbformat>=5.7.0", # Export as IPYNB]@@ -104,8 +103,8 @@ dev = ["click>=8.0,<9","black~=23.12.1",# For tracing debugging- "opentelemetry-api~=1.26.0",- "opentelemetry-sdk~=1.26.0",+ "opentelemetry-api~=1.28.0",+ "opentelemetry-sdk~=1.28.0",# For SQL"duckdb>=1.0.0","sqlglot[rs]>=26.2.0",@@ -113,6 +112,7 @@ dev = ["ruff>=0.13.2",# For AI"openai>=1.55.3",+ "pydantic-ai-slim[google,anthropic]>=1.39.0"]lsp = [@@ -162,9 +162,8 @@ dependencies = ["matplotlib>=3.8.0","sqlglot[rs]>=26.2.0","sqlalchemy>=2.0.40",- "google-genai>=1.0.0",+ "pydantic-ai-slim[google,anthropic]>=1.39.0","openai>=1.55.3",- "anthropic>=0.52.2","loro>=1.5.0","pandas-stubs>=1.5.3.230321","pyiceberg>=0.9.0",@@ -194,7 +193,7 @@ extra-dependencies = ["dirty-equals~=0.9.0","hypothesis~=6.102.1",# For server testing- "httpx~=0.27.0",+ "httpx~=0.28.0","urllib3~=2.5.0","matplotlib~=3.10.7",# Forced for modern matplotlib.@@ -229,7 +228,7 @@ template = "test"extra-dependencies = ["dirty-equals~=0.9.0","hypothesis~=6.102.1",- "httpx~=0.27.0",+ "httpx~=0.28.0","matplotlib~=3.9.2","pytest~=8.3.4","pytest-timeout~=2.3.1",@@ -269,8 +268,7 @@ extra-dependencies = ["ipython~=8.12.3",# testing gen ai"openai>=1.55.3",- "anthropic==0.52.2",- "google-genai>=0.2.0",+ "pydantic-ai-slim[google,anthropic]>=1.39.0","boto3>=1.38.46","litellm>=1.70.0",# exporting as ipynb@@ -482,6 +480,7 @@ banned-module-level-imports = ["typing_extensions","pyiceberg","redshift_connector",+ "pydantic_ai"][tool.ruff.lint.flake8-pytest-style]diff --git a/tests/_ai/test_chat_convert.py b/tests/_ai/test_chat_convert.pyindex f1822dff87..1b02ce52ea 100644--- a/tests/_ai/test_chat_convert.py+++ b/tests/_ai/test_chat_convert.py@@ -15,6 +15,7 @@ from marimo._ai._convert import (convert_to_groq_messages,convert_to_openai_messages,convert_to_openai_tools,+ extract_text,get_google_messages_from_parts,get_openai_messages_from_parts,)@@ -1407,3 +1408,66 @@ def test_get_google_messages_from_parts_empty():"""Test converting empty parts list."""result = get_google_messages_from_parts("user", [])assert result == []+++class TestExtractText:+ """Tests for the extract_text function."""++ def test_extract_text_from_base64_data_url(self):+ """Test extracting text from a base64-encoded data URL."""+ # "Hello, World!" encoded in base64+ data_url = "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="+ result = extract_text(data_url)+ assert result == "Hello, World!"++ def test_extract_text_from_base64_utf8(self):+ """Test extracting UTF-8 text from a base64-encoded data URL."""+ # "こんにちは" (Japanese for "Hello") encoded in base64+ text = "こんにちは"+ encoded = base64.b64encode(text.encode("utf-8")).decode("ascii")+ data_url = f"data:text/plain;base64,{encoded}"+ result = extract_text(data_url)+ assert result == text++ def test_extract_text_from_base64_latin1_fallback(self):+ """Test extracting text with latin1 fallback when UTF-8 fails."""+ # Create bytes that are valid latin1 but invalid UTF-8+ latin1_bytes = bytes([0xE9, 0xE8, 0xE0]) # é, è, à in latin1+ encoded = base64.b64encode(latin1_bytes).decode("ascii")+ data_url = f"data:text/plain;base64,{encoded}"+ result = extract_text(data_url)+ assert result == latin1_bytes.decode("latin1")++ def test_extract_text_from_plain_url(self):+ """Test that non-data URLs are returned as-is."""+ url = "https://example.com/file.txt"+ result = extract_text(url)+ assert result == url++ def test_extract_text_from_relative_url(self):+ """Test that relative URLs are returned as-is."""+ url = "/path/to/file.txt"+ result = extract_text(url)+ assert result == url++ def test_extract_text_empty_content(self):+ """Test extracting empty text content."""+ data_url = "data:text/plain;base64,"+ result = extract_text(data_url)+ assert result == ""++ def test_extract_text_multiline_content(self):+ """Test extracting multiline text content."""+ text = "Line 1\nLine 2\nLine 3"+ encoded = base64.b64encode(text.encode("utf-8")).decode("ascii")+ data_url = f"data:text/plain;base64,{encoded}"+ result = extract_text(data_url)+ assert result == text++ def test_extract_text_with_special_characters(self):+ """Test extracting text with special characters."""+ text = "Special chars: !@#$%^&*()_+-=[]{}|;':\",./<>?"+ encoded = base64.b64encode(text.encode("utf-8")).decode("ascii")+ data_url = f"data:text/plain;base64,{encoded}"+ result = extract_text(data_url)+ assert result == textdiff --git a/tests/_ai/test_pydantic_utils.py b/tests/_ai/test_pydantic_utils.pynew file mode 100644index 0000000000..06358ac08a--- /dev/null+++ b/tests/_ai/test_pydantic_utils.py@@ -0,0 +1,477 @@+# Copyright 2025 Marimo. All rights reserved.+from __future__ import annotations++from dataclasses import dataclass+from unittest.mock import AsyncMock++import pytest++pytest.importorskip("pydantic_ai", reason="pydantic_ai not installed")++from marimo._ai._pydantic_ai_utils import (+ convert_to_pydantic_messages,+ create_simple_prompt,+ form_toolsets,+ generate_id,+)+from marimo._server.ai.tools.types import ToolDefinition+++class TestGenerateId:+ def test_generate_id_with_prefix(self):+ result = generate_id("test")+ assert result.startswith("test_")+ # UUID hex is 32 characters+ assert len(result) == len("test_") + 32++ def test_generate_id_returns_unique_values(self):+ ids = [generate_id("prefix") for _ in range(100)]+ assert len(set(ids)) == 100++ def test_generate_id_with_empty_prefix(self):+ result = generate_id("")+ assert result.startswith("_")+++class TestFormToolsets:+ def test_form_toolsets_empty_list(self):+ tool_invoker = AsyncMock()+ toolset, deferred = form_toolsets([], tool_invoker)+ assert toolset is not None+ assert deferred is False++ def test_form_toolsets_with_backend_tool(self):+ tool_invoker = AsyncMock()+ tool = ToolDefinition(+ name="test_tool",+ description="A test tool",+ parameters={"type": "object", "properties": {}},+ source="backend",+ mode=["manual"],+ )+ toolset, deferred = form_toolsets([tool], tool_invoker)+ assert toolset is not None+ assert deferred is False++ def test_form_toolsets_with_frontend_tool(self):+ tool_invoker = AsyncMock()+ tool = ToolDefinition(+ name="frontend_tool",+ description="A frontend tool",+ parameters={"type": "object", "properties": {}},+ source="frontend",+ mode=["manual"],+ )+ toolset, deferred = form_toolsets([tool], tool_invoker)+ assert toolset is not None+ assert deferred is True++ def test_form_toolsets_with_multiple_tools(self):+ tool_invoker = AsyncMock()+ tools = [+ ToolDefinition(+ name="backend_tool",+ description="A backend tool",+ parameters={"type": "object", "properties": {}},+ source="backend",+ mode=["manual"],+ ),+ ToolDefinition(+ name="frontend_tool",+ description="A frontend tool",+ parameters={"type": "object", "properties": {}},+ source="frontend",+ mode=["manual"],+ ),+ ToolDefinition(+ name="mcp_tool",+ description="An MCP tool",+ parameters={"type": "object", "properties": {}},+ source="mcp",+ mode=["manual"],+ ),+ ]+ toolset, deferred = form_toolsets(tools, tool_invoker)+ assert toolset is not None+ assert deferred is True # has frontend tool++ def test_form_toolsets_with_only_backend_and_mcp_tools(self):+ tool_invoker = AsyncMock()+ tools = [+ ToolDefinition(+ name="backend_tool",+ description="A backend tool",+ parameters={"type": "object", "properties": {}},+ source="backend",+ mode=["manual"],+ ),+ ToolDefinition(+ name="mcp_tool",+ description="An MCP tool",+ parameters={"type": "object", "properties": {}},+ source="mcp",+ mode=["manual"],+ ),+ ]+ toolset, deferred = form_toolsets(tools, tool_invoker)+ assert toolset is not None+ assert deferred is False # no frontend tools++ async def test_backend_tool_invokes_tool_invoker(self):+ @dataclass+ class MockResult:+ value: str++ tool_invoker = AsyncMock(return_value=MockResult(value="result"))+ tool = ToolDefinition(+ name="backend_tool",+ description="A backend tool",+ parameters={"type": "object", "properties": {}},+ source="backend",+ mode=["manual"],+ )+ toolset, deferred = form_toolsets([tool], tool_invoker)+ assert deferred is False++ tools = toolset.tools+ assert len(tools) == 1+ assert "backend_tool" in tools+ backend_tool = tools["backend_tool"]+ assert backend_tool.name == "backend_tool"+ assert backend_tool.description == "A backend tool"++ # Actually call the tool function+ result = await backend_tool.function(arg1="test", arg2=123) # type: ignore[call-arg]++ # Verify tool_invoker was called with correct arguments+ tool_invoker.assert_called_once_with(+ "backend_tool", {"arg1": "test", "arg2": 123}+ )+ # Verify result is converted to dict via asdict+ assert result == {"value": "result"}++ async def test_frontend_tool_raises_call_deferred(self):+ from pydantic_ai import CallDeferred++ tool_invoker = AsyncMock()+ tool = ToolDefinition(+ name="frontend_tool",+ description="A frontend tool",+ parameters={"type": "object", "properties": {}},+ source="frontend",+ mode=["manual"],+ )+ toolset, deferred = form_toolsets([tool], tool_invoker)+ assert deferred is True++ tools = toolset.tools+ assert len(tools) == 1+ assert "frontend_tool" in tools+ frontend_tool = tools["frontend_tool"]+ assert frontend_tool.name == "frontend_tool"+ assert frontend_tool.description == "A frontend tool"++ # Call the tool function and verify it raises CallDeferred+ with pytest.raises(CallDeferred) as exc_info:+ await frontend_tool.function(arg="value") # type: ignore[call-arg]++ # Verify CallDeferred has correct metadata+ assert exc_info.value.metadata == {+ "source": "frontend",+ "tool_name": "frontend_tool",+ "kwargs": {"arg": "value"},+ }+ # Verify tool_invoker was NOT called for frontend tools+ tool_invoker.assert_not_called()+++class TestConvertToPydanticMessages:+ def test_convert_empty_messages(self):+ result = convert_to_pydantic_messages([])+ assert result == []++ def test_convert_message_with_message_id(self):+ from pydantic_ai.ui.vercel_ai.request_types import TextUIPart++ messages = [+ {+ "messageId": "msg_123",+ "role": "user",+ "parts": [{"type": "text", "text": "Hello"}],+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert len(result) == 1+ assert result[0].id == "msg_123"+ assert result[0].role == "user"+ assert result[0].parts == [+ TextUIPart(+ type="text", text="Hello", state=None, provider_metadata=None+ )+ ]++ def test_convert_message_with_id(self):+ messages = [+ {+ "id": "id_456",+ "role": "assistant",+ "parts": [{"type": "text", "text": "Hi there"}],+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert len(result) == 1+ assert result[0].id == "id_456"+ assert result[0].role == "assistant"++ def test_convert_message_generates_id_when_missing(self):+ messages = [+ {+ "role": "user",+ "parts": [{"type": "text", "text": "Hello"}],+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert len(result) == 1+ assert result[0].id.startswith("message_")++ def test_convert_message_prefers_message_id_over_id(self):+ messages = [+ {+ "messageId": "message_id_value",+ "id": "id_value",+ "role": "user",+ "parts": [],+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert result[0].id == "message_id_value"++ def test_convert_message_defaults_role_to_assistant(self):+ messages = [+ {+ "id": "test_id",+ "parts": [],+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert result[0].role == "assistant"++ def test_convert_message_defaults_parts_to_empty_list(self):+ messages = [+ {+ "id": "test_id",+ "role": "user",+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert result[0].parts == []++ def test_convert_message_with_metadata(self):+ messages = [+ {+ "id": "test_id",+ "role": "user",+ "parts": [],+ "metadata": {"key": "value"},+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert result[0].metadata == {"key": "value"}++ def test_convert_message_without_metadata(self):+ messages = [+ {+ "id": "test_id",+ "role": "user",+ "parts": [],+ }+ ]+ result = convert_to_pydantic_messages(messages)+ assert result[0].metadata is None++ def test_convert_multiple_messages(self):+ messages = [+ {+ "messageId": "msg_1",+ "role": "user",+ "parts": [{"type": "text", "text": "Hello"}],+ },+ {+ "id": "msg_2",+ "role": "assistant",+ "parts": [{"type": "text", "text": "Hi!"}],+ },+ {+ "role": "user",+ "parts": [{"type": "text", "text": "How are you?"}],+ },+ ]+ result = convert_to_pydantic_messages(messages)+ assert len(result) == 3+ assert result[0].id == "msg_1"+ assert result[1].id == "msg_2"+ assert result[2].id.startswith("message_")++ def test_convert_with_part_processor(self):+ """Test that part_processor is called on each part."""+ from pydantic_ai.ui.vercel_ai.request_types import (+ TextUIPart,+ UIMessage,+ )++ call_count = 0++ def processor(part):+ nonlocal call_count+ call_count += 1+ # Modify the text+ if isinstance(part, TextUIPart):+ return TextUIPart(+ type="text",+ text=f"processed: {part.text}",+ state=part.state,+ provider_metadata=part.provider_metadata,+ )+ return part++ messages = [+ {+ "id": "msg_1",+ "role": "user",+ "parts": [+ {"type": "text", "text": "Hello"},+ {"type": "text", "text": "World"},+ ],+ }+ ]+ result = convert_to_pydantic_messages(+ messages, part_processor=processor+ )++ assert call_count == 2+ assert result == [+ UIMessage(+ id="msg_1",+ role="user",+ metadata=None,+ parts=[+ TextUIPart(+ type="text",+ text="processed: Hello",+ state=None,+ provider_metadata=None,+ ),+ TextUIPart(+ type="text",+ text="processed: World",+ state=None,+ provider_metadata=None,+ ),+ ],+ )+ ]++ def test_convert_with_part_processor_error_returns_original(self):+ """Test that part_processor errors are caught and original part is returned."""+ from pydantic_ai.ui.vercel_ai.request_types import (+ TextUIPart,+ UIMessage,+ )++ def failing_processor(_part):+ raise ValueError("Processing failed!")++ messages = [+ {+ "id": "msg_1",+ "role": "user",+ "parts": [{"type": "text", "text": "Hello"}],+ }+ ]+ result = convert_to_pydantic_messages(+ messages, part_processor=failing_processor+ )++ # Should return original part when processor fails+ assert result == [+ UIMessage(+ id="msg_1",+ role="user",+ metadata=None,+ parts=[+ TextUIPart(+ type="text",+ text="Hello",+ state=None,+ provider_metadata=None,+ )+ ],+ )+ ]++ def test_convert_with_part_processor_empty_parts(self):+ """Test that part_processor is not called when parts is empty."""+ call_count = 0++ def processor(_part):+ nonlocal call_count+ call_count += 1+ return _part++ messages = [+ {+ "id": "msg_1",+ "role": "user",+ "parts": [],+ }+ ]+ result = convert_to_pydantic_messages(+ messages, part_processor=processor+ )++ assert call_count == 0+ assert len(result) == 1+ assert result[0].parts == []++ def test_convert_with_part_processor_multiple_messages(self):+ """Test that part_processor is applied to all messages."""+ from pydantic_ai.ui.vercel_ai.request_types import TextUIPart++ processed_parts = []++ def processor(part):+ if isinstance(part, TextUIPart):+ processed_parts.append(part.text)+ return part++ messages = [+ {+ "id": "msg_1",+ "role": "user",+ "parts": [{"type": "text", "text": "First"}],+ },+ {+ "id": "msg_2",+ "role": "assistant",+ "parts": [{"type": "text", "text": "Second"}],+ },+ ]+ convert_to_pydantic_messages(messages, part_processor=processor)++ assert processed_parts == ["First", "Second"]+++class TestCreateSimplePrompt:+ def test_create_simple_prompt(self):+ from pydantic_ai.ui.vercel_ai.request_types import TextUIPart++ result = create_simple_prompt("Hello, world!")+ assert result.id.startswith("message_")+ assert result.role == "user"+ assert result.parts == [TextUIPart(type="text", text="Hello, world!")]++ def test_create_simple_prompt_with_empty_text(self):+ result = create_simple_prompt("")+ assert result.id.startswith("message_")+ assert result.role == "user"+ assert result.parts == []diff --git a/tests/_server/ai/test_providers.py b/tests/_server/ai/test_providers.pyindex 0edda283f9..b625e0ec6a 100644--- a/tests/_server/ai/test_providers.py+++ b/tests/_server/ai/test_providers.py@@ -6,6 +6,7 @@ import pytestfrom marimo._ai._types import ChatMessagefrom marimo._config.config import AiConfig+from marimo._dependencies.dependencies import Dependency, DependencyManagerfrom marimo._server.ai.config import AnyProviderConfigfrom marimo._server.ai.providers import (AnthropicProvider,@@ -60,23 +61,40 @@ def test_anyprovider_for_model(model_name: str, provider_name: str) -> None:@pytest.mark.parametrize(- ("model_name", "provider_type"),+ ("model_name", "provider_type", "dependency"),[- pytest.param("gpt-4", OpenAIProvider, id="openai"),+ pytest.param("gpt-4", OpenAIProvider, None, id="openai"),pytest.param(- "claude-3-opus-20240229", AnthropicProvider, id="anthropic"+ "claude-3-opus-20240229",+ AnthropicProvider,+ DependencyManager.anthropic,+ id="anthropic",+ ),+ pytest.param(+ "gemini-1.5-flash",+ GoogleProvider,+ DependencyManager.google_ai,+ id="google",),- pytest.param("gemini-1.5-flash", GoogleProvider, id="google"),pytest.param("bedrock/anthropic.claude-3-sonnet-20240229",BedrockProvider,+ None,id="bedrock",),- pytest.param("openrouter/gpt-4", OpenAIProvider, id="openrouter"),+ pytest.param(+ "openrouter/gpt-4", OpenAIProvider, None, id="openrouter"+ ),],)-def test_get_completion_provider(model_name: str, provider_type: type) -> None:+def test_get_completion_provider(+ model_name: str, provider_type: type, dependency: Dependency | None+) -> None:"""Test that the correct provider is returned for a given model."""++ if dependency and not dependency.has():+ pytest.skip(f"{dependency.pkg} is not installed")+config = AnyProviderConfig(api_key="test-key", base_url="http://test-url")provider = get_completion_provider(config, model_name)assert isinstance(provider, provider_type)@@ -199,26 +217,6 @@ def test_extract_content_with_none_tool_call_ids(assert result == [("Hello", "text")]-def test_google_extract_content_with_none_tool_call_ids() -> None:- """Test Google extract_content handles None tool_call_ids without errors."""- config = AnyProviderConfig(api_key="test-key", base_url="http://test")- provider = GoogleProvider("gemini-1.5-flash", config)-- mock_response = MagicMock()- mock_candidate = MagicMock()- mock_content = MagicMock()- mock_part = MagicMock()- mock_part.text = "Hello"- mock_part.thought = False- mock_part.function_call = None- mock_content.parts = [mock_part]- mock_candidate.content = mock_content- mock_response.candidates = [mock_candidate]-- result = provider.extract_content(mock_response, None)- assert result == [("Hello", "text")]--def test_openai_extract_content_multiple_tool_calls() -> None:"""Test OpenAI extracts multiple tool calls correctly."""config = AnyProviderConfig(api_key="test-key", base_url="http://test")@@ -258,68 +256,39 @@ def test_openai_extract_content_multiple_tool_calls() -> None:assert tool_data_1["toolName"] == "get_time"-def test_google_extract_content_id_rectification() -> None:- """Test Google uses provided tool_call_ids for ID rectification."""- config = AnyProviderConfig(api_key="test-key", base_url="http://test")- provider = GoogleProvider("gemini-1.5-flash", config)-- mock_response = MagicMock()- mock_candidate = MagicMock()- mock_content = MagicMock()- mock_func_call = MagicMock()- mock_func_call.name = "get_weather"- mock_func_call.args = {"location": "SF"}- mock_func_call.id = None- mock_part = MagicMock()- mock_part.text = None- mock_part.function_call = mock_func_call- mock_content.parts = [mock_part]- mock_candidate.content = mock_content- mock_response.candidates = [mock_candidate]-- result = provider.extract_content(mock_response, ["stable_id"])- assert result is not None- tool_data, _ = result[0]- assert isinstance(tool_data, dict)- assert tool_data["toolCallId"] == "stable_id"---def test_anthropic_extract_content_tool_call_id_mapping() -> None:- """Test Anthropic maps tool call IDs via block index."""- try:- from anthropic.types import (- InputJSONDelta,- RawContentBlockDeltaEvent,- RawContentBlockStartEvent,- ToolUseBlock,- )- except ImportError:- pytest.skip("Anthropic not installed")+ not DependencyManager.anthropic.has()+ or not DependencyManager.pydantic_ai.has(),+ reason="anthropic or pydantic_ai not installed",+)+def test_anthropic_process_part_text_file() -> None:+ """Test Anthropic converts text file parts to text parts."""+ from pydantic_ai.ui.vercel_ai.request_types import FileUIPart, TextUIPartconfig = AnyProviderConfig(api_key="test-key", base_url="http://test")provider = AnthropicProvider("claude-3-opus-20240229", config)- start_event = RawContentBlockStartEvent(- type="content_block_start",- index=0,- content_block=ToolUseBlock(- type="tool_use", id="toolu_123", name="get_weather", input={}- ),+ # Test text file conversion - base64 encoded "Hello, World!"+ text_file_part = FileUIPart(+ type="file",+ media_type="text/plain",+ url="data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==",+ filename="test.txt",)- provider.extract_content(start_event, None)-- delta_event = RawContentBlockDeltaEvent(- type="content_block_delta",- index=0,- delta=InputJSONDelta(- type="input_json_delta", partial_json='{"location": "SF"}'- ),+ result = provider.process_part(text_file_part)+ assert isinstance(result, TextUIPart)+ assert result.text == "Hello, World!"++ # Test image file is not converted+ image_file_part = FileUIPart(+ type="file",+ media_type="image/png",+ url="data:image/png;base64,iVBORw0KGgo=",+ filename="test.png",)- result = provider.extract_content(delta_event, None)- assert result is not None- tool_data, _ = result[0]- assert isinstance(tool_data, dict)- assert tool_data["toolCallId"] == "toolu_123"+ result = provider.process_part(image_file_part)+ assert isinstance(result, FileUIPart)+ assert result.media_type == "image/png"@pytest.mark.parametrize(diff --git a/tests/_server/api/endpoints/test_ai.py b/tests/_server/api/endpoints/test_ai.pyindex a45a438c6b..ce3093606a 100644--- a/tests/_server/api/endpoints/test_ai.py+++ b/tests/_server/api/endpoints/test_ai.py@@ -447,22 +447,20 @@ class TestAnthropicAiEndpoints:@staticmethod@with_session(SESSION_ID)- @patch("anthropic.AsyncClient")+ @patch(+ "marimo._server.ai.providers.AnthropicProvider.stream_text",+ return_value=AsyncMock(),+ )def test_anthropic_completion_with_code(- client: TestClient, anthropic_mock: Any+ client: TestClient, stream_text_mock: Any) -> None:user_config_manager = get_session_config_manager(client)- anthropic_client = MagicMock()- anthropic_mock.return_value = anthropic_client-- # Mock async stream+ # Mock async generator for stream_textasync def mock_stream():- yield RawContentBlockDeltaEvent(TextDelta("import pandas as pd"))+ yield "import pandas as pd"- anthropic_client.messages.create = AsyncMock(- side_effect=lambda **kwargs: mock_stream() # noqa: ARG005- )+ stream_text_mock.return_value = mock_stream()with patch.object(user_config_manager, "get_config", return_value=_anthropic_config()@@ -477,33 +475,25 @@ class TestAnthropicAiEndpoints:},)assert response.status_code == 200, response.text- # Assert the prompt it was called with- prompt: str = anthropic_client.messages.create.call_args.kwargs[- "messages"- ][0]["content"][0]["text"]- assert prompt == "Help me create a dataframe"- # Assert the model it was called with- model = anthropic_client.messages.create.call_args.kwargs["model"]- assert model == "claude-3.5"+ # Verify that stream_text was called+ stream_text_mock.assert_called_once()+ # Check the user_prompt parameter+ call_kwargs = stream_text_mock.call_args.kwargs+ assert call_kwargs["user_prompt"] == "Help me create a dataframe"@staticmethod@with_session(SESSION_ID)- @patch("anthropic.AsyncClient")+ @patch(+ "marimo._server.ai.providers.AnthropicProvider.completion",+ return_value=AsyncMock(),+ )def test_anthropic_inline_completion(- client: TestClient, anthropic_mock: Any+ client: TestClient, completion_mock: Any) -> None:user_config_manager = get_session_config_manager(client)- anthropic_client = MagicMock()- anthropic_mock.return_value = anthropic_client-- # Mock async stream- async def mock_stream():- yield RawContentBlockDeltaEvent(TextDelta("df = pd.DataFrame()"))-- anthropic_client.messages.create = AsyncMock(- side_effect=lambda **kwargs: mock_stream() # noqa: ARG005- )+ # Mock completion to return a string+ completion_mock.return_value = "df = pd.DataFrame()"with patch.object(user_config_manager, "get_config", return_value=_anthropic_config()@@ -518,17 +508,15 @@ class TestAnthropicAiEndpoints:},)assert response.status_code == 200, response.text- # Assert the prompt it was called with- prompt: str = anthropic_client.messages.create.call_args.kwargs[- "messages"- ][0]["content"][0]["text"]- assert (- prompt- == f"{FIM_PREFIX_TAG}import pandas as pd\n{FIM_SUFFIX_TAG}\ndf.head(){FIM_MIDDLE_TAG}"+ completion_mock.assert_called_once()+ call_kwargs = completion_mock.call_args.kwargs+ messages = call_kwargs["messages"]+ assert len(messages) == 1+ assert messages[0].parts[0].text == (+ f"{FIM_PREFIX_TAG}import pandas as pd\n"+ f"{FIM_SUFFIX_TAG}\ndf.head()"+ f"{FIM_MIDDLE_TAG}")- # Assert the model it was called with- model = anthropic_client.messages.create.call_args.kwargs["model"]- assert model == "claude-3.5-for-inline-completion"@pytest.mark.skipif(@@ -537,25 +525,20 @@ class TestAnthropicAiEndpoints:class TestGoogleAiEndpoints:@staticmethod@with_session(SESSION_ID)- @patch("google.genai.client.AsyncClient")+ @patch(+ "marimo._server.ai.providers.GoogleProvider.stream_text",+ return_value=AsyncMock(),+ )def test_google_ai_completion_with_code(- client: TestClient, google_ai_mock: Any+ client: TestClient, stream_text_mock: Any) -> None:user_config_manager = get_session_config_manager(client)- google_client = MagicMock()- google_ai_mock.return_value = google_client-- # Mock async stream+ # Mock async generator for stream_textasync def mock_stream():- yield MagicMock(- text="import pandas as pd",- thought=None,- )+ yield "import pandas as pd"- google_client.models.generate_content_stream = AsyncMock(- side_effect=lambda **kwargs: mock_stream() # noqa: ARG005- )+ stream_text_mock.return_value = mock_stream()config = {"ai": {@@ -580,40 +563,27 @@ class TestGoogleAiEndpoints:},)assert response.status_code == 200, response.text- # Assert the prompt it was called with- prompt = (- google_client.models.generate_content_stream.call_args.kwargs[- "contents"- ]- )- assert (- prompt[0]["parts"][0]["text"] == "Help me create a dataframe"- )+ # Verify that stream_text was called+ stream_text_mock.assert_called_once()+ # Check the user_prompt parameter+ call_kwargs = stream_text_mock.call_args.kwargs+ assert call_kwargs["user_prompt"] == "Help me create a dataframe"@staticmethod@with_session(SESSION_ID)- @patch("google.genai.Client")def test_google_ai_completion_without_token(- client: TestClient, google_ai_mock: Any+ client: TestClient,) -> None:- user_config_manager = get_session_config_manager(client)+ from marimo._server.ai.providers import PydanticProvider- # Mock the google client and its aio attribute- google_client_mock = MagicMock()- google_aio_mock = MagicMock()- google_client_mock.aio = google_aio_mock- google_ai_mock.return_value = google_client_mock+ user_config_manager = get_session_config_manager(client)- # Mock async stream+ # Mock async generator for stream_textasync def mock_stream():- yield MagicMock(- text="import pandas as pd",- thought=None,- )+ yield "import pandas as pd"- google_aio_mock.models.generate_content_stream = AsyncMock(- side_effect=lambda **kwargs: mock_stream() # noqa: ARG005- )+ mock_provider = MagicMock(spec=PydanticProvider)+ mock_provider.stream_text.return_value = mock_stream()config = {"ai": {@@ -622,8 +592,14 @@ class TestGoogleAiEndpoints:},}- with patch.object(- user_config_manager, "get_config", return_value=config+ with (+ patch.object(+ user_config_manager, "get_config", return_value=config+ ),+ patch(+ "marimo._server.api.endpoints.ai.get_completion_provider",+ return_value=mock_provider,+ ),):response = client.post("/api/ai/completion",@@ -636,34 +612,21 @@ class TestGoogleAiEndpoints:)assert response.status_code == 200, response.text- prompt = (- google_aio_mock.models.generate_content_stream.call_args.kwargs[- "contents"- ]- )- assert prompt[0]["parts"][0]["text"] == "Help me create a dataframe"+ # Verify that stream_text was called+ mock_provider.stream_text.assert_called_once()+ call_kwargs = mock_provider.stream_text.call_args.kwargs+ assert call_kwargs["user_prompt"] == "Help me create a dataframe"@staticmethod@with_session(SESSION_ID)- @patch("google.genai.client.AsyncClient")+ @patch("marimo._server.ai.providers.GoogleProvider.completion")def test_google_ai_inline_completion(- client: TestClient, google_ai_mock: Any+ client: TestClient, completion_mock: Any) -> None:user_config_manager = get_session_config_manager(client)- google_client = MagicMock()- google_ai_mock.return_value = google_client-- # Mock async stream- async def mock_stream():- yield MagicMock(- text="df = pd.DataFrame()",- thought=None,- )-- google_client.models.generate_content_stream = AsyncMock(- side_effect=lambda **kwargs: mock_stream() # noqa: ARG005- )+ # Mock completion to return a string+ completion_mock.return_value = "df = pd.DataFrame()"with patch.object(user_config_manager, "get_config", return_value=_google_ai_config()@@ -679,14 +642,14 @@ class TestGoogleAiEndpoints:)assert response.status_code == 200, response.text# Assert the prompt it was called with- prompt = (- google_client.models.generate_content_stream.call_args.kwargs[- "contents"- ]- )- assert (- prompt[0]["parts"][0]["text"]- == f"{FIM_PREFIX_TAG}import pandas as pd\n{FIM_SUFFIX_TAG}\ndf.head(){FIM_MIDDLE_TAG}"+ completion_mock.assert_called_once()+ call_kwargs = completion_mock.call_args.kwargs+ messages = call_kwargs["messages"]+ assert len(messages) == 1+ assert messages[0].parts[0].text == (+ f"{FIM_PREFIX_TAG}import pandas as pd\n"+ f"{FIM_SUFFIX_TAG}\ndf.head()"+ f"{FIM_MIDDLE_TAG}")@@ -808,6 +771,7 @@ def test_chat_without_code(client: TestClient) -> None:headers=HEADERS,json={"messages": _create_messages("Hello"),+ "uiMessages": [],"model": "gpt-4-turbo","variables": [],"includeOtherCode": "",@@ -849,6 +813,7 @@ def test_chat_with_code(client: TestClient) -> None:headers=HEADERS,json={"messages": _create_messages("Help me create a dataframe"),+ "uiMessages": [],"model": "gpt-4-turbo","variables": [],"includeOtherCode": "import pandas as pd",