Skip to content

Commit c5488c2

Browse files
Update user guide and examples in docs
1 parent b726a44 commit c5488c2

File tree

2 files changed

+55
-46
lines changed

2 files changed

+55
-46
lines changed

docs/examples/index.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,27 +283,27 @@ 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 Doctor, Patient
286+
from sdialog.personas import Mentor, Student
287287
from sdialog.generators import PersonaGenerator, ContextGenerator
288288
from sdialog import Context
289289
290-
doc_gen = PersonaGenerator(Doctor(specialty="Cardiology"))
291-
pat_gen = PersonaGenerator(Patient(symptoms="chest pain"))
290+
mentor_gen = PersonaGenerator(Mentor(role="math tutor"))
291+
student_gen = PersonaGenerator(Student(role="math student", interests="algebra"))
292292
293293
# Apply simple attribute rules (random range & list choices)
294-
doc_gen.set(years_of_experience="{5-15}")
295-
pat_gen.set(age="{35-70}")
294+
mentor_gen.set(years_of_experience="{5-15}")
295+
student_gen.set(age="{15-20}")
296296
297-
doctor = doc_gen.generate()
298-
patient = pat_gen.generate()
297+
mentor = mentor_gen.generate()
298+
student = student_gen.generate()
299299
300-
ctx_base = Context(location="Emergency room")
300+
ctx_base = Context(location="classroom")
301301
ctx_gen = ContextGenerator(ctx_base)
302-
ctx_gen.set(topics=["triage", "diagnosis", "stabilization"],
303-
goals="{llm:State one succinct medical goal}")
302+
ctx_gen.set(topics=["algebra", "problem solving", "study tips"],
303+
goals="{llm:State one succinct learning goal}")
304304
context = ctx_gen.generate()
305305
306-
doctor.print(); patient.print(); context.print()
306+
mentor.print(); student.print(); context.print()
307307
308308
Paraphrasing an Existing Dialog
309309
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/sdialog/index.rst

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,24 @@ Now that we understand how to create dialogs, let's explore the powerful operati
137137
138138
Personas & Context
139139
------------------
140+
140141
Personas are structured, typed attribute bundles that specify role, style, goals, background knowledge, and behavioral constraints used to condition LLM prompts for Agents in a reproducible, inspectable way. Context objects complement Personas with shared situational grounding so multiple agents can coordinate.
141142

142143
SDialog formalizes this socio-cognitive conditioning through attribute models:
143144

144145
- **Persona** / **ExtendedPersona** (:class:`~sdialog.personas.Persona`, :class:`~sdialog.personas.ExtendedPersona`): Baseline and expanded demographic + behavioral traits.
145-
- **Domain-specific Personas**: :class:`~sdialog.personas.Doctor`, :class:`~sdialog.personas.Patient`, :class:`~sdialog.personas.ExtendedDoctor`, :class:`~sdialog.personas.ExtendedPatient`, :class:`~sdialog.personas.Customer`, :class:`~sdialog.personas.SupportAgent`.
146-
- :class:`~sdialog.Context`: Shared situational grounding (location, environment, objects, goals, constraints, topics, style_guidelines, shared knowledge, circumstances).
146+
- **Domain-specific Personas**:
147+
148+
- **Customer Service**: :class:`~sdialog.personas.Customer`, :class:`~sdialog.personas.SupportAgent`
149+
- **Healthcare**: :class:`~sdialog.personas.Patient`, :class:`~sdialog.personas.ExtendedPatient`, :class:`~sdialog.personas.Doctor`, :class:`~sdialog.personas.ExtendedDoctor`, :class:`~sdialog.personas.Nurse`, :class:`~sdialog.personas.Pharmacist`, :class:`~sdialog.personas.Caregiver`
150+
- **Education**: :class:`~sdialog.personas.Teacher`, :class:`~sdialog.personas.Student`, :class:`~sdialog.personas.AcademicAdvisor`
151+
- **Finance**: :class:`~sdialog.personas.FinancialAdvisor`, :class:`~sdialog.personas.Banker`, :class:`~sdialog.personas.InsuranceAgent`
152+
- **Retail**: :class:`~sdialog.personas.StoreManager`, :class:`~sdialog.personas.SalesAssociate`, :class:`~sdialog.personas.Shopper`
153+
- **Travel/Hospitality**: :class:`~sdialog.personas.HotelReceptionist`, :class:`~sdialog.personas.TravelAgent`, :class:`~sdialog.personas.Tourist`
154+
- **Legal**: :class:`~sdialog.personas.Lawyer`, :class:`~sdialog.personas.Paralegal`, :class:`~sdialog.personas.LegalClient`
155+
- **Technical Support**: :class:`~sdialog.personas.ITSupportSpecialist`, :class:`~sdialog.personas.HelpdeskTechnician`, :class:`~sdialog.personas.EndUser`
156+
- **Government/Public Service**: :class:`~sdialog.personas.CivilServant`, :class:`~sdialog.personas.SocialWorker`, :class:`~sdialog.personas.Citizen`
157+
- **Food Service**: :class:`~sdialog.personas.Chef`, :class:`~sdialog.personas.Waiter`, :class:`~sdialog.personas.RestaurantCustomer`
147158

148159
All inherit :class:`~sdialog.base.BaseAttributeModel` and, as such, they support:
149160

