You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
و`RouterConfig` و`ConversationState` والرسم المدمج) ضمن
12
-
`crewai.experimental`، وقد يتغير قبل أن يصبح مستقراً. ثبّت إصدار CrewAI
13
-
إذا كنت تعتمد على سلوك محدد.
14
-
</Warning>
15
-
16
8
## نظرة عامة
17
9
18
10
تعامل التطبيقات المحادثية مع كل سطر من المستخدم كـ **تشغيل flow جديد** بنفس **معرّف الجلسة**. توفر CrewAI مساعدات لسجل الرسائل، وتوجيه النية الاختياري، وتأجيل التتبع، والبث المنظّم للجولات، إضافة إلى REPL محلي عبر `flow.chat()`.
@@ -48,7 +40,7 @@ from uuid import uuid4
48
40
49
41
from crewai import Flow
50
42
from crewai.flow import listen
51
-
from crewai.experimental.conversationalimport (
43
+
from crewai.flowimport (
52
44
ConversationConfig,
53
45
ConversationState,
54
46
)
@@ -129,7 +121,7 @@ result = stream.result
129
121
130
122
## مساعدات `ChatState` منخفضة المستوى
131
123
132
-
تظل `ChatState` و`ConversationalConfig` القديمة ومساعدات `crewai.flow.conversation` قابلة للاستيراد للتنسيق المتقدم أو الاختبارات أو الأغلفة المخصصة. وهي منفصلة عن واجهتي `ConversationState` / `ConversationConfig` التجريبيتين، ولا تضيف وسيطي `user_message=` أو `session_id=` إلى `Flow.kickoff()`.
124
+
تظل `ChatState` و`ConversationalConfig` القديمة ومساعدات `crewai.flow.conversation` قابلة للاستيراد للتنسيق المتقدم أو الاختبارات أو الأغلفة المخصصة. وهي منفصلة عن واجهتي `ConversationState` / `ConversationConfig`، ولا تضيف وسيطي `user_message=` أو `session_id=` إلى `Flow.kickoff()`.
133
125
134
126
```python
135
127
from crewai.flow import ChatState
@@ -151,7 +143,7 @@ class MyChatState(ChatState):
151
143
152
144
`ConversationalInputs` هو `TypedDict` لمفاتيح `kickoff(inputs={...})` الاصطلاحية: `id` و`user_message` و`last_intent`.
153
145
154
-
تخزن `ConversationState`التجريبية`messages` ككائنات `ConversationMessage`، وتوفر أيضاً `current_user_message` و`ended` و`events` و`agent_threads`. استخدم `conversation_messages` عند تمرير سجلها القانوني إلى LLM.
146
+
تخزن `ConversationState`رسائل`messages` ككائنات `ConversationMessage`، وتوفر أيضاً `current_user_message` و`ended` و`events` و`agent_threads`. استخدم `conversation_messages` عند تمرير سجلها القانوني إلى LLM.
155
147
156
148
## API المحادثة على `Flow`
157
149
@@ -193,7 +185,7 @@ class MyChatState(ChatState):
193
185
194
186
### مساعدات الوحدة (`crewai.flow.conversation`)
195
187
196
-
يمكن استيرادها من `crewai.flow.conversation` للاختبارات أو التنسيق المخصص. تستخدم هذه المساعدات بنية `ConversationalConfig` القديمة؛ كما تمسح `prepare_conversational_turn()` قيمة `last_intent`، بخلاف `handle_turn()`التجريبية التي تحتفظ بها كسياق للموجّه.
188
+
يمكن استيرادها من `crewai.flow.conversation` للاختبارات أو التنسيق المخصص. تستخدم هذه المساعدات بنية `ConversationalConfig` القديمة؛ كما تمسح `prepare_conversational_turn()` قيمة `last_intent`، بخلاف `handle_turn()` التي تحتفظ بها كسياق للموجّه.
يستخدم [`Flow` المحادثاتي](#flow-المحادثاتي-تجريبي) التجريبي دورة حياة التتبع نفسها: القيمة الافتراضية لـ `defer_trace_finalization` هي `True`، ولذلك يبقي كل `handle_turn()` trace الجلسة مفتوحاً. تمنع الجولات المؤجلة أيضاً إصدار `flow_failed` لكل جولة؛ وعند حدوث خطأ في جولة أو إلغاء الجلسة، أنهِ الجلسة صراحةً. يغلق ذلك الدفعة بحدث `FlowFinished` على مستوى الجلسة بدلاً من حدث `FlowFailed` لكل جولة. لُف REPL/الحلقة دائماً بـ `try/finally` واستدعِ `flow.finalize_session_traces()` عند الخروج. بدون ذلك، تبقى دفعة trace مفتوحة وقد لا تُصدَّر المحادثة النهائية أبداً.
575
+
يستخدم [`Flow` المحادثاتي](#flow-المحادثاتي) دورة حياة التتبع نفسها: القيمة الافتراضية لـ `defer_trace_finalization` هي `True`، ولذلك يبقي كل `handle_turn()` trace الجلسة مفتوحاً. تمنع الجولات المؤجلة أيضاً إصدار `flow_failed` لكل جولة؛ وعند حدوث خطأ في جولة أو إلغاء الجلسة، أنهِ الجلسة صراحةً. يغلق ذلك الدفعة بحدث `FlowFinished` على مستوى الجلسة بدلاً من حدث `FlowFailed` لكل جولة. لُف REPL/الحلقة دائماً بـ `try/finally` واستدعِ `flow.finalize_session_traces()` عند الخروج. بدون ذلك، تبقى دفعة trace مفتوحة وقد لا تُصدَّر المحادثة النهائية أبداً.
584
576
585
577
## البث
586
578
@@ -613,7 +605,7 @@ from crewai.flow import (
613
605
start,
614
606
)
615
607
from crewai.flow.conversation import prepare_conversational_turn
`RouterConfig`, `ConversationState`, and the built-in graph) lives under
12
-
`crewai.experimental` and may change before it graduates. Pin your CrewAI
13
-
version if you depend on specific behavior.
14
-
</Warning>
15
-
16
8
## Overview
17
9
18
10
Conversational apps treat each user line as a **new flow run** with the **same session id**. CrewAI adds helpers for message history, optional intent routing, deferred tracing, structured turn streaming, and a local `flow.chat()` REPL.
@@ -48,7 +40,7 @@ from uuid import uuid4
48
40
49
41
from crewai import Flow
50
42
from crewai.flow import listen
51
-
from crewai.experimental.conversationalimport (
43
+
from crewai.flowimport (
52
44
ConversationConfig,
53
45
ConversationState,
54
46
)
@@ -129,7 +121,7 @@ Decorating a `Flow` subclass with `ConversationConfig` both attaches the chat de
129
121
130
122
## Lower-level `ChatState` helpers
131
123
132
-
`ChatState`, the legacy `ConversationalConfig`, and `crewai.flow.conversation` helpers are still importable for advanced orchestration, tests, or custom wrappers. They are separate from the experimental `ConversationState` / `ConversationConfig` API and do not add `user_message=` or `session_id=` keyword arguments to `Flow.kickoff()`.
124
+
`ChatState`, the legacy `ConversationalConfig`, and `crewai.flow.conversation` helpers are still importable for advanced orchestration, tests, or custom wrappers. They are separate from the `ConversationState` / `ConversationConfig` API and do not add `user_message=` or `session_id=` keyword arguments to `Flow.kickoff()`.
133
125
134
126
```python
135
127
from crewai.flow import ChatState
@@ -151,7 +143,7 @@ class MyChatState(ChatState):
151
143
152
144
`ConversationalInputs` is a `TypedDict` for conventional `kickoff(inputs={...})` keys: `id`, `user_message`, `last_intent`.
153
145
154
-
The experimental `ConversationState` stores `messages` as `ConversationMessage` objects and additionally provides `current_user_message`, `ended`, `events`, and `agent_threads`. Use `conversation_messages` when passing its canonical history to an LLM.
146
+
`ConversationState` stores `messages` as `ConversationMessage` objects and additionally provides `current_user_message`, `ended`, `events`, and `agent_threads`. Use `conversation_messages` when passing its canonical history to an LLM.
155
147
156
148
## `Flow` conversational API
157
149
@@ -193,7 +185,7 @@ The experimental `ConversationState` stores `messages` as `ConversationMessage`
193
185
194
186
### Module helpers (`crewai.flow.conversation`)
195
187
196
-
Importable from `crewai.flow.conversation` for tests or custom orchestration. These helpers use the legacy `ConversationalConfig` shape; `prepare_conversational_turn()` also clears `last_intent`, unlike experimental `handle_turn()`, which preserves it as router context.
188
+
Importable from `crewai.flow.conversation` for tests or custom orchestration. These helpers use the legacy `ConversationalConfig` shape; `prepare_conversational_turn()` also clears `last_intent`, unlike `handle_turn()`, which preserves it as router context.
197
189
198
190
| Function | Description |
199
191
|----------|-------------|
@@ -237,7 +229,7 @@ Each `handle_turn()` completes one graph run, and the conversation continues wit
237
229
238
230
Do **not** use `@human_feedback` for follow-up chat lines unless a human must approve a specific step output before it is shown.
239
231
240
-
## Conversational `Flow` (experimental)
232
+
## Conversational `Flow`
241
233
242
234
Opt into the conversational chat graph by setting `conversational = True` on a `Flow` subclass or applying `@ConversationConfig(...)`. The base `Flow` then supplies `route_conversation` as the built-in start/router plus the `converse_turn` and `end_conversation` listeners. The deprecated `answer_from_history_turn` listener remains available for compatibility. The framework manages `state.messages`, can drive a router LLM, and keeps the trace batch open across turns. You write the **custom routes**; the framework owns the rest.
243
235
@@ -248,7 +240,7 @@ Use this when you want a multi-turn chat with a router and per-route handlers wi
248
240
```python
249
241
from crewai import Flow
250
242
from crewai.flow import listen
251
-
from crewai.experimental.conversationalimport (
243
+
from crewai.flowimport (
252
244
ConversationConfig,
253
245
ConversationState,
254
246
)
@@ -333,7 +325,7 @@ from typing import Literal
333
325
from pydantic import BaseModel
334
326
335
327
from crewai importLLM
336
-
from crewai.experimental.conversationalimport RouterConfig
328
+
from crewai.flowimport RouterConfig
337
329
338
330
339
331
classMyRoute(BaseModel):
@@ -471,7 +463,7 @@ To run side effects (event bus setup, telemetry) on every routing decision, over
471
463
from typing import Any
472
464
473
465
from crewai import Flow
474
-
from crewai.experimental.conversationalimport ConversationState
466
+
from crewai.flowimport ConversationState
475
467
476
468
477
469
classSupportFlow(Flow[ConversationState]):
@@ -581,7 +573,7 @@ the session ends.
581
573
582
574
### Conversational `Flow` trace lifecycle
583
575
584
-
The experimental [conversational `Flow`](#conversational-flow-experimental) uses the same tracing lifecycle: `defer_trace_finalization` defaults to `True`, so each `handle_turn()` keeps the session trace open. Deferred turns also suppress per-turn `flow_failed`; on a turn error or session abort, finalize the session explicitly. This closes the batch with the session-level `FlowFinished` event rather than a per-turn `FlowFailed` event. Always wrap your REPL/loop in `try/finally` and call `flow.finalize_session_traces()` on exit. Without it, the trace batch stays open and the final conversation may never export.
576
+
The [conversational `Flow`](#conversational-flow) uses the same tracing lifecycle: `defer_trace_finalization` defaults to `True`, so each `handle_turn()` keeps the session trace open. Deferred turns also suppress per-turn `flow_failed`; on a turn error or session abort, finalize the session explicitly. This closes the batch with the session-level `FlowFinished` event rather than a per-turn `FlowFailed` event. Always wrap your REPL/loop in `try/finally` and call `flow.finalize_session_traces()` on exit. Without it, the trace batch stays open and the final conversation may never export.
585
577
586
578
## Streaming
587
579
@@ -614,7 +606,7 @@ from crewai.flow import (
614
606
start,
615
607
)
616
608
from crewai.flow.conversation import prepare_conversational_turn
0 commit comments