Skip to content

Commit 04b8bd0

Browse files
Add the STACKONE_API_KEY too in example
1 parent e0ca81c commit 04b8bd0

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

examples/search_tool_example.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
For semantic search basics, see semantic_search_example.py.
44
For full agent execution, see agent_tool_search.py.
55
6+
Prerequisites:
7+
- STACKONE_API_KEY environment variable
8+
- STACKONE_ACCOUNT_ID environment variable
9+
610
Run with:
711
uv run python examples/search_tool_example.py
812
"""
@@ -22,37 +26,39 @@
2226

2327

2428
def main() -> None:
25-
account_id = os.getenv("STACKONE_ACCOUNT_ID", "")
26-
_account_ids = [a.strip() for a in account_id.split(",") if a.strip()] if account_id else []
29+
api_key = os.getenv("STACKONE_API_KEY")
30+
account_id = os.getenv("STACKONE_ACCOUNT_ID")
31+
32+
if not api_key:
33+
print("Set STACKONE_API_KEY to run this example.")
34+
return
35+
if not account_id:
36+
print("Set STACKONE_ACCOUNT_ID to run this example.")
37+
return
2738

2839
# --- Example 1: get_search_tool() callable ---
2940
print("=== get_search_tool() callable ===\n")
3041

31-
toolset = StackOneToolSet(search={})
42+
toolset = StackOneToolSet(api_key=api_key, account_id=account_id, search={})
3243
search_tool = toolset.get_search_tool()
3344

3445
queries = ["cancel an event", "list employees", "send a message"]
3546
for query in queries:
36-
tools = search_tool(query, top_k=3, account_ids=_account_ids)
47+
tools = search_tool(query, top_k=3)
3748
names = [t.name for t in tools]
3849
print(f' "{query}" -> {", ".join(names) or "(none)"}')
3950

4051
# --- Example 2: Constructor top_k vs per-call override ---
4152
print("\n=== Constructor top_k vs per-call override ===\n")
4253

43-
toolset_3 = StackOneToolSet(search={"top_k": 3})
44-
toolset_10 = StackOneToolSet(search={"top_k": 10})
54+
toolset_3 = StackOneToolSet(api_key=api_key, account_id=account_id, search={"top_k": 3})
4555

4656
query = "manage employee records"
4757

48-
tools_3 = toolset_3.search_tools(query, account_ids=_account_ids)
58+
tools_3 = toolset_3.search_tools(query)
4959
print(f"Constructor top_k=3: got {len(tools_3)} tools")
5060

51-
tools_10 = toolset_10.search_tools(query, account_ids=_account_ids)
52-
print(f"Constructor top_k=10: got {len(tools_10)} tools")
53-
54-
# Per-call override: constructor says 3 but this call says 10
55-
tools_override = toolset_3.search_tools(query, top_k=10, account_ids=_account_ids)
61+
tools_override = toolset_3.search_tools(query, top_k=10)
5662
print(f"Per-call top_k=10 (overrides constructor 3): got {len(tools_override)} tools")
5763

5864

examples/workday_integration.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Workday can take 10-15s to respond. This example shows how to configure
44
timeout and account_ids through the execute config.
55
6+
Prerequisites:
7+
- STACKONE_API_KEY environment variable
8+
- STACKONE_ACCOUNT_ID environment variable (a Workday-connected account)
9+
- OPENAI_API_KEY environment variable
10+
611
Run with:
712
uv run python examples/workday_integration.py
813
"""
@@ -25,12 +30,22 @@
2530

2631

2732
def main() -> None:
28-
account_id = os.getenv("STACKONE_ACCOUNT_ID", "")
33+
api_key = os.getenv("STACKONE_API_KEY")
34+
account_id = os.getenv("STACKONE_ACCOUNT_ID")
35+
36+
if not api_key:
37+
print("Set STACKONE_API_KEY to run this example.")
38+
return
39+
if not account_id:
40+
print("Set STACKONE_ACCOUNT_ID to run this example.")
41+
return
2942

30-
# Timeout and account_ids both live in the execute config
43+
# Timeout for slow providers, account_id for scoping
3144
toolset = StackOneToolSet(
45+
api_key=api_key,
46+
account_id=account_id,
3247
search={"method": "auto", "top_k": 5},
33-
execute={"account_ids": [account_id], "timeout": 120},
48+
timeout=120,
3449
)
3550
client = OpenAI()
3651

0 commit comments

Comments
 (0)