Skip to content

Commit eb36878

Browse files
authored
Merge pull request #23 from root-signals/sdk-v1.5.2
version 1.5.2
2 parents 5c2b2e4 + 3712c47 commit eb36878

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 1.5.2
2+
3+
### Added
4+
5+
- Added evaluator execution by name
6+
7+
### Changed
8+
9+
- Evaluator uses new endpoints instead of deprecated ones in all functions
10+
111
## 1.5.1
212

313
### Added

examples/run_evaluator_by_name.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from root import RootSignals
2+
3+
client = RootSignals()
4+
5+
# Run a root evaluator by name using the run_by_name method
6+
result = client.evaluators.run_by_name(
7+
name="Helpfulness",
8+
response="You can find the instructions from our Careers page.",
9+
request="Where can I find the application instructions?",
10+
)
11+
12+
print(f"Score: {result.score} / 1.0")
13+
print(f"Justification: {result.justification}")
14+
15+
# Run a custom evaluator by name
16+
# Assuming you have created a custom evaluator named "Network Troubleshooting"
17+
try:
18+
custom_result = client.evaluators.run_by_name(
19+
name="Network Troubleshooting",
20+
request="My internet is not working.",
21+
response="""
22+
I'm sorry to hear that your internet isn't working.
23+
Let's troubleshoot this step by step:
24+
1. Check if your router is powered on and all cables are properly connected
25+
2. Try restarting your router and modem
26+
3. Check if other devices can connect to the network
27+
4. Try connecting to a different network if available
28+
""",
29+
)
30+
31+
print(f"Score: {custom_result.score} / 1.0")
32+
print(f"Justification: {custom_result.justification}")
33+
except Exception as e:
34+
print(f"Error: {e}")
35+
print(
36+
"Note: This example requires that you have previously created a custom evaluator named 'Network Troubleshooting'"
37+
)
38+
39+
result_with_context = client.evaluators.run_by_name(
40+
name="Context_Precision",
41+
response="The capital of France is Paris, which is known for the Eiffel Tower.",
42+
request="What is the capital of France?",
43+
contexts=["France is a country in Western Europe with a population of about 67 million people."],
44+
variables={"criteria": "geographical accuracy"},
45+
)
46+
47+
print(f"Score: {result_with_context.score} / 1.0")
48+
print(f"Justification: {result_with_context.justification}")

src/root/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-FileCopyrightText: 2024-present juho.ylikyla <[email protected]>
22
#
33
# SPDX-License-Identifier: MIT
4-
__version__ = "1.5.1"
4+
__version__ = "1.5.2"

0 commit comments

Comments
 (0)