hyperpocket 0.0.3__py3-none-any.whl → 0.1.9__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. hyperpocket/auth/README.md +3 -3
  2. hyperpocket/auth/__init__.py +0 -8
  3. hyperpocket/auth/gumloop/context.py +13 -0
  4. hyperpocket/auth/gumloop/token_context.py +15 -0
  5. hyperpocket/auth/gumloop/token_handler.py +66 -0
  6. hyperpocket/auth/gumloop/token_schema.py +8 -0
  7. hyperpocket/auth/linear/token_context.py +1 -1
  8. hyperpocket/auth/notion/README.md +28 -0
  9. hyperpocket/auth/notion/context.py +15 -0
  10. hyperpocket/auth/notion/token_context.py +14 -0
  11. hyperpocket/auth/notion/token_handler.py +65 -0
  12. hyperpocket/auth/notion/token_schema.py +10 -0
  13. hyperpocket/auth/provider.py +8 -5
  14. hyperpocket/auth/reddit/context.py +15 -0
  15. hyperpocket/auth/reddit/oauth2_context.py +32 -0
  16. hyperpocket/auth/reddit/oauth2_handler.py +151 -0
  17. hyperpocket/auth/reddit/oauth2_schema.py +18 -0
  18. hyperpocket/auth/slack/token_context.py +1 -1
  19. hyperpocket/builtin.py +63 -0
  20. hyperpocket/cli/__main__.py +12 -0
  21. hyperpocket/cli/auth.py +83 -0
  22. hyperpocket/cli/codegen/auth/__init__.py +13 -0
  23. hyperpocket/cli/codegen/auth/auth_context_template.py +16 -0
  24. hyperpocket/cli/codegen/auth/auth_token_context_template.py +16 -0
  25. hyperpocket/cli/codegen/auth/auth_token_handler_template.py +69 -0
  26. hyperpocket/cli/codegen/auth/auth_token_schema_template.py +12 -0
  27. hyperpocket/cli/codegen/auth/server_auth_template.py +18 -0
  28. hyperpocket/cli/eject.py +19 -0
  29. hyperpocket/cli/sync.py +5 -5
  30. hyperpocket/config/settings.py +14 -12
  31. hyperpocket/futures/futurestore.py +0 -1
  32. hyperpocket/pocket_auth.py +25 -5
  33. hyperpocket/pocket_core.py +264 -0
  34. hyperpocket/pocket_main.py +127 -174
  35. hyperpocket/prompts.py +6 -8
  36. hyperpocket/repository/__init__.py +2 -2
  37. hyperpocket/repository/lock.py +71 -1
  38. hyperpocket/repository/lockfile.py +19 -13
  39. hyperpocket/repository/repository.py +26 -1
  40. hyperpocket/server/auth/__init__.py +0 -6
  41. hyperpocket/server/auth/gumloop.py +16 -0
  42. hyperpocket/server/auth/notion.py +19 -0
  43. hyperpocket/server/auth/reddit.py +16 -0
  44. hyperpocket/server/server.py +56 -20
  45. hyperpocket/server/tool/dto/script.py +15 -2
  46. hyperpocket/server/tool/wasm.py +20 -8
  47. hyperpocket/session/README.md +2 -2
  48. hyperpocket/session/in_memory.py +18 -5
  49. hyperpocket/session/interface.py +14 -0
  50. hyperpocket/session/redis.py +29 -5
  51. hyperpocket/tool/README.md +16 -12
  52. hyperpocket/tool/__init__.py +4 -3
  53. hyperpocket/tool/function/README.md +39 -10
  54. hyperpocket/tool/function/__init__.py +2 -0
  55. hyperpocket/tool/function/annotation.py +2 -1
  56. hyperpocket/tool/function/tool.py +108 -29
  57. hyperpocket/tool/tool.py +100 -28
  58. hyperpocket/tool/wasm/README.md +27 -5
  59. hyperpocket/tool/wasm/browser.py +2 -7
  60. hyperpocket/tool/wasm/script.py +40 -1
  61. hyperpocket/tool/wasm/templates/python.py +32 -14
  62. hyperpocket/tool/wasm/tool.py +21 -18
  63. hyperpocket/tool_like.py +5 -0
  64. hyperpocket/util/__init__.py +1 -1
  65. hyperpocket/util/extract_func_param_desc_from_docstring.py +4 -4
  66. hyperpocket/util/function_to_model.py +5 -2
  67. hyperpocket/util/json_schema_to_model.py +47 -26
  68. {hyperpocket-0.0.3.dist-info → hyperpocket-0.1.9.dist-info}/METADATA +107 -88
  69. hyperpocket-0.1.9.dist-info/RECORD +137 -0
  70. {hyperpocket-0.0.3.dist-info → hyperpocket-0.1.9.dist-info}/WHEEL +1 -1
  71. hyperpocket-0.1.9.dist-info/entry_points.txt +2 -0
  72. hyperpocket/auth/README.KR.md +0 -309
  73. hyperpocket/auth/slack/tests/test_oauth2_handler.py +0 -32
  74. hyperpocket/auth/slack/tests/test_token_handler.py +0 -23
  75. hyperpocket/auth/tests/test_google_oauth2_handler.py +0 -147
  76. hyperpocket/auth/tests/test_slack_oauth2_handler.py +0 -147
  77. hyperpocket/auth/tests/test_slack_token_handler.py +0 -66
  78. hyperpocket/external/__init__.py +0 -7
  79. hyperpocket/external/github_client.py +0 -19
  80. hyperpocket/session/README.KR.md +0 -62
  81. hyperpocket/session/tests/test_in_memory.py +0 -145
  82. hyperpocket/session/tests/test_redis.py +0 -151
  83. hyperpocket/tests/test_pocket.py +0 -116
  84. hyperpocket/tests/test_pocket_auth.py +0 -982
  85. hyperpocket/tool/README.KR.md +0 -68
  86. hyperpocket/tool/builtins/__init__.py +0 -0
  87. hyperpocket/tool/builtins/example/__init__.py +0 -0
  88. hyperpocket/tool/builtins/example/add_tool.py +0 -18
  89. hyperpocket/tool/function/README.KR.md +0 -159
  90. hyperpocket/tool/tests/test_function_tool.py +0 -266
  91. hyperpocket/tool/wasm/README.KR.md +0 -144
  92. hyperpocket-0.0.3.dist-info/RECORD +0 -130
  93. hyperpocket-0.0.3.dist-info/entry_points.txt +0 -3
  94. /hyperpocket/auth/{slack/tests → gumloop}/__init__.py +0 -0
  95. /hyperpocket/auth/{tests → notion}/__init__.py +0 -0
  96. /hyperpocket/{session/tests → auth/reddit}/__init__.py +0 -0
  97. /hyperpocket/{tests → cli/codegen}/__init__.py +0 -0
