Skip to content

Commit e0f44ad

Browse files
authored
Consecutive Analyses (#1274)
1 parent 3df92ca commit e0f44ad

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

lumen/ai/coordinator.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .utils import (
3737
fuse_messages, log_debug, mutate_user_message, stream_details,
3838
)
39-
from .views import LumenOutput
39+
from .views import AnalysisOutput, LumenOutput
4040

4141
if TYPE_CHECKING:
4242
from panel.chat.step import ChatStep
@@ -362,6 +362,13 @@ async def run_demo(event):
362362
async def _add_analysis_suggestions(self):
363363
pipeline = self._memory["pipeline"]
364364
current_analysis = self._memory.get("analysis")
365+
366+
# Clear current_analysis unless the last message is the same AnalysisOutput
367+
if current_analysis and self.interface.objects:
368+
last_message_obj = self.interface.objects[-1].object
369+
if not (isinstance(last_message_obj, AnalysisOutput) and last_message_obj.analysis is current_analysis):
370+
current_analysis = None
371+
365372
allow_consecutive = getattr(current_analysis, '_consecutive_calls', True)
366373
applicable_analyses = []
367374
for analysis in self._analyses:

lumen/ai/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ class AnalysisOutput(LumenOutput):
288288
def __init__(self, **params):
289289
if not params['analysis'].autorun:
290290
params['active'] = 0
291+
292+
# Set title based on analysis name if not provided
293+
if 'title' not in params or params['title'] is None:
294+
params['title'] = type(params['analysis']).__name__
295+
291296
super().__init__(**params)
292297
controls = self.analysis.controls()
293298
if controls is not None or not self.analysis.autorun:
@@ -310,7 +315,7 @@ def __init__(self, **params):
310315
)
311316
self._main.insert(1, ('Config', pn.Column(controls, run_button)))
312317
with discard_events(self):
313-
self._main.active = 1 if self.analysis.autorun else 0
318+
self._main.active = 0 if self.analysis.autorun else 1
314319
self._rendered = True
315320

316321
async def _rerun(self, event):
@@ -324,7 +329,7 @@ async def _rerun(self, event):
324329
spec = view.to_spec()
325330
self.param.update(
326331
spec=yaml.dump(spec),
327-
active=2
332+
active=0
328333
)
329334

330335

0 commit comments

Comments
 (0)