hyperpocket-langgraph 0.0.1__py3-none-any.whl → 0.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hyperpocket_langgraph/pocket_langgraph.py +3 -66
- {hyperpocket_langgraph-0.0.1.dist-info → hyperpocket_langgraph-0.1.8.dist-info}/METADATA +29 -37
- hyperpocket_langgraph-0.1.8.dist-info/RECORD +5 -0
- {hyperpocket_langgraph-0.0.1.dist-info → hyperpocket_langgraph-0.1.8.dist-info}/WHEEL +1 -1
- hyperpocket_langgraph-0.0.1.dist-info/RECORD +0 -5
@@ -8,10 +8,9 @@ from pydantic import BaseModel
|
|
8
8
|
from hyperpocket.config import pocket_logger
|
9
9
|
from hyperpocket.pocket_main import ToolLike
|
10
10
|
from hyperpocket.prompts import pocket_extended_tool_description
|
11
|
-
from hyperpocket.server.server import PocketServerOperations
|
12
11
|
|
13
12
|
try:
|
14
|
-
from langchain_core.messages import
|
13
|
+
from langchain_core.messages import ToolMessage
|
15
14
|
from langchain_core.tools import BaseTool, StructuredTool
|
16
15
|
except ImportError:
|
17
16
|
raise ImportError(
|
@@ -19,9 +18,7 @@ except ImportError:
|
|
19
18
|
)
|
20
19
|
|
21
20
|
try:
|
22
|
-
from langgraph.
|
23
|
-
from langgraph.graph import add_messages, StateGraph, MessagesState
|
24
|
-
from langgraph.graph.state import CompiledStateGraph
|
21
|
+
from langgraph.graph import MessagesState
|
25
22
|
except ImportError:
|
26
23
|
raise ImportError(
|
27
24
|
"You need to install langgraph to use pocket langgraph"
|
@@ -43,7 +40,7 @@ class PocketLanggraph(Pocket):
|
|
43
40
|
auth: PocketAuth = None):
|
44
41
|
super().__init__(tools, auth)
|
45
42
|
self.langgraph_tools = {}
|
46
|
-
for tool_name, tool_impl in self.tools.items():
|
43
|
+
for tool_name, tool_impl in self.core.tools.items():
|
47
44
|
self.langgraph_tools[tool_name] = self._get_langgraph_tool(tool_impl)
|
48
45
|
|
49
46
|
def get_tools(self):
|
@@ -133,66 +130,6 @@ class PocketLanggraph(Pocket):
|
|
133
130
|
|
134
131
|
return _tool_node
|
135
132
|
|
136
|
-
async def prepare_in_subprocess(self,
|
137
|
-
tool_name: str,
|
138
|
-
body: Any,
|
139
|
-
thread_id: str = 'default',
|
140
|
-
profile: str = 'default',
|
141
|
-
*args, **kwargs):
|
142
|
-
prepare = await self.server.call_in_subprocess(
|
143
|
-
PocketServerOperations.PREPARE_AUTH,
|
144
|
-
args,
|
145
|
-
{
|
146
|
-
'tool_name': tool_name,
|
147
|
-
'body': body,
|
148
|
-
'thread_id': thread_id,
|
149
|
-
'profile': profile,
|
150
|
-
**kwargs,
|
151
|
-
},
|
152
|
-
)
|
153
|
-
|
154
|
-
return prepare
|
155
|
-
|
156
|
-
async def authenticate_in_subprocess(self,
|
157
|
-
tool_name: str,
|
158
|
-
body: Any,
|
159
|
-
thread_id: str = 'default',
|
160
|
-
profile: str = 'default',
|
161
|
-
*args, **kwargs):
|
162
|
-
credentials = await self.server.call_in_subprocess(
|
163
|
-
PocketServerOperations.AUTHENTICATE,
|
164
|
-
args,
|
165
|
-
{
|
166
|
-
'tool_name': tool_name,
|
167
|
-
'body': body,
|
168
|
-
'thread_id': thread_id,
|
169
|
-
'profile': profile,
|
170
|
-
**kwargs,
|
171
|
-
},
|
172
|
-
)
|
173
|
-
|
174
|
-
return credentials
|
175
|
-
|
176
|
-
async def tool_call_in_subprocess(self,
|
177
|
-
tool_name: str,
|
178
|
-
body: Any,
|
179
|
-
thread_id: str = 'default',
|
180
|
-
profile: str = 'default',
|
181
|
-
*args, **kwargs):
|
182
|
-
result = await self.server.call_in_subprocess(
|
183
|
-
PocketServerOperations.TOOL_CALL,
|
184
|
-
args,
|
185
|
-
{
|
186
|
-
'tool_name': tool_name,
|
187
|
-
'body': body,
|
188
|
-
'thread_id': thread_id,
|
189
|
-
'profile': profile,
|
190
|
-
**kwargs,
|
191
|
-
},
|
192
|
-
)
|
193
|
-
|
194
|
-
return result
|
195
|
-
|
196
133
|
def _get_langgraph_tool(self, pocket_tool: PocketTool) -> BaseTool:
|
197
134
|
def _invoke(body: Any, thread_id: str = 'default', profile: str = 'default', **kwargs) -> str:
|
198
135
|
if isinstance(body, BaseModel):
|
@@ -1,16 +1,10 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: hyperpocket-langgraph
|
3
|
-
Version: 0.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Requires-
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.11
|
10
|
-
Classifier: Programming Language :: Python :: 3.12
|
11
|
-
Classifier: Programming Language :: Python :: 3.13
|
12
|
-
Requires-Dist: hyperpocket (==0.0.3)
|
13
|
-
Requires-Dist: langgraph (>=0.2.59,<0.3.0)
|
3
|
+
Version: 0.1.8
|
4
|
+
Author-email: moon <moon@vessl.ai>
|
5
|
+
Requires-Python: >=3.10
|
6
|
+
Requires-Dist: hyperpocket>=0.0.3
|
7
|
+
Requires-Dist: langgraph>=0.2.59
|
14
8
|
Description-Content-Type: text/markdown
|
15
9
|
|
16
10
|
# Langgraph extensions
|
@@ -23,12 +17,13 @@ Description-Content-Type: text/markdown
|
|
23
17
|
## Get Pocket Subgraph
|
24
18
|
|
25
19
|
```python
|
26
|
-
|
27
|
-
|
20
|
+
from hyperpocket.tool import from_git
|
21
|
+
|
22
|
+
from hyperpocket_langgraph import PocketLanggraph
|
28
23
|
|
29
24
|
pocket = PocketLanggraph(tools=[
|
30
|
-
|
31
|
-
|
25
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
|
26
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
|
32
27
|
"https://github.com/my-org/some-awesome-tool",
|
33
28
|
])
|
34
29
|
|
@@ -41,15 +36,14 @@ pocket_node = pocket.get_tool_node()
|
|
41
36
|
```python
|
42
37
|
import os
|
43
38
|
|
39
|
+
from hyperpocket.tool import from_git
|
44
40
|
from langchain_openai import ChatOpenAI
|
45
41
|
|
46
|
-
|
47
|
-
from pocket_langgraph import PocketLanggraph
|
42
|
+
from hyperpocket_langgraph import PocketLanggraph
|
48
43
|
|
49
44
|
pocket = PocketLanggraph(tools=[
|
50
|
-
|
51
|
-
|
52
|
-
"https://github.com/my-org/some-awesome-tool",
|
45
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
|
46
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
|
53
47
|
])
|
54
48
|
|
55
49
|
# get tools from pocket to bind llm
|
@@ -66,6 +60,7 @@ llm_with_tools = llm.bind_tools(tools)
|
|
66
60
|
import os
|
67
61
|
from typing import Annotated
|
68
62
|
|
63
|
+
from hyperpocket.tool import from_git
|
69
64
|
from langchain_core.runnables import RunnableConfig
|
70
65
|
from langchain_openai import ChatOpenAI
|
71
66
|
from langgraph.checkpoint.memory import MemorySaver
|
@@ -74,14 +69,12 @@ from langgraph.graph.message import add_messages
|
|
74
69
|
from langgraph.prebuilt import tools_condition
|
75
70
|
from typing_extensions import TypedDict
|
76
71
|
|
77
|
-
|
78
|
-
from pocket_langgraph import PocketLanggraph
|
72
|
+
from hyperpocket_langgraph import PocketLanggraph
|
79
73
|
|
80
74
|
# Define pocket tools
|
81
75
|
pocket = PocketLanggraph(tools=[
|
82
|
-
|
83
|
-
|
84
|
-
"https://github.com/my-org/some-awesome-tool",
|
76
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
|
77
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
|
85
78
|
])
|
86
79
|
|
87
80
|
# Get Pocket ToolNode
|
@@ -138,14 +131,14 @@ by setting the `should_interrupt` flag when calling `get_tool_node`
|
|
138
131
|
Perform authentication in a multi-turn way
|
139
132
|
|
140
133
|
```python
|
141
|
-
|
142
|
-
|
134
|
+
from hyperpocket.tool import from_git
|
135
|
+
|
136
|
+
from hyperpocket_langgraph import PocketLanggraph
|
143
137
|
|
144
138
|
# Define pocket tools
|
145
139
|
pocket = PocketLanggraph(tools=[
|
146
|
-
|
147
|
-
|
148
|
-
"https://github.com/my-org/some-awesome-tool",
|
140
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
|
141
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
|
149
142
|
])
|
150
143
|
|
151
144
|
# Get Pocket ToolNode
|
@@ -155,14 +148,14 @@ pocket_node = pocket.get_tool_node(should_interrupt=False) # multi turn
|
|
155
148
|
### Human-in-the-loop Auth
|
156
149
|
|
157
150
|
```python
|
158
|
-
|
159
|
-
|
151
|
+
from hyperpocket.tool import from_git
|
152
|
+
|
153
|
+
from hyperpocket_langgraph import PocketLanggraph
|
160
154
|
|
161
155
|
# Define pocket tools
|
162
156
|
pocket = PocketLanggraph(tools=[
|
163
|
-
|
164
|
-
|
165
|
-
"https://github.com/my-org/some-awesome-tool",
|
157
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
|
158
|
+
from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
|
166
159
|
])
|
167
160
|
|
168
161
|
# Get Pocket ToolNode
|
@@ -198,4 +191,3 @@ flow, there is a risk of incorrect decisions being made.
|
|
198
191
|
Conversely, the human-in-the-loop approach eliminates this risk by always continuing the previous flow as it is,
|
199
192
|
offering more predictable and controlled behavior for managing the auth flow.
|
200
193
|
|
201
|
-
|
@@ -0,0 +1,5 @@
|
|
1
|
+
hyperpocket_langgraph/__init__.py,sha256=0Az6FKsAvohOk8G4kUE99g6kyWz-Nf7dUuCuN3_pViY,97
|
2
|
+
hyperpocket_langgraph/pocket_langgraph.py,sha256=6_KfStimtuvW7W7TzyUWN4WJ5veybDgJv_bGCAtxOt4,6852
|
3
|
+
hyperpocket_langgraph-0.1.8.dist-info/METADATA,sha256=umosqoSEHq85vwsT7JiLfCMxAasNxLsvLFinxQ_sjeI,5827
|
4
|
+
hyperpocket_langgraph-0.1.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
+
hyperpocket_langgraph-0.1.8.dist-info/RECORD,,
|
@@ -1,5 +0,0 @@
|
|
1
|
-
hyperpocket_langgraph/__init__.py,sha256=0Az6FKsAvohOk8G4kUE99g6kyWz-Nf7dUuCuN3_pViY,97
|
2
|
-
hyperpocket_langgraph/pocket_langgraph.py,sha256=SqXZDdqvOKX66f0rRI8Ol-rNkL66yIXLFlToyorMvMs,9176
|
3
|
-
hyperpocket_langgraph-0.0.1.dist-info/METADATA,sha256=9zG8UMulVdv3cVcSMHiOXzauJov9Jldx44myu1PRQeg,5671
|
4
|
-
hyperpocket_langgraph-0.0.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
5
|
-
hyperpocket_langgraph-0.0.1.dist-info/RECORD,,
|