Skip to content

Commit 2151209

Browse files
Release v0.4.4
1 parent c5488c2 commit 2151209

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

docs/examples/index.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,19 @@ Let's dive into creating diverse characters and settings! We'll see how to use :
283283

284284
.. code-block:: python
285285
286-
from sdialog.personas import Mentor, Student
286+
from sdialog.personas import Teacher, Student
287287
from sdialog.generators import PersonaGenerator, ContextGenerator
288288
from sdialog import Context
289289
290-
mentor_gen = PersonaGenerator(Mentor(role="math tutor"))
291-
student_gen = PersonaGenerator(Student(role="math student", interests="algebra"))
290+
# Teacher and Student are real persona classes
291+
teacher_gen = PersonaGenerator(Teacher(subject="mathematics"))
292+
student_gen = PersonaGenerator(Student(interests="algebra"))
292293
293294
# Apply simple attribute rules (random range & list choices)
294-
mentor_gen.set(years_of_experience="{5-15}")
295+
teacher_gen.set(years_experience="{5-15}", politeness=["polite", "neutral", "strict"])
295296
student_gen.set(age="{15-20}")
296297
297-
mentor = mentor_gen.generate()
298+
teacher = teacher_gen.generate()
298299
student = student_gen.generate()
299300
300301
ctx_base = Context(location="classroom")
@@ -303,7 +304,7 @@ Let's dive into creating diverse characters and settings! We'll see how to use :
303304
goals="{llm:State one succinct learning goal}")
304305
context = ctx_gen.generate()
305306
306-
mentor.print(); student.print(); context.print()
307+
teacher.print(); student.print(); context.print()
307308
308309
Paraphrasing an Existing Dialog
309310
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/sdialog/index.rst

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -395,41 +395,38 @@ Both generators derive from :class:`~sdialog.generators.base.BaseAttributeModelG
395395

396396
Creates diverse character profiles with demographic, behavioral, and professional attributes. Ideal for generating varied participants in dialogue scenarios.
397397

398-
Let's see how we can create sophisticated mentor personas where attributes intelligently depend on each other. In this example, we'll make the communication style adapt based on years of teaching experience:
398+
Let's see how we can create teacher personas using only attributes defined in personas.py. For example, we can generate teachers with different subjects and years of experience:
399399

400400
.. code-block:: python
401401
402402
import random
403-
from sdialog.personas import Mentor
403+
from sdialog.personas import Teacher
404404
from sdialog.generators import PersonaGenerator
405405
406-
# Let's define a custom function to sample teaching style values based on experience
407-
def get_random_teaching_style(years_of_teaching=None, **kwargs):
408-
if years_of_teaching < 3:
409-
base_styles = ["enthusiastic", "supportive", "detailed"]
410-
elif years_of_teaching < 10:
411-
base_styles = ["confident", "professional", "clear"]
412-
else:
413-
base_styles = ["authoritative", "concise", "experienced"]
414-
return random.choice(base_styles)
406+
# Define a custom function to sample communication style based on years of experience
407+
def get_communication_style(years_experience=None, **kwargs):
408+
# Example: simple mapping for demonstration
409+
if not years_experience:
410+
return "clear"
411+
return "enthusiastic" if years_experience < 10 else "authoritative"
415412
416-
# 1) Create a generator for mentor personas
417-
mentor_gen = PersonaGenerator(Mentor)
413+
# 1) Create a generator for teacher personas
414+
teacher_gen = PersonaGenerator(Teacher)
418415
419416
# 2) Setup generation with interdependent attributes
420-
mentor_gen.set(
417+
teacher_gen.set(
421418
subject=["mathematics", "history", "biology"],
422-
years_of_teaching="{2-25}",
423-
teaching_style=get_random_teaching_style, # Depends on experience
424-
patience=["low", "medium", "high"]
419+
years_experience="{2-25}",
420+
communication_style=get_communication_style, # Depends on years_experience
421+
politeness=["polite", "neutral", "strict"]
425422
)
426423
427-
# 3) Generate diverse mentors with contextually appropriate teaching styles
428-
mentor1 = mentor_gen.generate()
429-
mentor2 = mentor_gen.generate()
424+
# 3) Generate diverse teachers with contextually appropriate communication styles
425+
teacher1 = teacher_gen.generate()
426+
teacher2 = teacher_gen.generate()
430427
431-
# 4) Let's generate 3 more mentors in one shot
432-
mentors_batch = mentor_gen.generate(n=3) # Returns list of 3 mentors
428+
# 4) Let's generate 3 more teachers in one shot
429+
teachers_batch = teacher_gen.generate(n=3) # Returns list of 3 teachers
433430
434431
**ContextGenerator** (:class:`~sdialog.generators.ContextGenerator`)
435432
Generates rich contextual frameworks that define the setting, environment, and situational constraints for dialogues. Essential for creating realistic and consistent conversation backgrounds.
@@ -489,18 +486,18 @@ Now let's move on to creating complete conversations! Dialogue generators create
489486

490487
.. code-block:: python
491488
492-
from sdialog.personas import Mentor, Student
489+
from sdialog.personas import Teacher, Student
493490
from sdialog.generators import PersonaDialogGenerator
494491
495-
mentor = Mentor(name="Ms. Lee", subject="mathematics")
496-
student = Student(name="Alex", learning_goal="understand algebra")
492+
teacher = Teacher(name="Ms. Lee", subject="mathematics")
493+
student = Student(name="Alex", interests="algebra")
497494
498495
# Generate persona-driven dialogue
499496
gen = PersonaDialogGenerator(
500-
mentor, student,
497+
teacher, student,
501498
dialogue_details="Discuss learning challenges and provide guidance"
502499
)
503-
500+
504501
dialog = gen.generate()
505502
dialog.print()
506503

src/sdialog/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
logger = logging.getLogger(__name__)
3838

39-
__version__ = "0.4.3"
39+
__version__ = "0.4.4"
4040

4141

4242
def _get_dynamic_version() -> str:

0 commit comments

Comments
 (0)