hyperpocket 0.5.1__py3-none-any.whl → 0.5.3__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/cli/__main__.py +1 -7
- hyperpocket/pocket_main.py +56 -19
- hyperpocket/util/function_to_model.py +8 -11
- {hyperpocket-0.5.1.dist-info → hyperpocket-0.5.3.dist-info}/METADATA +2 -3
- {hyperpocket-0.5.1.dist-info → hyperpocket-0.5.3.dist-info}/RECORD +7 -9
- hyperpocket/cli/eject.py +0 -14
- hyperpocket/cli/pull.py +0 -13
- {hyperpocket-0.5.1.dist-info → hyperpocket-0.5.3.dist-info}/WHEEL +0 -0
- {hyperpocket-0.5.1.dist-info → hyperpocket-0.5.3.dist-info}/entry_points.txt +0 -0
hyperpocket/cli/__main__.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
import click
|
2
2
|
|
3
|
-
from hyperpocket.cli.eject import eject
|
4
|
-
from hyperpocket.cli.pull import pull
|
5
|
-
from hyperpocket.cli.eject import eject
|
6
|
-
from hyperpocket.cli.auth_token import create_token_auth_template
|
7
3
|
from hyperpocket.cli.auth_oauth2 import create_oauth2_auth_template
|
4
|
+
from hyperpocket.cli.auth_token import create_token_auth_template
|
8
5
|
from hyperpocket.cli.tool_create import create_tool_template, build_tool
|
9
6
|
from hyperpocket.cli.tool_export import export_tool
|
10
7
|
|
@@ -26,7 +23,4 @@ devtool.add_command(create_tool_template)
|
|
26
23
|
devtool.add_command(build_tool)
|
27
24
|
devtool.add_command(export_tool)
|
28
25
|
|
29
|
-
cli.add_command(pull)
|
30
|
-
cli.add_command(eject)
|
31
|
-
|
32
26
|
cli()
|
hyperpocket/pocket_main.py
CHANGED
@@ -32,18 +32,22 @@ class Pocket(object):
|
|
32
32
|
|
33
33
|
def __init__(
|
34
34
|
self,
|
35
|
-
tools: list[ToolLike],
|
35
|
+
tools: list[ToolLike] = None,
|
36
36
|
auth: PocketAuth = None,
|
37
37
|
use_profile: bool = False,
|
38
38
|
):
|
39
39
|
try:
|
40
40
|
if auth is None:
|
41
41
|
auth = PocketAuth()
|
42
|
+
if tools is None:
|
43
|
+
tools = []
|
44
|
+
|
42
45
|
self.auth = auth
|
43
46
|
self.use_profile = use_profile
|
44
47
|
self.server = PocketServer.get_instance()
|
48
|
+
self.tools = {}
|
45
49
|
|
46
|
-
self.
|
50
|
+
self.load_tools(tools)
|
47
51
|
pocket_logger.info(
|
48
52
|
f"All Registered Tools Loaded successfully. total registered tools : {len(self.tools)}"
|
49
53
|
)
|
@@ -468,25 +472,58 @@ class Pocket(object):
|
|
468
472
|
tool_by_provider[auth_provider_name] = [tool]
|
469
473
|
return tool_by_provider
|
470
474
|
|
471
|
-
def
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
return dock(tool_like)
|
478
|
-
elif isinstance(tool_like, Tool):
|
479
|
-
return tool_like
|
480
|
-
elif isinstance(tool_like, Callable):
|
481
|
-
return from_func(tool_like)
|
482
|
-
else:
|
483
|
-
raise ValueError(f"Invalid tool type: {type(tool_like)}")
|
475
|
+
def load_tools(self, tools: Union[List[ToolLike], ToolLike]) -> List[Tool]:
|
476
|
+
"""
|
477
|
+
Load a list of tools into the pocket.
|
478
|
+
|
479
|
+
This method takes a list of tool identifiers(tool like) and loads them into the
|
480
|
+
pocket for use.
|
484
481
|
|
482
|
+
Args:
|
483
|
+
tools (Union[List[ToolLike], ToolLike]): A list of tool identifiers to be loaded.
|
484
|
+
"""
|
485
|
+
if not isinstance(tools, list):
|
486
|
+
tools = [tools]
|
487
|
+
|
488
|
+
loaded_tools = []
|
485
489
|
with concurrent.futures.ThreadPoolExecutor(max_workers=10, thread_name_prefix="tool-loader") as executor:
|
486
|
-
futures = [executor.submit(
|
487
|
-
for future in concurrent.futures.as_completed(futures)
|
488
|
-
|
489
|
-
|
490
|
+
futures = [executor.submit(self._load_tool, tool_like) for tool_like in tools]
|
491
|
+
loaded_tools = [future.result() for future in concurrent.futures.as_completed(futures)]
|
492
|
+
|
493
|
+
for tool in loaded_tools:
|
494
|
+
if tool.name in self.tools:
|
495
|
+
raise RuntimeError(f"{tool.name} already exists. duplicated tool name.")
|
496
|
+
self.tools[tool.name] = tool
|
497
|
+
|
498
|
+
return loaded_tools
|
499
|
+
|
500
|
+
def _load_tool(self, tool_like) -> Tool:
|
501
|
+
if isinstance(tool_like, str) or isinstance(tool_like, tuple):
|
502
|
+
dock = self._default_dock()
|
503
|
+
return dock(tool_like)
|
504
|
+
elif isinstance(tool_like, Tool):
|
505
|
+
return tool_like
|
506
|
+
elif isinstance(tool_like, Callable):
|
507
|
+
return from_func(tool_like)
|
508
|
+
else:
|
509
|
+
raise ValueError(f"Invalid tool type: {type(tool_like)}")
|
510
|
+
|
511
|
+
def remove_tool(self, tool_name: str) -> bool:
|
512
|
+
"""
|
513
|
+
Remove a tool from the pocket.
|
514
|
+
|
515
|
+
This method removes a tool identified by the given tool_name.
|
516
|
+
|
517
|
+
Args:
|
518
|
+
tool_name (str): The tool name to be removed.
|
519
|
+
|
520
|
+
Returns:
|
521
|
+
bool: True if the tool is removed successfully, False otherwise.
|
522
|
+
"""
|
523
|
+
if not tool_name in self.tools:
|
524
|
+
return False
|
525
|
+
del self.tools[tool_name]
|
526
|
+
return True
|
490
527
|
|
491
528
|
def _tool_instance(self, tool_name: str) -> Tool:
|
492
529
|
return self.tools[tool_name]
|
@@ -38,18 +38,15 @@ def function_to_model(func: callable) -> Type[BaseModel]:
|
|
38
38
|
raise Exception(
|
39
39
|
f"Should all arguments be annotated but {param_name} is not annotated"
|
40
40
|
)
|
41
|
+
|
42
|
+
if param.annotation.__module__ == "typing":
|
43
|
+
for arg in param.annotation.__args__:
|
44
|
+
if arg.__module__ != "builtins" and not issubclass(arg, BaseModel):
|
45
|
+
raise Exception(
|
46
|
+
f"currently only support builtin types and pydantic BaseModel but {param_name} is not builtin type"
|
47
|
+
)
|
41
48
|
|
42
|
-
if
|
43
|
-
param.annotation.__module__ == "typing"
|
44
|
-
and param.annotation.__name__ == "Optional"
|
45
|
-
):
|
46
|
-
fields[param_name] = (
|
47
|
-
param.annotation.__args__[0],
|
48
|
-
FieldInfo(
|
49
|
-
default=param.default,
|
50
|
-
description=param_desc_map.get(param_name, ""),
|
51
|
-
),
|
52
|
-
)
|
49
|
+
# if annotation type isn't typing, check this type directly.
|
53
50
|
elif param.annotation.__module__ != "builtins" and not issubclass(
|
54
51
|
param.annotation, BaseModel
|
55
52
|
):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: hyperpocket
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.3
|
4
4
|
Summary: Building AI agent with hyperpocket tool in a flash
|
5
5
|
Project-URL: Homepage, https://vessl-ai.github.io/hyperpocket
|
6
6
|
Project-URL: Repository, https://github.com/vessl-ai/hyperpocket
|
@@ -14,10 +14,9 @@ Requires-Dist: httpx==0.27
|
|
14
14
|
Requires-Dist: jinja2>=3.1.4
|
15
15
|
Requires-Dist: multiprocess>=0.70.17
|
16
16
|
Requires-Dist: nest-asyncio>=1.6.0
|
17
|
-
Requires-Dist: playwright>=1.49.0
|
18
17
|
Requires-Dist: pydantic>=2.10.2
|
19
18
|
Requires-Dist: pygithub>=2.5.0
|
20
|
-
Requires-Dist: python-multipart>=0.0.
|
19
|
+
Requires-Dist: python-multipart>=0.0.18
|
21
20
|
Requires-Dist: redis>=5.2.1
|
22
21
|
Requires-Dist: requests>=2.32.3
|
23
22
|
Requires-Dist: toml>=0.10.2
|
@@ -2,7 +2,7 @@ hyperpocket/__init__.py,sha256=VVLbApRTiULqEVQp6lCNOcuXKx9V62O_7C9VNKBQ0G0,137
|
|
2
2
|
hyperpocket/builtin.py,sha256=w7OLxf5RCKVpLma9HieSdw6Uky5701ae6g31VPvFoZk,2439
|
3
3
|
hyperpocket/constants.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
hyperpocket/pocket_auth.py,sha256=eRRTzJh3et65EDJnQHB_Kpmco4dgCR2KL8f-FnbuGX0,17819
|
5
|
-
hyperpocket/pocket_main.py,sha256=
|
5
|
+
hyperpocket/pocket_main.py,sha256=PGMx5MovFSD9Xy9gJbCnF4yLPL4LimfTqDta0SGSroU,17615
|
6
6
|
hyperpocket/prompts.py,sha256=N1bCzCLZvGUVhH1Vn_cgeBPsdY3MdIU7ZGqVgexoj5E,472
|
7
7
|
hyperpocket/tool_like.py,sha256=Foa-iWTnVb54JEq20Becadbz-TSbYkZk6TxexSzaaRM,116
|
8
8
|
hyperpocket/auth/README.md,sha256=zn4QqnFZCA_4X3x8Wb6lE3OP5otYxpByZaCiUkBvaNs,11562
|
@@ -468,11 +468,9 @@ hyperpocket/auth/zoom/oauth2_context.py,sha256=f0vj1zeRzTnT-4cwe8SeEn2xz03NBy9W_
|
|
468
468
|
hyperpocket/auth/zoom/oauth2_handler.py,sha256=dMoZjuSRSBaoYLzYkjxc0KZxm9CALLm9aaEVydLBW-0,5111
|
469
469
|
hyperpocket/auth/zoom/oauth2_schema.py,sha256=OlwlEdigiqFX3-XdVp0mhrK7ZKWxVw0v1qNtfx3wN9c,469
|
470
470
|
hyperpocket/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
471
|
-
hyperpocket/cli/__main__.py,sha256=
|
471
|
+
hyperpocket/cli/__main__.py,sha256=9myHxl6CdY5A1w41q7WkD4u1PyZ7C_PlpRFpIYKmXCM,589
|
472
472
|
hyperpocket/cli/auth_oauth2.py,sha256=FTsaIrJY9U1uDEtZL456zOWQKfcqzOPg33ikFhFFjyA,4899
|
473
473
|
hyperpocket/cli/auth_token.py,sha256=YV1AK70Q_hNsm_xwHP5LTaUWI-omssnX8214JyD3m_w,4875
|
474
|
-
hyperpocket/cli/eject.py,sha256=utzeL4t02ML-EIgpPUiFjCbycjRpvkP1905bLeZAT2Y,321
|
475
|
-
hyperpocket/cli/pull.py,sha256=JnoIsmQwJODWOuilmKR5KKFsdMZ0Ht7pCWIbENJuYfw,275
|
476
474
|
hyperpocket/cli/tool_create.py,sha256=1tsVw_sy28JmeCSXT1j-7dqOsDXzvZPTNqcmHchtcpI,3996
|
477
475
|
hyperpocket/cli/tool_export.py,sha256=NRfssftdb1HEj9DtdM7rh6_rFs1hydYyjpDe7V8kFzU,8060
|
478
476
|
hyperpocket/cli/codegen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -592,12 +590,12 @@ hyperpocket/util/extract_func_param_desc_from_docstring.py,sha256=eGDrbigmVg1zau
|
|
592
590
|
hyperpocket/util/find_all_leaf_class_in_package.py,sha256=06n8R47BDPovxhCOnzu9GuEfeQzEbv-HdG-zfMu1gBw,533
|
593
591
|
hyperpocket/util/find_all_subclass_in_package.py,sha256=TtEb41-nzCNhC9pgelTS6MMxLT_JNZkFPJe5z2H9yik,978
|
594
592
|
hyperpocket/util/flatten_json_schema.py,sha256=iuNBEmMSKFtPi-uqo6fb3RWN0koHOAihWAAofWbd1U8,1671
|
595
|
-
hyperpocket/util/function_to_model.py,sha256=
|
593
|
+
hyperpocket/util/function_to_model.py,sha256=HubCCZOdTWcGy4OpDSEws5pEkkuiqT_aYqM663tdU6U,2381
|
596
594
|
hyperpocket/util/get_objects_from_subpackage.py,sha256=4mR_S8eaJSdU68YfCkiXeIcXxb6q7LjFGsY_IHeNIZw,929
|
597
595
|
hyperpocket/util/git_parser.py,sha256=y96nhgZXtRgA_u_0GTPo95PGkpG-n_oMIrkbckdxiR8,2496
|
598
596
|
hyperpocket/util/json_schema_to_model.py,sha256=nc5AmnqkrdeFLELu-7_O9sEAaUaD8_KGlvIMDRobt-4,3751
|
599
597
|
hyperpocket/util/short_hashing_str.py,sha256=ahLUT8iQr-MJVbDJXrSt0cXnnSEeJ8EU3A0PDn6e0gs,119
|
600
|
-
hyperpocket-0.5.
|
601
|
-
hyperpocket-0.5.
|
602
|
-
hyperpocket-0.5.
|
603
|
-
hyperpocket-0.5.
|
598
|
+
hyperpocket-0.5.3.dist-info/METADATA,sha256=D1F09X8C9Ewl20lLIN2i6pEzdZp8_KtkTrA36rUVxpY,13044
|
599
|
+
hyperpocket-0.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
600
|
+
hyperpocket-0.5.3.dist-info/entry_points.txt,sha256=KpBleaYr0SaENXOa-dFvJ_cvFCHYFEQ4LMl11ShAcBI,61
|
601
|
+
hyperpocket-0.5.3.dist-info/RECORD,,
|
hyperpocket/cli/eject.py
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
import pathlib
|
2
|
-
from typing import Optional
|
3
|
-
|
4
|
-
import click
|
5
|
-
|
6
|
-
import hyperpocket.repository as repository
|
7
|
-
|
8
|
-
|
9
|
-
@click.command()
|
10
|
-
@click.argument("url", type=str)
|
11
|
-
@click.argument("ref", type=str)
|
12
|
-
@click.argument("remote_path", type=str)
|
13
|
-
def eject(url: str, ref: str, remote_path: str):
|
14
|
-
repository.eject(url, ref, remote_path)
|
hyperpocket/cli/pull.py
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import pathlib
|
2
|
-
from typing import Optional
|
3
|
-
|
4
|
-
import click
|
5
|
-
|
6
|
-
import hyperpocket.repository as repository
|
7
|
-
|
8
|
-
|
9
|
-
@click.command()
|
10
|
-
@click.argument("url", type=str)
|
11
|
-
@click.option("--git-ref", type=str, default="HEAD")
|
12
|
-
def pull(url: str, git_ref: str):
|
13
|
-
repository.pull(url, git_ref)
|
File without changes
|
File without changes
|