@@ -1,11 +1,11 @@
1
+ import os
1
2
  import json
2
3
  import pathlib
3
4
  from typing import Any, Optional
4
5
 
5
6
  import toml
6
-
7
7
  from hyperpocket.auth import AuthProvider
8
- from hyperpocket.config import pocket_logger
8
+ from hyperpocket.config import settings, pocket_logger
9
9
  from hyperpocket.repository import Lock, Lockfile
10
10
  from hyperpocket.repository.lock import GitLock, LocalLock
11
11
  from hyperpocket.tool import Tool, ToolRequest
@@ -18,26 +18,23 @@ class WasmToolRequest(ToolRequest):
18
18
  lock: Lock
19
19
  rel_path: str
20
20
 
21
- def __init__(self, lock: Lock, rel_path: str):
21
+ def __init__(self, lock: Lock, rel_path: str, tool_vars: dict):
22
22
  self.lock = lock
23
23
  self.rel_path = rel_path
24
+ self.overridden_tool_vars = tool_vars
24
25
 
25
26
  def __str__(self):
26
27
  return f"ToolRequest(lock={self.lock}, rel_path={self.rel_path})"
27
28
 
29
+ def from_local(path: str, tool_vars: Optional[dict[str, str]] = None) -> WasmToolRequest:
30
+ if tool_vars is None:
31
+ tool_vars = dict()
32
+ return WasmToolRequest(LocalLock(path), "", tool_vars)
28
33
 
