Skip to content

Commit 96de85b

Browse files
committed
Release 0.1.2: Added DungeonMaster template and complex test suite
1 parent 8af5d6a commit 96de85b

File tree

9 files changed

+671
-53
lines changed

9 files changed

+671
-53
lines changed

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Changelog
22

3+
## [0.1.2] - 2024-03-19
4+
5+
### Added
6+
- New DungeonMaster template for RPG scenario generation
7+
- Comprehensive test suite for complex template features
8+
- Support for nested object handling in templates
9+
- Enhanced template validation for complex data structures
10+
11+
### Fixed
12+
- Fixed custom_data handling in templates
13+
- Improved test coverage for complex scenarios
14+
- Updated template validation for optional fields
15+
16+
## [0.1.1] - 2024-01-20
17+
18+
### Added
19+
- Enhanced schema validation with warning system for missing fields
20+
- Support for optional fields with default values
21+
- Improved handling of nested fields in templates
22+
- Added comprehensive test fixtures and test configuration
23+
24+
### Changed
25+
- Schema validation now warns instead of failing for missing required fields
26+
- Optional fields are now initialized with appropriate default values
27+
- Improved test environment setup with proper fixtures handling
28+
29+
### Fixed
30+
- Fixed issue with template rendering for undefined optional fields
31+
- Fixed handling of custom_data and nested fields
32+
- Fixed test environment cleanup and prompts.json handling
33+
334
## [0.1.0] - 2024-01-19
435

536
### Added

examples/basic_usage.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def main():
1818
issue_type="password reset",
1919
technical_level="intermediate",
2020
interaction_history="2 previous tickets about 2FA setup",
21-
product_version="2.1.0"
21+
product_version="2.1.0",
22+
issue_description="User is unable to reset their password after multiple attempts",
23+
custom_data={"product_version": "2.1.0", "subscription_tier": "standard"}
2224
)
2325
print(support_prompt)
2426
print("\n" + "-"*50 + "\n")
@@ -32,7 +34,9 @@ def main():
3234
issue_type="password reset",
3335
technical_level="intermediate",
3436
interaction_history="2 previous tickets about 2FA setup",
35-
product_version="2.1.0"
37+
product_version="2.1.0",
38+
issue_description="User is unable to reset their password after multiple attempts",
39+
custom_data={"product_version": "2.1.0", "subscription_tier": "standard"}
3640
)
3741
print(support_prompt_v1)
3842
print("\n" + "-"*50 + "\n")

examples/complex_usage.py

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
"""
2+
Advanced template usage example for Promptix library.
3+
4+
This example demonstrates advanced templating features:
5+
1. Conditional blocks (if/else/elif)
6+
2. Loops and list handling (for loops)
7+
3. Nested conditional logic
8+
4. Numeric comparisons
9+
5. Dynamic content generation
10+
6. Custom data structures
11+
"""
12+
13+
from typing import Any, Dict, List, Optional
14+
15+
from promptix import Promptix
16+
17+
18+
def generate_rpg_scenario(
19+
game_style: str,
20+
party_level: int,
21+
party_classes: List[str],
22+
environment: str,
23+
quest_type: str,
24+
difficulty: str,
25+
magical_elements: Optional[List[str]] = None,
26+
environment_details: Optional[Dict[str, Any]] = None,
27+
special_conditions: Optional[List[str]] = None,
28+
) -> str:
29+
"""
30+
Generate a dynamic RPG scenario using advanced template features.
31+
"""
32+
env_details = environment_details or {}
33+
34+
context = {
35+
"game_style": game_style,
36+
"party_level": party_level,
37+
"party_classes": party_classes,
38+
"environment": environment,
39+
"quest_type": quest_type,
40+
"difficulty": difficulty,
41+
"magical_elements": magical_elements,
42+
# environment-specific flags
43+
"has_traps": env_details.get("has_traps", False),
44+
"has_crime": env_details.get("has_crime", False),
45+
"has_monsters": env_details.get("has_monsters", False),
46+
# environment details
47+
"city_type": env_details.get("city_type", "medieval"),
48+
"atmosphere": env_details.get("atmosphere", "mysterious"),
49+
"terrain_type": env_details.get("terrain_type", "forest"),
50+
# special conditions in custom data
51+
"custom_data": {"special_conditions": special_conditions} if special_conditions else {},
52+
}
53+
54+
return Promptix.get_prompt(prompt_template="DungeonMaster", **context)
55+
56+
def main():
57+
print("Advanced Template Usage Examples\n")
58+
59+
# Example 1: Beginner dungeon crawl
60+
print("\nExample 1: Beginner Dungeon Crawl")
61+
print("-" * 50)
62+
prompt1 = generate_rpg_scenario(
63+
game_style="heroic",
64+
party_level=3,
65+
party_classes=["Warrior", "Cleric", "Rogue"],
66+
environment="dungeon",
67+
quest_type="combat",
68+
difficulty="easy",
69+
environment_details={"has_traps": True},
70+
magical_elements=["Ancient Runes", "Magical Barriers"],
71+
)
72+
print(prompt1)
73+
74+
# Example 2: Complex city intrigue
75+
print("\nExample 2: Complex City Intrigue")
76+
print("-" * 50)
77+
prompt2 = generate_rpg_scenario(
78+
game_style="mystery",
79+
party_level=8,
80+
party_classes=["Bard", "Rogue", "Wizard", "Paladin"],
81+
environment="city",
82+
quest_type="diplomacy",
83+
difficulty="hard",
84+
environment_details={
85+
"has_crime": True,
86+
"city_type": "merchant",
87+
"atmosphere": "tense",
88+
},
89+
magical_elements=["Dark Magic", "Illusion Magic", "Forbidden Arts"],
90+
special_conditions=[
91+
"Political uprising imminent",
92+
"Hidden cult influence",
93+
"Corrupt city guard",
94+
],
95+
)
96+
print(prompt2)
97+
98+
# Example 3: Epic wilderness adventure
99+
print("\nExample 3: Epic Wilderness Adventure")
100+
print("-" * 50)
101+
prompt3 = generate_rpg_scenario(
102+
game_style="epic",
103+
party_level=15,
104+
party_classes=["Druid", "Ranger", "Barbarian", "Shaman"],
105+
environment="wilderness",
106+
quest_type="mystery",
107+
difficulty="medium",
108+
environment_details={"has_monsters": True, "terrain_type": "mountain"},
109+
magical_elements=["Ancient Ley Lines", "Natural Magic", "Elemental Powers"],
110+
)
111+
print(prompt3)
112+
113+
# Example 4: Minimal configuration
114+
print("\nExample 4: Minimal Required Configuration")
115+
print("-" * 50)
116+
prompt4 = generate_rpg_scenario(
117+
game_style="gritty",
118+
party_level=1,
119+
party_classes=["Fighter"],
120+
environment="city",
121+
quest_type="combat",
122+
difficulty="medium",
123+
magical_elements=["Street Magic", "Common Spells"]
124+
)
125+
print(prompt4)
126+
127+
128+
if __name__ == "__main__":
129+
main()

0 commit comments

Comments
 (0)