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
- Standard Dialog schema with JSON import/export _(aiming to help standardize dialog datasets with community support)_
17
+
- Standard [Dialog](https://sdialog.readthedocs.io/en/latest/sdialog/index.html#dialog) schema with JSON import/export _(aiming to help standardize dialog datasets with community support)_
18
18
- Persona‑driven multi‑agent simulation with contexts, tools, and thoughts
19
19
- Composable orchestration for precise control over behavior and flow
20
20
- Built‑in evaluation (metrics + LLM‑as‑judge) for comparison and iteration
Instead of creating the Dialog object programmatically as above, you can also load it from text files or strings using a simple template format with :meth:`~sdialog.Dialog.from_file` or :meth:`~sdialog.Dialog.from_str` methods, respectively.
55
+
Dialog objects can be created programmatically or you can simply created from plain text, either a string or txt file, using :meth:`~sdialog.Dialog.from_str` or :meth:`~sdialog.Dialog.from_file` methods, respectively.
87
56
Both methods accept the same arguments and ``Dialog.from_str(text)`` is equivalent to ``Dialog.from_file("file.txt")`` when the file contains plain text.
88
-
The most common cases are shown below with three examples:
89
-
90
-
**Creating Dialog from Text**:
57
+
Below it is shown examples of three typical use cases:
91
58
92
59
.. code-block:: python
93
60
94
61
from sdialog import Dialog, Turn
95
62
96
-
# Basic usage - Text in default "{speaker}: {text}" format
63
+
#1) Basic usage - Text in default "{speaker}: {text}" format
97
64
dialog_text ="""Alice: Hello there! How are you today?
98
65
Bob: I'm doing great, thanks for asking.
99
66
Alice: That's wonderful to hear!
@@ -102,7 +69,7 @@ The most common cases are shown below with three examples:
[2024-01-15 14:31] @moderator: Welcome to the chat
108
75
[2024-01-15 14:32] @user123: Thanks, excited to be here!
@@ -115,7 +82,7 @@ The most common cases are shown below with three examples:
115
82
)
116
83
dialog_from_chat.print()
117
84
118
-
# Text with no speaker tags
85
+
#3) Text with no speaker tags
119
86
simple_conversation ="""Hello there!
120
87
Hi, how are you?
121
88
I'm doing well, thanks!
@@ -129,6 +96,44 @@ The most common cases are shown below with three examples:
129
96
)
130
97
dialog_with_defaults.print()
131
98
99
+
**Operations Example**:
100
+
101
+
Below is a compact walkthrough demonstrating common Dialog manipulations—creating a dialog programmatically, slicing (which preserves lineage), chaining text transformations, selective speaker filtering, speaker renaming, length/statistics queries, and safe iteration over derived copies.
102
+
103
+
.. code-block:: python
104
+
105
+
from sdialog import Dialog, Turn
106
+
107
+
# Let's first create a sample dialog programatically
108
+
dialog = Dialog(turns=[
109
+
Turn(speaker="Alice", text="Hello there! How are you doing today?"),
110
+
Turn(speaker="Bob", text="I'm doing great, thanks for asking."),
111
+
Turn(speaker="Alice", text="That's wonderful to hear!"),
112
+
Turn(speaker="Bob", text="What about you? How's YOUR DAY going?")
113
+
])
114
+
115
+
# Slicing creates new Dialog with fresh ID and parentId linkage
116
+
first_half = dialog[:2] # First 2 turns → new Dialog with dialog.id as parentId
0 commit comments