29
- def from_local(path: str) -> WasmToolRequest:
30
- return WasmToolRequest(LocalLock(path), "")
31
-
32
-
33
- def from_git(repository: str, ref: str, rel_path: str) -> WasmToolRequest:
34
- return WasmToolRequest(GitLock(repository_url=repository, git_ref=ref), rel_path)
35
-
36
-
37
- def from_github(owner: str, repo: str, ref: str, rel_path: str) -> WasmToolRequest:
38
- repository = f"https://github.com/{owner}/{repo}"
39
- return from_git(repository, ref, rel_path)
40
-
34
+ def from_git(repository: str, ref: str, rel_path: str, tool_vars: Optional[dict[str, str]] = None) -> WasmToolRequest:
35
+ if not tool_vars:
36
+ tool_vars = dict()
37
+ return WasmToolRequest(GitLock(repository_url=repository, git_ref=ref), rel_path, tool_vars)
41
38
 
42
39
  class WasmTool(Tool):
43
40
  """
@@ -76,6 +73,7 @@ class WasmTool(Tool):
76
73
  pocket_logger.warning(f"{toolpkg_path} failed to load json schema. error : {e}")
77
74
  json_schema = None
78
75
 
76
+ default_tool_vars = dict()
79
77
  try:
80
78
  with config_path.open("r") as f:
81
79
  config = toml.load(f)
@@ -92,6 +90,7 @@ class WasmTool(Tool):
92
90
  else:
93
91
  raise ValueError("`language` field is required in config.toml")
94
92
  auth = cls._get_auth(config)
93
+ default_tool_vars = config.get("tool_vars", {})
95
94
  except Exception as e:
96
95
  raise ValueError(f"Failed to load config.toml: {e}")
97
96
 
@@ -100,6 +99,7 @@ class WasmTool(Tool):
100
99
  readme = f.read()
101
100
  else:
102
101
  readme = None
102
+
103
103
  return cls(
104
104
  name=name,
105
105
  description=description,
@@ -109,6 +109,9 @@ class WasmTool(Tool):
109
109
  readme=readme,
110
110
  pkg_lock=tool_req.lock,
111
111
  rel_path=tool_req.rel_path,
112
+ postprocessings=tool_req.postprocessings,
113
+ default_tool_vars=default_tool_vars,
114
+ overridden_tool_vars=tool_req.overridden_tool_vars,
112
115
  )
113
116
 
114
117
  @classmethod
@@ -124,7 +127,7 @@ class WasmTool(Tool):
124
127
  auth_handler=auth_handler,
125
128
  scopes=scopes,
126
129
  )
127
-
130
+
128
131
  def template_arguments(self) -> dict[str, str]:
129
132
  return {}
130
133
 
@@ -133,7 +136,7 @@ class WasmTool(Tool):
133
136
  str(self.pkg_lock.toolpkg_path() / self.rel_path),
134
137
  self.runtime,
135
138
  body,
136
- envs,
139
+ envs | self.tool_vars,
137
140
  **kwargs,
138
141
  )
139
142
 
@@ -142,6 +145,6 @@ class WasmTool(Tool):
142
145
  str(self.pkg_lock.toolpkg_path() / self.rel_path),
143
146
  self.runtime,
144
147
  body,
145
- envs,
148
+ envs | self.tool_vars,
146
149
  **kwargs,
147
150
  )
@@ -0,0 +1,5 @@
1
+ from typing import Union, Callable
2
+
3
+ from hyperpocket.tool import ToolRequest, Tool
4
+
5
+ ToolLike = Union[Tool, str, Callable, ToolRequest]
@@ -1 +1 @@
1
- __all__ = ['json_schema_to_model', "tool_to_open_ai_spec"]
1
+ __all__ = ['json_schema_to_model']
@@ -41,13 +41,13 @@ def extract_param_docstring_mapping(func) -> dict[str, str]:
41
41
  pocket_logger.debug(f"try to extract docstring of {func.__name__} by plain text style..")
42
42
  param_descriptions = []
43
43
  for line in docstring.split("\n"):
44
- l = line.strip().split(":")
45
- if len(l) < 2:
44
+ split_line = line.strip().split(":")
45
+ if len(split_line) < 2:
46
46
  continue
47
47
 
48
- param_name = l[0]
48
+ param_name = split_line[0]
49
49
  cleaned_param_name = clean_bracket_content(param_name)
50
- description = ":".join(l[1:]).strip()
50
+ description = ":".join(split_line[1:]).strip()
51
51
  if cleaned_param_name in func_params:
52
52
  param_descriptions.append((cleaned_param_name, description))
53
53
 
@@ -1,6 +1,6 @@
1
1
  import inspect
2
2
  from inspect import signature, Parameter
3
- from typing import Any, Dict, Type, Tuple, List
3
+ from typing import Any, Dict, Type, Tuple
4
4
 
5
5
  from pydantic import BaseModel, create_model
6
6
  from pydantic.fields import FieldInfo
@@ -33,7 +33,10 @@ def function_to_model(func: callable) -> Type[BaseModel]:
33
33
  if param.annotation is Parameter.empty:
34
34
  raise Exception(f"Should all arguments be annotated but {param_name} is not annotated")
35
35
 
36
- if param.annotation.__module__ != "builtins" and not issubclass(param.annotation, BaseModel):
36
+ if param.annotation.__module__ == "typing" and param.annotation.__name__ == "Optional":
37
+ fields[param_name] = (
38
+ param.annotation.__args__[0], FieldInfo(default=param.default, description=param_desc_map.get(param_name, "")))
39
+ elif param.annotation.__module__ != "builtins" and not issubclass(param.annotation, BaseModel):
37
40
  raise Exception(
38
41
  f"currently only support builtin types and pydantic BaseModel but {param_name} is not builtin type")
39
42
 
@@ -1,4 +1,4 @@
1
- from typing import Type
1
+ from typing import Type, Union
2
2
 
3
3
  from pydantic import BaseModel, create_model, Field
4
4
 
@@ -12,32 +12,25 @@ def json_schema_to_model(schema: dict, model_name: str = "DynamicModel") -> Type
12
12
  required_fields = schema.get("required", [])
13
13
  for property_name, property_schema in schema.get("properties", {}).items():
14
14
  field_type, field_default, field_description, required = None, None, None, False
15
- if "type" in property_schema:
16
- json_type = property_schema["type"]
17
- if json_type == "integer":
18
- field_type = int
19
- elif json_type == "string":
20
- field_type = str
21
- elif json_type == "object":
22
- if "properties" in property_schema:
23
- # Recursively create nested models
24
- field_type = json_schema_to_model(property_schema, model_name)
25
- else:
26
- field_type = dict
27
15
 
28
- elif json_type == "array":
29
- # Handle arrays; currently assuming array of objects or primitives
30
- item_schema = property_schema.get("items", {})
31
- if item_schema.get("type") == "object":
32
- field_type = list[json_schema_to_model(item_schema, model_name)]
33
- else:
34
- field_type = list
35
- if "default" in property_schema:
36
- field_default = property_schema["default"]
37
- if "description" in property_schema:
38
- field_description = property_schema["description"]
39
- if property_name in required_fields:
40
- required = True
16
+ if "anyOf" in property_schema:
17
+ types = []
18
+ for item in property_schema["anyOf"]:
19
+ sub_type = _convert_to_python_type(item["type"], model_name, property_schema)
20
+ types.append(sub_type)
21
+
22
+ field_type = Union[tuple(types)]
23
+ elif "type" in property_schema:
24
+ field_type = _convert_to_python_type(property_schema["type"], model_name, property_schema)
25
+ else:
26
+ raise RuntimeError("have no type in json schema.")
27
+
28
+ if "default" in property_schema:
29
+ field_default = property_schema["default"]
30
+ if "description" in property_schema:
31
+ field_description = property_schema["description"]
32
+ if property_name in required_fields:
33
+ required = True
41
34
 
42
35
  if required:
43
36
  fields[property_name] = (field_type, Field(description=field_description))
@@ -67,3 +60,31 @@ def json_schema_to_model(schema: dict, model_name: str = "DynamicModel") -> Type
67
60
  model.Config = Config
68
61
 
69
62
  return model
63
+
64
+
65
+ def _convert_to_python_type(json_type, model_name, property_schema):
66
+ field_type = None
67
+ if json_type == "integer":
68
+ field_type = int
69
+ elif json_type == "string":
70
+ field_type = str
71
+ elif json_type == "boolean":
72
+ field_type = bool
73
+ elif json_type == "number":
74
+ field_type = float
75
+ elif json_type == "none":
76
+ field_type = type(None)
77
+ elif json_type == "object":
78
+ if "properties" in property_schema:
79
+ # Recursively create nested models
80
+ field_type = json_schema_to_model(property_schema, model_name)
81
+ else:
82
+ field_type = dict
83
+ elif json_type == "array":
84
+ # Handle arrays; currently assuming array of objects or primitives
85
+ item_schema = property_schema.get("items", {})
86
+ if item_schema.get("type") == "object":
87
+ field_type = list[json_schema_to_model(item_schema, model_name)]
88
+ else:
89
+ field_type = list
90
+ return field_type
@@ -1,47 +1,41 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: hyperpocket
3
- Version: 0.0.3
3
+ Version: 0.1.9
4
4
  Summary: Building AI agent with hyperpocket tool in a flash
5
- Home-page: https://vessl-ai.github.io/hyperpocket
6
- Author: VESSL AI Devs
7
- Author-email: dev@vessl.ai
8
- Requires-Python: >=3.11,<4.0
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.11
11
- Classifier: Programming Language :: Python :: 3.12
12
- Classifier: Programming Language :: Python :: 3.13
13
- Requires-Dist: click (>=8.1.7,<9.0.0)
14
- Requires-Dist: dynaconf (>=3.2.6,<4.0.0)
15
- Requires-Dist: fastapi (>=0.115.5,<0.116.0)
16
- Requires-Dist: gitpython (>=3.1.43,<4.0.0)
17
- Requires-Dist: httpx (==0.27)
18
- Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
19
- Requires-Dist: multiprocess (>=0.70.17,<0.71.0)
20
- Requires-Dist: playwright (>=1.49.0,<2.0.0)
21
- Requires-Dist: pydantic (>=2.10.2,<3.0.0)
22
- Requires-Dist: pygithub (>=2.5.0,<3.0.0)
23
- Requires-Dist: python-multipart (>=0.0.19,<0.0.20)
24
- Requires-Dist: redis (>=5.2.1,<6.0.0)
25
- Requires-Dist: requests (>=2.32.3,<3.0.0)
26
- Requires-Dist: toml (>=0.10.2,<0.11.0)
27
- Requires-Dist: uvicorn (>=0.32.1,<0.33.0)
5
+ Project-URL: Homepage, https://vessl-ai.github.io/hyperpocket
28
6
  Project-URL: Repository, https://github.com/vessl-ai/hyperpocket
7
+ Author-email: Hyperpocket Team <hyperpocket@vessl.ai>
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: click>=8.1.7
10
+ Requires-Dist: dynaconf>=3.2.6
11
+ Requires-Dist: fastapi>=0.115.5
12
+ Requires-Dist: gitpython>=3.1.43
13
+ Requires-Dist: httpx==0.27
14
+ Requires-Dist: jinja2>=3.1.4
15
+ Requires-Dist: multiprocess>=0.70.17
16
+ Requires-Dist: playwright>=1.49.0
17
+ Requires-Dist: pydantic>=2.10.2
18
+ Requires-Dist: pygithub>=2.5.0
19
+ Requires-Dist: python-multipart>=0.0.19
20
+ Requires-Dist: redis>=5.2.1
21
+ Requires-Dist: requests>=2.32.3
22
+ Requires-Dist: toml>=0.10.2
23
+ Requires-Dist: uvicorn>=0.32.1
29
24
  Description-Content-Type: text/markdown
30
25
 
31
- # Pocket 👛
26
+ # Hyperpocket 👛
32
27
 
33
- Pocket is where tools belong. Power your agent up with a pocket of tools. 👛
28
+ Hyperpocket is where tools belong. Power your agent up with a pocket of tools. 👛
34
29
 
35
30
  <figure>
36
- <img src="image.png" alt="4d-pocket" width="200"/>
37
- <figcaption>© Doraemon</figcaption>
31
+ <img src="../../logo.png" alt="hyperpocket" width="200"/>
38
32
  </figure>
39
33
 
40
34
  ## Introduction
41
35
 
42
- Pocket is a tool that allows you to easily use tool and auth for agents on your machine.
36
+ Hyperpocket is a tool that allows you to easily use tool and auth for agents on your machine.
43
37
 
44
- **_Start fast._** Just install Pocket and use it. We know you don't have time to authenticate to our server.
38
+ **_Start fast._** Just install Hyperpocket and use it. We know you don't have time to authenticate to our server.
45
39
 
46
40
  **_Go securely._** Not like others, you are the only one who knows your secret tokens. We do NOT. All of your secret
47
41
  tokens belong to your infrastructure, not ours.
@@ -52,17 +46,12 @@ with the dependency spaghetti.
52
46
 
53
47
  **_Battery Included_** You can use popular tools and authentication providers out-of-the-box.
54
48
 
55
- <figure>
56
- <img src="pocket1.png" alt="pocket-flow" width="400"/>
57
- <figcaption></figcaption>
58
- </figure>
59
-
60
49
  ## Installation
61
50
 
62
- 1. install pocket
51
+ 1. install hyperpocket
63
52
 
64
53
  ```bash
65
- pip install pocket
54
+ pip install hyperpocket
66
55
  ```
67
56
 
68
57
  2. install playwright
@@ -87,17 +76,15 @@ Or just use LLM API Clients out of the box.
87
76
  ### Using out-of-the-box tools
88
77
 
89
78
  ```python
79
+ from hyperpocket.tool import from_git
90
80
  from langchain_openai import ChatOpenAI
91
81
 
92
- import hyperpocket as pk
93
- import hyperpocket.curated_tools
94
- from pocket_langchain import PocketLangchain
82
+ from hyperpocket_langchain import PocketLangchain
95
83
 
96
84
  pklc = PocketLangchain(
97
85
  tools=[
98
- *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
99
- *pk.curated_tools.LINEAR,
100
- "https://github.com/my-org/some-awesome-tool",
86
+ from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
87
+ from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
101
88
  ]
102
89
  )
103
90
  tools = pklc.get_tools()
@@ -111,45 +98,43 @@ llm_tool_binding.invoke(...)
111
98
 
112
99
  There are two kinds of auth process, one is using system auth(developer api key) and the other is using end user auth.
113
100
 
114
- Pocket provides way to use end user auth easily.
101
+ Hyperpocket provides way to use end user auth easily.
115
102
  (Of course, you can also just set your STRIPE_API_KEY when using Stripe API related tools)
116
103
 
117
104
  - Supported methods
118
105
 
119
- - [x] OAuth
120
- - [x] Token
121
- - [ ] Basic Auth (Username, Password)
106
+ - [x] OAuth
107
+ - [x] Token
108
+ - [ ] Basic Auth (Username, Password)
122
109
 
123
110
  - Supported OAuth Providers
124
- - [x] Google
125
- - [x] GitHub
126
- - [x] Slack
127
- - [x] Linear
128
- - [ ] Facebook
129
- - [ ] X (Previously Twitter)
130
- - [ ] LinkedIn
131
- - [ ] Discord
132
- - [ ] Zoom
133
- - [ ] Microsoft
134
- - [ ] Spotify
135
- - [ ] Twitch
111
+ - [x] Google
112
+ - [x] GitHub
113
+ - [x] Slack
114
+ - [x] Linear
115
+ - [ ] Facebook
116
+ - [ ] X (Previously Twitter)
117
+ - [ ] LinkedIn
118
+ - [ ] Discord
119
+ - [ ] Zoom
120
+ - [ ] Microsoft
121
+ - [ ] Spotify
122
+ - [ ] Twitch
136
123
 
137
124
  You can manage your auths in request-wise level. (e.g. you can use different auths for different requests)
138
125
 
139
126
  ```python
127
+ from hyperpocket.tool import from_git
140
128
  from langchain_openai import ChatOpenAI
141
129
  from langgraph.graph import StateGraph, START, MessagesState
142
130
  from langgraph.prebuilt import tools_condition
143
131
 
144
- import hyperpocket as pk
145
- import hyperpocket.curated_tools
146
- from pocket_langgraph import PocketLanggraph
132
+ from hyperpocket_langgraph import PocketLanggraph
147
133
 
148
134
  pklg = PocketLanggraph(
149
135
  tools=[
150
- *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
151
- *pk.curated_tools.LINEAR,
152
- "https://github.com/my-org/some-awesome-tool",
136
+ from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
137
+ from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
153
138
  ],
154
139
  )
155
140
  llm = ChatOpenAI()
@@ -175,12 +160,12 @@ graph_builder.compile()
175
160
  ```
176
161
 
177
162
  ```python
163
+ from hyperpocket.config import secret
164
+ from hyperpocket.tool import from_git
178
165
  from llama_index.core.agent import FunctionCallingAgent
179
166
  from llama_index.llms.openai import OpenAI
180
- from pocket_llamaindex import PocketLlamaindex
181
167
 
182
- from hyperpocket.config import secret
183
- from hyperpocket.tool import from_git
168
+ from hyperpocket_llamaindex import PocketLlamaindex
184
169
 
185
170
  llm = OpenAI(api_key=secret["OPENAI_API_KEY"])
186
171
  pocket = PocketLlamaindex(
@@ -227,12 +212,8 @@ Assistance: Here are the recent 10 messages.
227
212
 
228
213
  ### Config
229
214
 
230
- Running `pocket config init` will create your config file in `$HOME/.pocket/settings.toml`
231
-
232
215
  The `settings.toml` looks as follows.
233
216
 
234
- TODO: Add `secrets.toml`.
235
-
236
217
  ```toml
237
218
  log_level = "debug"
238
219
  internal_server_port = "8000" # optional, default is 8000
@@ -273,11 +254,11 @@ client_secret = "" # your github client secret
273
254
 
274
255
  - While creating your github OAuth app, configuring your app's `Authorization callback URL` is different for your
275
256
  development environment and production environment.
276
- - For development environment, you can use `http://localhost:8000/auth/github/callback`
277
- - **Note**: Default port for pocket dev server is `8000`. If you are using a different port, make sure to
278
- replace `8000` with your actual port number.
279
- - For production environment, you can use `https://yourdomain.com/auth/github/callback`
280
- - **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
257
+ - For development environment, you can use `http://localhost:8000/auth/github/callback`
258
+ - **Note**: Default port for hyperpocket dev server is `8000`. If you are using a different port, make sure to
259
+ replace `8000` with your actual port number.
260
+ - For production environment, you can use `https://yourdomain.com/auth/github/callback`
261
+ - **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
281
262
 
282
263
  #### How to integrate SLACK OAuth app
283
264
 
@@ -288,15 +269,53 @@ client_secret = "" # your github client secret
288
269
  - Redirect URLs :
289
270
  `{public_server_protocol}://{public_hostname}:[{public_server_port}]/{callback_url_rewrite_prefix}/auth/slack/oauth2/callback`
290
271
  - Scopes : What you want to request to user.
291
- - Recommended scopes :
292
- - channels:history,
293
- - channels:read,
294
- - chat:write,
295
- - groups:history,
296
- - groups:read,
297
- - im:history,
298
- - mpim:history,
299
- - reactions:read,
300
- - reactions:write,
272
+ - Recommended scopes :
273
+ - channels:history,
274
+ - channels:read,
275
+ - chat:write,
276
+ - groups:history,
277
+ - groups:read,
278
+ - im:history,
279
+ - mpim:history,
280
+ - reactions:read,
281
+ - reactions:write,
301
282
 
302
283
  3. Set your Slack APP Client ID / Client Secret in `$HOME/.pocket/settings.toml`
284
+
285
+ #### How to start adding a new token auth
286
+
287
+ 1. Generate boilerplate codes for token-based auth services ?
288
+
289
+ ```
290
+ # service_name should be lowercase including underscore
291
+ poetry run hyperpocket devtool create-token-auth-template {service_name}
292
+ ```
293
+
294
+ It will generate boilerplate code lines for a new token-based auth service
295
+
296
+ 2. Extend AuthProvider enum to add your new auth provider.
297
+
298
+ ```python
299
+ class AuthProvider(Enum):
300
+ SERVICE = 'service'
301
+ ```
302
+
303
+ 3. Specify auth provider for tools
304
+
305
+ 1) github repo or local
306
+
307
+ ```toml
308
+ [auth]
309
+ auth_provider = "{service_name}"
310
+ auth_handler = "{service_name}-token"
311
+ scopes = []
312
+ ```
313
+
314
+ 2. function_tool
315
+
316
+ ```python
317
+ @function_tool(
318
+ auth_provider=AuthProvider.SERVICE
319
+ )
320
+ def my_function(**kwargs):
321
+ ```