@@ -381,62 +392,60 @@ Let's dive into one of SDialog's most powerful features! Attribute generators co
381392
Both generators derive from :class:`~sdialog.generators.base.BaseAttributeModelGenerator` and support flexible attribute generation rules:
382393

383394
**PersonaGenerator** (:class:`~sdialog.generators.PersonaGenerator`)
395+
384396
Creates diverse character profiles with demographic, behavioral, and professional attributes. Ideal for generating varied participants in dialogue scenarios.
385397

386-
Let's see how we can create sophisticated doctor personas where attributes intelligently depend on each other. In this example, we'll make the communication style adapt based on years of experience:
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:
387399

388400
.. code-block:: python
389401
390402
import random
391-
from sdialog.personas import Doctor
403+
from sdialog.personas import Mentor
392404
from sdialog.generators import PersonaGenerator
393405
394-
# Let's define a custom function to sample formality values based on experience
395-
# Your function can take any of the persona attributes as keyword arguments
396-
# In this case, we are interested in the years_of_experience attribute
397-
def get_random_formality(years_of_experience=None, **kwargs):
398-
# Base style on experience level
399-
if years_of_experience < 3:
400-
base_styles = ["enthusiastic", "eager to learn", "detailed"]
401-
elif years_of_experience < 10:
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:
402411
base_styles = ["confident", "professional", "clear"]
403412
else:
404413
base_styles = ["authoritative", "concise", "experienced"]
405414
return random.choice(base_styles)
406415
407-
# 1) Create a generator for doctor personas
408-
doctor_gen = PersonaGenerator(Doctor)
416+
# 1) Create a generator for mentor personas
417+
mentor_gen = PersonaGenerator(Mentor)
409418
410419
# 2) Setup generation with interdependent attributes
411-
doctor_gen.set(
412-
specialty=["cardiology", "neurology", "oncology"],
413-
years_of_experience="{2-25}",
414-
formality=get_random_formality, # Depends on experience
415-
hurriedness=["low", "medium", "high"]
420+
mentor_gen.set(
421+
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"]
416425
)
417426
418-
# 3) Generate diverse doctors with contextually appropriate communication styles
419-
doctor1 = doctor_gen.generate()
420-
doctor2 = doctor_gen.generate()
427+
# 3) Generate diverse mentors with contextually appropriate teaching styles
428+
mentor1 = mentor_gen.generate()
429+
mentor2 = mentor_gen.generate()
421430
422-
# 4) Let's generate 3 more doctors in one shot
423-
doctors_batch = doctor_gen.generate(n=3) # Returns list of 3 doctors
431+
# 4) Let's generate 3 more mentors in one shot
432+
mentors_batch = mentor_gen.generate(n=3) # Returns list of 3 mentors
424433
425434
**ContextGenerator** (:class:`~sdialog.generators.ContextGenerator`)
426435
Generates rich contextual frameworks that define the setting, environment, and situational constraints for dialogues. Essential for creating realistic and consistent conversation backgrounds.
427436

428-
Now let's create varied hospital contexts to set the stage for our medical conversations:
437+
Now let's create varied classroom contexts to set the stage for our educational conversations:
429438

430439
.. code-block:: python
431440
432441
from sdialog import Context
433442
from sdialog.generators import ContextGenerator
434443
435-
# Create varied hospital contexts
436-
ctx_gen = ContextGenerator(Context(location="hospital ward"))
444+
# Create varied classroom contexts
445+
ctx_gen = ContextGenerator(Context(location="classroom"))
437446
ctx_gen.set(
438-
environment="{llm:Describe a realistic medical environment}",
439-
constraints=["time pressure", "privacy concerns", "urgent case"]
447+
environment="{llm:Describe a realistic educational environment}",
448+
constraints=["time pressure", "distraction", "group activity"]
440449
)
441450
context = ctx_gen.generate()
442451
@@ -476,20 +485,20 @@ Now let's move on to creating complete conversations! Dialogue generators create
476485
**PersonaDialogGenerator** (:class:`~sdialog.generators.PersonaDialogGenerator`)
477486
Creates sophisticated dialogues by having two distinct personas or agents interact naturally. This generator produces more realistic and character-consistent conversations.
478487

479-
Here's how we can create a dialogue between a doctor and patient with their unique characteristics:
488+
Here's how we can create a dialogue between a mentor and student with their unique characteristics:
480489

481490
.. code-block:: python
482491
483-
from sdialog.personas import Doctor, Patient
492+
from sdialog.personas import Mentor, Student
484493
from sdialog.generators import PersonaDialogGenerator
485494
486-
doctor = Doctor(name="Dr. Smith", specialty="cardiology")
487-
patient = Patient(name="John", reason_for_visit="chest pain")
495+
mentor = Mentor(name="Ms. Lee", subject="mathematics")
496+
student = Student(name="Alex", learning_goal="understand algebra")
488497
489498
# Generate persona-driven dialogue
490499
gen = PersonaDialogGenerator(
491-
doctor, patient,
492-
dialogue_details="Discuss symptoms and initial diagnosis"
500+
mentor, student,
501+
dialogue_details="Discuss learning challenges and provide guidance"
493502
)
494503
495504
dialog = gen.generate()

0 commit comments

Comments
 (0)