Skip to content

Commit bedd37d

Browse files
committed
Enhance Promptix with Conversation Memory and Logging Support
- Add conversation memory support in README examples - Integrate logging utility in storage utils - Improve PromptManager to dynamically detect storage file format - Add blog links to README for more context
1 parent 135a393 commit bedd37d

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [0.1.9] - 2025-03-03
4+
5+
## Changed
6+
- Promptix Studio Updated
7+
- Updated README
8+
39
## [0.1.8] - 2025-03-03
410

511
## Changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,16 @@ system_instruction = (
148148
from openai import OpenAI
149149
client = OpenAI()
150150

151+
# Example conversation history
152+
memory = [
153+
{"role": "user", "content": "Can you help me with my last transaction ?"}
154+
]
155+
151156
openai_config = (
152157
Promptix.builder("CustomerSupport")
153158
.with_customer_name("Jordan Smith")
154159
.with_issue("billing question")
160+
.with_memory(memory)
155161
.for_client("openai")
156162
.build()
157163
)
@@ -181,18 +187,28 @@ Generate consistent but customizable content with prompts that:
181187
- Maintain brand voice while allowing flexibility
182188
- Include relevant reference materials based on topic
183189

190+
Read more about the design principles behind Promptix in [Why I Created Promptix: A Local-First Approach to Prompt Management](https://nisarg38.github.io/Portfolio-Website/blog/blogs/promptix-01).
191+
192+
For a detailed guide on how to use Promptix, see [How to Use Promptix: A Developer's Guide](https://nisarg38.github.io/Portfolio-Website/blog/blogs/promptix-02).
193+
184194
## 🧪 Advanced Usage
185195

186196
### Custom Tools Configuration
187197

188198
```python
199+
# Example conversation history
200+
memory = [
201+
{"role": "user", "content": "Can you help me understand Python decorators?"}
202+
]
203+
189204
# Configure specialized tools for different scenarios
190205
security_review_config = (
191206
Promptix.builder("CodeReviewer")
192207
.with_code_snippet(code)
193208
.with_review_focus("security")
194209
.with_tool("vulnerability_scanner")
195210
.with_tool("dependency_checker")
211+
.with_memory(memory)
196212
.for_client("openai")
197213
.build()
198214
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "promptix"
7-
version = "0.1.8"
7+
version = "0.1.9"
88
description = "A simple library for managing and using prompts locally with Promptix Studio"
99
readme = "README.md"
1010
requires-python = ">=3.8"

src/promptix/core/storage/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from pathlib import Path
33
from datetime import datetime
44
from typing import Dict, Any
5+
from promptix.enhancements.logging import setup_logging
6+
7+
# Set up logger for this module
8+
logger = setup_logging()
59

610
from .loaders import PromptLoaderFactory
711

@@ -23,7 +27,7 @@ def create_default_prompts_file(file_path: Path) -> Dict[str, Any]:
2327
if file_path.suffix.lower() not in ['.yaml', '.yml', '.json']:
2428
# If no valid extension is provided, prefer YAML
2529
file_path = file_path.with_suffix('.yaml')
26-
print(f"No valid extension provided, defaulting to YAML format: {file_path}")
30+
logger.info(f"No valid extension provided, defaulting to YAML format: {file_path}")
2731

2832
# Get current timestamp
2933
current_time = datetime.now().isoformat()
@@ -78,6 +82,6 @@ def create_default_prompts_file(file_path: Path) -> Dict[str, Any]:
7882
loader = PromptLoaderFactory.get_loader(file_path)
7983
loader.save(default_prompts, file_path)
8084

81-
print(f"Created new prompts file at {file_path} with a sample prompt")
85+
logger.info(f"Created new prompts file at {file_path} with a sample prompt")
8286

8387
return default_prompts

src/promptix/tools/studio/data.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
import traceback
99

1010
class PromptManager:
11-
def __init__(self, storage_path: str = "prompts.json"):
12-
self.storage_path = storage_path
11+
def __init__(self):
12+
# Check for YAML file first, then JSON
13+
yaml_path = os.path.join(os.getcwd(), "prompts.yaml")
14+
json_path = os.path.join(os.getcwd(), "prompts.json")
15+
16+
if os.path.exists(yaml_path):
17+
self.storage_path = yaml_path
18+
elif os.path.exists(json_path):
19+
self.storage_path = json_path
20+
else:
21+
self.storage_path = yaml_path # Default to yaml if neither exists
22+
1323
self._ensure_storage_exists()
14-
self._loader = PromptLoaderFactory.get_loader(Path(storage_path))
24+
25+
self._loader = PromptLoaderFactory.get_loader(Path(self.storage_path))
1526

1627
def _ensure_storage_exists(self):
1728
"""Ensure the storage file exists"""

0 commit comments

Comments
 (0)