Skip to content

Commit a87fa00

Browse files
Semantic Search
1 parent f1db9f2 commit a87fa00

File tree

1 file changed

+6
-38
lines changed

1 file changed

+6
-38
lines changed

README.md

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -328,54 +328,22 @@ result = execute_tool.call(toolName="hris_list_employees", params={"limit": 10})
328328

329329
## Semantic Search
330330

331-
Semantic search enables tool discovery using natural language instead of exact keyword matching. It understands intent and synonyms, so queries like "onboard new hire" or "check my to-do list" resolve to the right StackOne actions.
332-
333-
**How it works:** Your query is matched against all StackOne actions using semantic vector search. Results are automatically filtered to only the connectors available in your linked accounts, so you only get tools you can actually use.
334-
335-
### `search_tools()` — Recommended
336-
337-
High-level method that returns a `Tools` collection ready for any framework:
331+
Discover tools using natural language instead of exact names. Queries like "onboard new hire" resolve to the right actions even when the tool is called `hris_create_employee`.
338332

339333
```python
340334
from stackone_ai import StackOneToolSet
341335

342336
toolset = StackOneToolSet()
343337

344-
# Natural language search — no need to know exact tool names
345-
tools = toolset.search_tools("manage employee records", top_k=5)
346-
347-
# Use with any framework
348-
langchain_tools = tools.to_langchain()
349-
350-
# Filter by connector
351-
tools = toolset.search_tools("create time off request", connector="bamboohr", top_k=3)
352-
```
353-
354-
### `search_action_names()` — Lightweight
355-
356-
Returns action names and similarity scores without fetching full tool definitions. Useful for inspecting results before committing:
338+
# Search by intent — returns Tools collection ready for any framework
339+
tools = toolset.search_tools("manage employee records", account_ids=["your-account-id"], top_k=5)
340+
openai_tools = tools.to_openai()
357341

358-
```python
342+
# Lightweight: inspect results without fetching full tool definitions
359343
results = toolset.search_action_names("time off requests", top_k=5)
360-
for r in results:
361-
print(f"{r.action_name} ({r.connector_key}): {r.similarity_score:.2f}")
362-
```
363-
364-
### Utility Tools with Semantic Search
365-
366-
For agent loops using `tool_search` / `tool_execute`, pass `semantic_client` to upgrade from local keyword matching to semantic search:
367-
368-
```python
369-
tools = toolset.fetch_tools()
370-
utility = tools.utility_tools(semantic_client=toolset.semantic_client)
371-
372-
search_tool = utility.get_tool("tool_search")
373-
results = search_tool.call(query="onboard a new team member", limit=5)
374344
```
375345

376-
> `tool_search` is scoped to the connectors in your fetched tools, so only tools you can execute are returned.
377-
378-
See [Semantic Search Example](examples/semantic_search_example.py) for complete patterns including OpenAI and LangChain integration.
346+
Results are automatically scoped to connectors in your linked accounts. See [Semantic Search Example](examples/semantic_search_example.py) for utility tools integration, OpenAI, and LangChain patterns.
379347

380348
## Examples
381349

0 commit comments

Comments
 (0)