Add domain-specific vocabulary definitions to ensure consistent understanding of terminology.
USAGE
PromptBuilder.vocabulary(terms)
The vocabulary method provides the AI with a professional glossary of terms specific to your domain, similar to what professionals use to maintain consistent understanding of specialized terminology. This helps ensure the AI correctly interprets domain-specific language and responds using appropriate terminology.
Parameters
terms:Union[VocabularyTerm, List[VocabularyTerm]]
Domain-specific terms with their definitions and optional synonyms. Can be a single VocabularyTerm or a list of VocabularyTerm items for batch addition.
Returns
PromptBuilder
Self for method chaining, allowing combination with other prompt building methods.
Research Foundation
Domain Knowledge Anchoring: Explicit vocabulary definitions help establish consistent domain context and prevent misinterpretation of specialized terminology that may have different meanings in general contexts.
Semantic Consistency: Providing clear definitions ensures the AI maintains consistent understanding of terms throughout the conversation, even when users employ synonyms or alternative phrasings.
Examples
Basic single term usage
This examples shows how to add a single vocabulary term to establish a domain context.
import talk_box as tbchurn_term = tb.VocabularyTerm( term="Customer Churn", definition=("Percentage of customers who stop using our service during a specific time period." ), synonyms=["attrition rate", "customer turnover", "subscription cancellation rate"])builder = ( tb.PromptBuilder() .persona("customer success manager") .vocabulary(churn_term) .task_context("Analyze customer retention patterns and improvement strategies"))print(builder)
You are a customer success manager.
TASK: Analyze customer retention patterns and improvement strategies
DOMAIN VOCABULARY:
- **Customer Churn**: Percentage of customers who stop using our service during a specific time
period. (Also: attrition rate, customer turnover, subscription cancellation rate)
Multilingual vocabulary for global operations
Here’s an example where we create an internationalized vocabulary with language-aware synonyms in the domain of global hotel management.
import talk_box as tbroom_types = [ tb.VocabularyTerm( term="Ocean View Room", definition="Premium rooms on floors 15-20 with direct Atlantic Ocean visibility.", synonyms=["seaside room", "beach view", "waterfront suite","es:habitación con vista al mar", "fr:chambre vue sur mer","de:Meerblickzimmer", "pt-BR:quarto vista oceano" ] ), tb.VocabularyTerm( term="Concierge Level", definition=("Exclusive access tier with dedicated concierge services and premium amenities" ), synonyms=["VIP services", "premium tier", "exclusive access","es:nivel concierge", "fr:niveau concierge", "de:Concierge-Service" ] )]builder = ( tb.PromptBuilder() .persona("multilingual hotel booking assistant") .vocabulary(room_types) .task_context("Assist international guests with room selections and amenities"))print(builder)
You are a multilingual hotel booking assistant.
TASK: Assist international guests with room selections and amenities
DOMAIN VOCABULARY:
- **Ocean View Room**: Premium rooms on floors 15-20 with direct Atlantic Ocean visibility. (Also:
seaside room, beach view, waterfront suite, de:Meerblickzimmer, es:habitación con vista al mar,
fr:chambre vue sur mer, pt-BR:quarto vista oceano)
- **Concierge Level**: Exclusive access tier with dedicated concierge services and premium amenities
(Also: VIP services, premium tier, exclusive access, de:Concierge-Service, es:nivel concierge,
fr:niveau concierge)
Healthcare domain vocabulary with translations
Define medical terminology with official translations (through the translations= attribute of VocabularyTerm) for international healthcare systems.
healthcare_vocab = [ tb.VocabularyTerm( term="Electronic Health Record", definition=("Digital version of patient medical history maintained by healthcare ""providers including diagnoses, medications, treatment plans, and test results." ), synonyms=["EHR", "electronic medical record", "EMR", "digital health record"], translations={"es": "Registro Médico Electrónico","fr": "Dossier Médical Électronique","de": "Elektronische Patientenakte","pt": "Registro Eletrônico de Saúde" } ), tb.VocabularyTerm( term="Clinical Decision Support", definition=("Health information technology that provides healthcare professionals with ""patient-specific assessments and evidence-based treatment recommendations" ), synonyms=["CDS", "decision support system", "clinical guidance system"], translations={"es": "Soporte de Decisiones Clínicas","fr": "Aide à la Décision Clinique","de": "Klinische Entscheidungsunterstützung","pt": "Apoio à Decisão Clínica" } ), tb.VocabularyTerm( term="Health Level Seven", definition=("International standard for exchanging healthcare information between ""different healthcare systems and applications." ), synonyms=["HL7", "healthcare interoperability standard", "medical data exchange protocol" ], translations={"es": "Nivel Siete de Salud","fr": "Niveau Sept Santé","de": "Gesundheitsstufe Sieben","pt": "Nível Sete de Saúde" } )]builder = ( tb.PromptBuilder() .persona("healthcare IT consultant", "medical informatics and system integration") .vocabulary(healthcare_vocab) .constraint("Maintain strict patient privacy and HIPAA compliance") .avoid_topics(["medical diagnosis", "treatment recommendations", "patient-specific medical advice" ]) .task_context("Design interoperable healthcare information systems"))print(builder)
You are a healthcare IT consultant with expertise in medical informatics and system integration.
CRITICAL REQUIREMENTS:
- Maintain strict patient privacy and HIPAA compliance
TASK: Design interoperable healthcare information systems
DOMAIN VOCABULARY:
- **Electronic Health Record**: Digital version of patient medical history maintained by healthcare
providers including diagnoses, medications, treatment plans, and test results. [Translations:
de:Elektronische Patientenakte, es:Registro Médico Electrónico, fr:Dossier Médical Électronique,
pt:Registro Eletrônico de Saúde] (Also: EHR, electronic medical record, EMR, digital health
record)
- **Clinical Decision Support**: Health information technology that provides healthcare
professionals with patient-specific assessments and evidence-based treatment recommendations
[Translations: de:Klinische Entscheidungsunterstützung, es:Soporte de Decisiones Clínicas, fr:Aide
à la Décision Clinique, pt:Apoio à Decisão Clínica] (Also: CDS, decision support system, clinical
guidance system)
- **Health Level Seven**: International standard for exchanging healthcare information between
different healthcare systems and applications. [Translations: de:Gesundheitsstufe Sieben, es:Nivel
Siete de Salud, fr:Niveau Sept Santé, pt:Nível Sete de Saúde] (Also: HL7, healthcare
interoperability standard, medical data exchange protocol)
ADDITIONAL CONSTRAINTS:
- IMPORTANT CONSTRAINT: You MUST NOT provide any information, advice, or discussion about medical
diagnosis, treatment recommendations, or patient-specific medical advice. If asked about any of
these topics, politely decline and redirect by saying something to the effect of 'I'm not able to
help with that topic. Is there something else I can assist you with instead?' (adapt the language
and phrasing to match the conversation's language and tone).
See Also
VocabularyTerm: Complete documentation for creating domain-specific terminology with multilingual support, translations, and comprehensive examples