-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_openai.py
63 lines (55 loc) · 1.89 KB
/
test_openai.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pytest
from promptix import Promptix
def test_prepare_model_config_basic():
memory = [
{"role": "user", "content": "Test message"},
{"role": "assistant", "content": "Test response"}
]
model_config = Promptix.prepare_model_config(
prompt_template="CustomerSupport",
user_name="Test User",
issue_type="test",
technical_level="beginner",
interaction_history="none",
product_version="1.0.0",
issue_description="Test description",
custom_data={"product_version": "1.0.0", "subscription_tier": "standard"},
memory=memory,
)
assert isinstance(model_config, dict)
assert "messages" in model_config
assert "model" in model_config
assert len(model_config["messages"]) > 0
def test_prepare_model_config_memory_validation():
with pytest.raises(ValueError):
Promptix.prepare_model_config(
prompt_template="CustomerSupport",
user_name="Test User",
memory=[{"invalid": "format"}] # Invalid memory format
)
def test_prepare_model_config_required_fields():
with pytest.raises(ValueError):
Promptix.prepare_model_config(
prompt_template="CustomerSupport",
memory=[],
user_name="Test User",
issue_type="invalid"
)
def test_prepare_model_config_custom_data():
memory = [
{"role": "user", "content": "Test message"}
]
model_config = Promptix.prepare_model_config(
prompt_template="CustomerSupport",
user_name="Test User",
issue_type="general",
issue_description="Test issue",
technical_level="intermediate",
memory=memory,
custom_data={
"special_field": "test_value",
"priority": "high"
}
)
assert isinstance(model_config, dict)
assert "messages" in model_config