-
Notifications
You must be signed in to change notification settings - Fork 0
feat: LangGraph integration helpers and example #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8bb3c02
8a9a13f
6dcf323
8f24d87
e124a9a
6106a82
f55b44d
99c68c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| """Integration helpers for external frameworks. | ||
|
|
||
| Currently includes: | ||
|
|
||
| - LangGraph helpers to turn StackOne tools into a `ToolNode` or `ToolExecutor`. | ||
| """ | ||
|
|
||
| from .langgraph import ( | ||
| bind_model_with_tools, | ||
| create_react_agent, | ||
| to_tool_executor, | ||
| to_tool_node, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "to_tool_node", | ||
| "to_tool_executor", | ||
| "bind_model_with_tools", | ||
| "create_react_agent", | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,94 @@ | ||||||
| """LangGraph integration helpers. | ||||||
|
|
||||||
| These utilities convert StackOne tools into LangGraph prebuilt components. | ||||||
|
|
||||||
| Usage: | ||||||
| from stackone_ai import StackOneToolSet | ||||||
| from stackone_ai.integrations.langgraph import to_tool_node | ||||||
|
|
||||||
| toolset = StackOneToolSet() | ||||||
| tools = toolset.get_tools("hris_*", account_id="...") | ||||||
| node = to_tool_node(tools) # langgraph.prebuilt.ToolNode | ||||||
| """ | ||||||
|
|
||||||
| from __future__ import annotations | ||||||
|
|
||||||
| from collections.abc import Sequence | ||||||
| from typing import TYPE_CHECKING, Any | ||||||
|
|
||||||
| from langchain_core.tools import BaseTool | ||||||
|
|
||||||
| from stackone_ai.models import Tools | ||||||
|
|
||||||
| if TYPE_CHECKING: # pragma: no cover - only for typing | ||||||
| try: | ||||||
| from langgraph.prebuilt import ToolNode | ||||||
| except Exception: # pragma: no cover | ||||||
|
||||||
| except Exception: # pragma: no cover | |
| except ImportError: # pragma: no cover |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a bare Exception catch is too broad. Consider catching ImportError or ModuleNotFoundError specifically since this is checking for missing dependencies.
| except Exception as e: # pragma: no cover | |
| except ImportError as e: # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With add_messages, returning state["messages"] + [resp] duplicates messages; return only the new message so the reducer can append it.
Prompt for AI agents