In-Context Learning Examples#
In-context learning examples allow you to provide the DecisionAI with specific examples of how to respond to certain types of prompts. These examples help guide the AI’s behavior and improve the quality of responses for your specific use case.
Overview#
When you deploy a model, DecisionAI can automatically load and sync in-context learning examples from XML files in a specified directory. These examples become part of the AI’s context and influence how it responds to user prompts during chat sessions.
Setting Up Examples#
Configure Examples Directory
When initializing your model, specify the directory containing your examples:
decision_ai init MODEL_NAME --examples-dir "path/to/examples"Or add it to your TOML configuration:
[tool.decision_ai.model.your_model_name] description = "Your model description" path = "your_model.py" class_name = "YourModelClass" examples_dir = "examples"
Create XML Example Files
Each example should be in a separate XML file with the following structure:
<example> <prompt>User's question or request</prompt> <how_to_proceed>AI's response methodology</how_to_proceed> </example>
Multiple
<example>elements per xml file are not supported. Create a new xml file for each example.
XML File Format#
Each XML file must contain exactly one <example> element with two required child elements:
<prompt>: The user’s question or request that triggers this example<how_to_proceed>: The AI’s detailed methodology for handling this type of request
Naming Convention#
Use descriptive filenames that indicate the example’s purpose
Example:
budget_constraints.xml,solve_model.xml,capacity_limits.xmlThe filename (without .xml extension) becomes the example’s name in the system
Directory Structure#
A typical project structure with examples:
my_project/
├── src/
│ └── my_model.py
├── examples/
│ ├── constraint_example.xml
│ ├── solve_example.xml
│ └── optimization_tips.xml
└── pyproject.toml