Skip to content

Commit c81e982

Browse files
committed
more informative quickstart
1 parent beb0603 commit c81e982

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

‎examples/quickstart.py‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2+
import random
3+
import string
24

35
from dotenv import load_dotenv
46

@@ -7,21 +9,31 @@
79

810
load_dotenv()
911

10-
logger = RLMLogger(log_dir="./logs")
12+
# Generate a large text file with a hidden secret number
13+
secret_number = random.randint(100_000_000, 999_999_999)
14+
filler_lines = ["".join(random.choices(string.ascii_lowercase + " ", k=120)) for _ in range(50_000)]
15+
insert_at = random.randint(len(filler_lines) // 3, 2 * len(filler_lines) // 3)
16+
filler_lines.insert(insert_at, f"SECRET_NUMBER={secret_number}")
17+
haystack = "\n".join(filler_lines)
1118

1219
rlm = RLM(
13-
backend="portkey", # or "openai", etc.
20+
backend="openai",
1421
backend_kwargs={
15-
"model_name": "@openai/gpt-5-nano",
16-
"api_key": os.getenv("PORTKEY_API_KEY"),
22+
"model_name": "gpt-5-nano",
23+
"api_key": os.getenv("OPENAI_API_KEY"),
1724
},
1825
environment="local",
19-
environment_kwargs={},
20-
max_depth=1,
21-
logger=logger,
22-
verbose=True, # For printing to console with rich, disabled by default.
26+
max_iterations=10,
27+
logger=RLMLogger(log_dir="./logs"),
28+
verbose=True,
2329
)
2430

25-
result = rlm.completion("Print me the first 5 powers of two, each on a newline.")
31+
result = rlm.completion(
32+
"The context contains ~50k lines of random text with a single line "
33+
"matching the pattern SECRET_NUMBER=<digits>. Find and return ONLY the "
34+
f"numeric value.\n\n{haystack}"
35+
)
2636

27-
print(result)
37+
print(f"\nModel found: {result.response}")
38+
print(f"Actual number: {secret_number}")
39+
print(f"Correct: {str(secret_number) in result.response}")

0 commit comments

Comments
 (0)