diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 7956cbf6f21..b85c08428ef 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -19077,7 +19077,7 @@ snapshots: d3-timer: 3.0.1 vega-dataflow: 5.7.7 vega-format: 1.1.3 - vega-functions: 5.16.0 + vega-functions: 5.15.0 vega-runtime: 6.2.1 vega-scenegraph: 4.13.1 vega-util: 1.17.3 diff --git a/frontend/src/components/editor/chrome/panels/suggestions-panel.tsx b/frontend/src/components/editor/chrome/panels/suggestions-panel.tsx index 2e910f1e4cc..7a33b3e5904 100644 --- a/frontend/src/components/editor/chrome/panels/suggestions-panel.tsx +++ b/frontend/src/components/editor/chrome/panels/suggestions-panel.tsx @@ -35,7 +35,7 @@ export const SuggestionsPanel: React.FC = () => { }; return ( -
+
{suggestions.map((suggestion) => (
{ )} onClick={() => handleSuggestionClick(suggestion.title)} > -
- {suggestion.type === "prompt_warning" ? ( - - ) : ( - - )} -

{suggestion.title}

+
+
+ {suggestion.type === "prompt_warning" ? ( + + ) : ( + + )} +
+
+

{suggestion.title}

+

+ {suggestion.description} +

+
-

- {suggestion.description} -

))}
diff --git a/marimo/__init__.py b/marimo/__init__.py index d4f95c41c2e..7244b9b0764 100644 --- a/marimo/__init__.py +++ b/marimo/__init__.py @@ -83,7 +83,7 @@ "video", "vstack", ] -__version__ = "0.0.4" +__version__ = "0.0.5" import marimo._ai as ai import marimo._islands as islands diff --git a/marimo/_ai/agents.py b/marimo/_ai/agents.py index d47e27c0dc8..72a43d4755a 100644 --- a/marimo/_ai/agents.py +++ b/marimo/_ai/agents.py @@ -1,6 +1,8 @@ # Copyright 2024 Marimo. All rights reserved. from __future__ import annotations +import asyncio +import inspect import uuid from dataclasses import dataclass from enum import Enum @@ -49,6 +51,10 @@ class Agent: suggestions_fn: Optional[Callable[..., List[Suggestion]]] = None +def is_coroutine_function(fn: Callable[..., Any]) -> bool: + return asyncio.iscoroutinefunction(fn) or inspect.iscoroutinefunction(fn) + + @mddoc def register_agent(agent: Agent) -> None: """Register an LLM agent.""" @@ -69,7 +75,9 @@ async def run_agent(prompt: str, name: Optional[str] = None) -> Any: try: _registry = get_context().agent_registry agent = _registry.get_agent(name) - result = agent.run_fn(prompt) - return result + if is_coroutine_function(agent.run_fn): + return await agent.run_fn(prompt) + else: + return agent.run_fn(prompt) except ContextNotInitializedError: pass diff --git a/marimo/_runtime/agents.py b/marimo/_runtime/agents.py index d2ad3961fe6..b81cb0b17e5 100644 --- a/marimo/_runtime/agents.py +++ b/marimo/_runtime/agents.py @@ -25,7 +25,9 @@ def get_agent( raise ValueError(f"Agent name '{name}' is not registered.") return self._agents[name] else: - if len(self._agents) != 1: + if len(self._agents) == 0: + return None + elif len(self._agents) > 1: raise ValueError( "No agent name provided and multiple agents are registered." ) diff --git a/marimo/_runtime/runner/hooks_post_execution.py b/marimo/_runtime/runner/hooks_post_execution.py index 5f982d4604f..c852893e509 100644 --- a/marimo/_runtime/runner/hooks_post_execution.py +++ b/marimo/_runtime/runner/hooks_post_execution.py @@ -224,10 +224,8 @@ async def _broadcast_suggestions( return agent_name = cell.agent_name - suggestion_fn = ( - get_context().agent_registry.get_agent(agent_name).suggestions_fn - ) - if suggestion_fn is None: + agent = get_context().agent_registry.get_agent(agent_name) + if agent is None or agent.suggestions_fn is None: return async def _update_suggestions( @@ -236,7 +234,7 @@ async def _update_suggestions( suggestions = await suggestion_fn() Suggestions(suggestions=suggestions).broadcast() - asyncio.create_task(_update_suggestions(suggestion_fn)) + asyncio.create_task(_update_suggestions(agent.suggestions_fn)) @kernel_tracer.start_as_current_span("store_reference_to_output") diff --git a/openapi/api.yaml b/openapi/api.yaml index 5125a21837e..4ec9ff404f8 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -2182,7 +2182,7 @@ components: type: object info: title: marimo API - version: 0.0.1 + version: 0.0.5 openapi: 3.1.0 paths: /@file/{filename_and_length}: