mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-07 16:09:30 +00:00
Track conversational flow turn usage in telemetry (#6324)
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Vulnerability Scan / pip-audit (push) Has been cancelled
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Vulnerability Scan / pip-audit (push) Has been cancelled
Build uv cache / build-cache (3.10) (push) Has been cancelled
Build uv cache / build-cache (3.11) (push) Has been cancelled
Build uv cache / build-cache (3.12) (push) Has been cancelled
Build uv cache / build-cache (3.13) (push) Has been cancelled
* Track conversational flow turn usage in telemetry * adjusted name to flow:conversation_turn * only mark on turn completed event * ensure tui also emits these events
This commit is contained in:
@@ -65,8 +65,12 @@ def _load_conversational_flow_from_kickoff_script() -> Any | None:
|
||||
|
||||
|
||||
def _run_conversational_flow_tui(flow: Any) -> Any:
|
||||
from crewai.events.event_listener import EventListener
|
||||
|
||||
from crewai_cli.crew_run_tui import CrewRunApp
|
||||
|
||||
EventListener() # ensures we get events from the TUI
|
||||
|
||||
app = CrewRunApp(
|
||||
crew_name=getattr(flow, "name", None) or type(flow).__name__,
|
||||
conversational=True,
|
||||
|
||||
@@ -61,3 +61,40 @@ def test_kickoff_flow_falls_back_to_uv_when_no_conversational_flow(
|
||||
kickoff_flow.kickoff_flow()
|
||||
|
||||
assert calls == [["uv", "run", "kickoff"]]
|
||||
|
||||
|
||||
def test_run_conversational_flow_tui_initializes_event_listener(monkeypatch) -> None:
|
||||
calls: list[str] = []
|
||||
|
||||
class FakeEventListener:
|
||||
def __init__(self) -> None:
|
||||
calls.append("listener")
|
||||
|
||||
class FakeCrewRunApp:
|
||||
def __init__(self, *, crew_name: str, conversational: bool) -> None:
|
||||
calls.append("app")
|
||||
self.crew_name = crew_name
|
||||
self.conversational = conversational
|
||||
self._status = "completed"
|
||||
self._crew_result = "done"
|
||||
self._flow = None
|
||||
|
||||
def run(self) -> None:
|
||||
calls.append("run")
|
||||
|
||||
class DemoFlow:
|
||||
name = "Demo"
|
||||
|
||||
monkeypatch.setattr(
|
||||
"crewai.events.event_listener.EventListener",
|
||||
FakeEventListener,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"crewai_cli.crew_run_tui.CrewRunApp",
|
||||
FakeCrewRunApp,
|
||||
)
|
||||
|
||||
result = kickoff_flow._run_conversational_flow_tui(DemoFlow())
|
||||
|
||||
assert result == "done"
|
||||
assert calls == ["listener", "app", "run"]
|
||||
|
||||
Reference in New Issue
Block a user