Skip to content

Commit d092769

Browse files
authored
feat: added topic scoping to the SDK (#466)
* feat: added topic scoping to the SDK * added topics to the prompt * wip * docs
1 parent a7f169d commit d092769

6 files changed

Lines changed: 23 additions & 5 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ make check-safety
4242

4343
The SDK has a minimal structure centered on the `Client` class:
4444

45-
- **`qualifire/client.py`**: Main `Client` class with two public methods:
45+
- **`qualifire/client.py`**: Main `Client` class with three public methods:
4646
- `evaluate()` - Run ad-hoc evaluations with various checks (hallucinations, grounding, PII, content moderation, etc.)
4747
- `invoke_evaluation()` - Run pre-configured evaluations from the Qualifire dashboard
48+
- `compile_prompt()` - Compile a prompt with topic scoping and policy targets
4849

4950
- **`qualifire/types.py`**: All data classes and enums:
5051
- `EvaluationRequest`/`EvaluationResponse` - API request/response structures
5152
- `LLMMessage`, `LLMToolCall`, `LLMToolDefinition` - Message and tool types for conversation-based evaluation
5253
- `ModelMode` (SPEED/BALANCED/QUALITY) - Quality vs speed trade-off for checks
5354
- `SyntaxCheckArgs` - Configuration for syntax validation
55+
- `PolicyTarget`, `CompilePromptResponse` - Types for prompt compilation with topic scoping
5456

5557
- **`qualifire/utils.py`**: Helper functions for API key and base URL resolution from environment variables
5658

assets/images/coverage.svg

Lines changed: 2 additions & 2 deletions
Loading

pyproject.toml

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

55
[project]
66
name = "qualifire"
7-
version = "0.13.0"
7+
version = "0.13.1"
88
description = "Qualifire Python SDK"
99
authors = [{ name = "qualifire-dev", email = "dror@qualifire.ai" }]
1010
requires-python = ">=3.8,<4"

qualifire/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def evaluate(
6363
grounding_multi_turn_mode: bool = False,
6464
policy_multi_turn_mode: bool = False,
6565
policy_target: PolicyTarget = PolicyTarget.BOTH,
66+
topic_scoping_mode: Optional[ModelMode] = None,
67+
topic_scoping_multi_turn_mode: bool = False,
68+
topic_scoping_target: PolicyTarget = PolicyTarget.BOTH,
69+
allowed_topics: Optional[List[str]] = None,
6670
) -> Union[EvaluationResponse, None]:
6771
"""
6872
Evaluates the given input and output pairs.
@@ -105,6 +109,10 @@ def evaluate(
105109
:param grounding_multi_turn_mode: Enable multi-turn mode for grounding check.
106110
:param policy_multi_turn_mode: Enable multi-turn mode for policy check.
107111
:param policy_target: Target for policy checks (input/output/both).
112+
:param topic_scoping_mode: Model mode for topic scoping check (speed/balanced/quality).
113+
:param topic_scoping_multi_turn_mode: Enable multi-turn mode for topic scoping check.
114+
:param topic_scoping_target: Target topic for topic scoping check.
115+
:param allowed_topics: List of allowed topics for topic scoping check.
108116
109117
:return: An EvaluationResponse object containing the evaluation results.
110118
:raises Exception: If an error occurs during the evaluation.
@@ -224,6 +232,10 @@ def evaluate(
224232
grounding_multi_turn_mode=grounding_multi_turn_mode,
225233
policy_multi_turn_mode=policy_multi_turn_mode,
226234
policy_target=policy_target,
235+
topic_scoping_mode=topic_scoping_mode,
236+
topic_scoping_multi_turn_mode=topic_scoping_multi_turn_mode,
237+
topic_scoping_target=topic_scoping_target,
238+
allowed_topics=allowed_topics,
227239
)
228240

229241
response = requests.post(

qualifire/types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ class EvaluationRequest(BaseModel):
6666
grounding_multi_turn_mode: bool = False
6767
policy_multi_turn_mode: bool = False
6868
policy_target: PolicyTarget = PolicyTarget.BOTH
69+
topic_scoping_mode: Optional[ModelMode] = None
70+
topic_scoping_multi_turn_mode: bool = False
71+
topic_scoping_target: Optional[str] = None
72+
allowed_topics: Optional[List[str]] = None
6973

7074
@model_validator(mode="after")
7175
def validate_model(self) -> "EvaluationRequest":

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)