hyperpocket 0.2.0__tar.gz → 0.3.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- hyperpocket-0.3.0/PKG-INFO +377 -0
- hyperpocket-0.3.0/README.md +352 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/reddit/oauth2_handler.py +1 -1
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/oauth2_handler.py +1 -1
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/__main__.py +4 -2
- hyperpocket-0.3.0/hyperpocket/cli/auth_oauth2.py +90 -0
- hyperpocket-0.2.0/hyperpocket/cli/auth.py → hyperpocket-0.3.0/hyperpocket/cli/auth_token.py +32 -25
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/codegen/auth/__init__.py +8 -1
- hyperpocket-0.3.0/hyperpocket/cli/codegen/auth/auth_oauth2_context_template.py +38 -0
- hyperpocket-0.3.0/hyperpocket/cli/codegen/auth/auth_oauth2_handler_template.py +158 -0
- hyperpocket-0.3.0/hyperpocket/cli/codegen/auth/auth_oauth2_schema_template.py +20 -0
- hyperpocket-0.3.0/hyperpocket/cli/codegen/auth/server_auth_template.py +50 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/pocket_core.py +58 -32
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/pocket_main.py +1 -1
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/pyproject.toml +1 -1
- hyperpocket-0.3.0/tests/test_pocket_core.py +101 -0
- hyperpocket-0.2.0/PKG-INFO +0 -326
- hyperpocket-0.2.0/README.md +0 -301
- hyperpocket-0.2.0/hyperpocket/cli/codegen/auth/server_auth_template.py +0 -19
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/.gitignore +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/README.md +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/calendly/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/calendly/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/calendly/oauth2_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/calendly/oauth2_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/calendly/oauth2_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/oauth2_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/oauth2_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/oauth2_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/token_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/github/token_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/google/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/google/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/google/oauth2_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/google/oauth2_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/google/oauth2_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/gumloop/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/gumloop/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/gumloop/token_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/gumloop/token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/gumloop/token_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/linear/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/linear/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/linear/token_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/linear/token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/linear/token_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/notion/README.md +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/notion/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/notion/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/notion/token_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/notion/token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/notion/token_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/provider.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/reddit/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/reddit/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/reddit/oauth2_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/reddit/oauth2_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/oauth2_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/oauth2_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/token_context.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/auth/slack/token_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/builtin.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/codegen/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/codegen/auth/auth_context_template.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/codegen/auth/auth_token_context_template.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/codegen/auth/auth_token_handler_template.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/codegen/auth/auth_token_schema_template.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/eject.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/pull.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/cli/sync.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/config/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/config/auth.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/config/git.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/config/logger.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/config/session.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/config/settings.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/constants.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/futures/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/futures/futurestore.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/pocket_auth.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/prompts.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/repository/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/repository/lock.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/repository/lockfile.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/repository/repository.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/calendly.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/github.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/google.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/gumloop.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/linear.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/notion.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/reddit.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/slack.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/auth/token.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/proxy.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/server.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/tool/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/tool/dto/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/tool/dto/script.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/server/tool/wasm.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/session/README.md +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/session/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/session/in_memory.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/session/interface.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/session/redis.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/README.md +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/function/README.md +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/function/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/function/annotation.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/function/tool.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/tests/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/tool.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/README.md +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/browser.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/invoker.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/script.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/templates/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/templates/node.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/templates/python.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool/wasm/tool.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/tool_like.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/extract_func_param_desc_from_docstring.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/find_all_leaf_class_in_package.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/find_all_subclass_in_package.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/flatten_json_schema.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/function_to_model.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/get_objects_from_subpackage.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/hyperpocket/util/json_schema_to_model.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/auth/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/auth/test_google_oauth2_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/auth/test_gumloop_token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/auth/test_notion_token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/auth/test_slack_oauth2_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/auth/test_slack_token_handler.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/session/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/session/test_in_memory.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/session/test_redis.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/test_pocket.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/test_pocket_auth.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/tool/__init__.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/tool/test_function_tool.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/tool/test_wasm_tool.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/tests/utils/test_extract_func_param_desc_from_docstring.py +0 -0
- {hyperpocket-0.2.0 → hyperpocket-0.3.0}/uv.lock +0 -0
@@ -0,0 +1,377 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: hyperpocket
|
3
|
+
Version: 0.3.0
|
4
|
+
Summary: Building AI agent with hyperpocket tool in a flash
|
5
|
+
Project-URL: Homepage, https://vessl-ai.github.io/hyperpocket
|
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
|
24
|
+
Description-Content-Type: text/markdown
|
25
|
+
|
26
|
+
<p align="center">
|
27
|
+
<img src="logo.png" alt="hyperpocket" width="570"/>
|
28
|
+
</p>
|
29
|
+
|
30
|
+
# Hyperpocket 👛
|
31
|
+
|
32
|
+
Hyperpocket is where tools belong. Power your agent up with a pocket of tools. 👛
|
33
|
+
|
34
|
+
## Introduction
|
35
|
+
|
36
|
+
Hyperpocket is a tool that allows you to easily use tool and auth for agents on your machine.
|
37
|
+
|
38
|
+
**_Start fast._** Just install Hyperpocket and use it. We know you don't have time to authenticate to our server.
|
39
|
+
|
40
|
+
**_Go securely._** Not like others, you are the only one who knows your secret tokens. We do NOT. All of your secret
|
41
|
+
tokens belong to your infrastructure, not ours.
|
42
|
+
|
43
|
+
**_Power up with public tools._** Without worries for tool integration, use others' tools just with copy-and-paste the
|
44
|
+
link to the tool. Your tool will run on isolated environment based on WebAssembly technology, and you don't have to deal
|
45
|
+
with the dependency spaghetti.
|
46
|
+
|
47
|
+
**_Battery Included_** You can use popular tools and authentication providers out-of-the-box.
|
48
|
+
|
49
|
+
## Getting Started
|
50
|
+
|
51
|
+
getting started langchain tool-calling-agent example with hyperpocket
|
52
|
+
|
53
|
+
### 1. Prerequisite
|
54
|
+
|
55
|
+
install hyperpocket package
|
56
|
+
|
57
|
+
```shell
|
58
|
+
pip install hyperpocket_langchain
|
59
|
+
pip install langchain_openai
|
60
|
+
```
|
61
|
+
|
62
|
+
install playwright
|
63
|
+
|
64
|
+
```shell
|
65
|
+
playwright install
|
66
|
+
```
|
67
|
+
|
68
|
+
### 2. Configuration
|
69
|
+
|
70
|
+
setting hyperpocket config in your current working directory
|
71
|
+
|
72
|
+
`${WORKDIR}/.secret.toml`
|
73
|
+
|
74
|
+
```toml
|
75
|
+
[auth.slack]
|
76
|
+
client_id = "<SLACK_CLIENT_ID>"
|
77
|
+
client_secret = "<SLACK_CLIENT_SECRET>"
|
78
|
+
```
|
79
|
+
|
80
|
+
setting openai api key env for this example.
|
81
|
+
|
82
|
+
```shell
|
83
|
+
export OPENAI_API_KEY=<OPENAI_API_KEY>
|
84
|
+
```
|
85
|
+
|
86
|
+
### 3. Writing code
|
87
|
+
|
88
|
+
`langchain_example.py`
|
89
|
+
|
90
|
+
```python
|
91
|
+
import os
|
92
|
+
|
93
|
+
from langchain.agents import AgentExecutor, create_tool_calling_agent
|
94
|
+
from langchain.memory import ConversationBufferMemory
|
95
|
+
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
96
|
+
from langchain_openai import ChatOpenAI
|
97
|
+
|
98
|
+
from hyperpocket_langchain import PocketLangchain
|
99
|
+
|
100
|
+
if __name__ == '__main__':
|
101
|
+
pocket = PocketLangchain(
|
102
|
+
tools=[
|
103
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
104
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
105
|
+
],
|
106
|
+
)
|
107
|
+
tools = pocket.get_tools()
|
108
|
+
llm = ChatOpenAI(model="gpt-4o", api_key=os.getenv("OPENAI_API_KEY"))
|
109
|
+
prompt = ChatPromptTemplate.from_messages(
|
110
|
+
[
|
111
|
+
(
|
112
|
+
"system",
|
113
|
+
"You are a tool calling assistant. You can help the user by calling proper tools",
|
114
|
+
),
|
115
|
+
("placeholder", "{chat_history}"),
|
116
|
+
("user", "{input}"),
|
117
|
+
MessagesPlaceholder(variable_name="agent_scratchpad"),
|
118
|
+
]
|
119
|
+
)
|
120
|
+
|
121
|
+
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
122
|
+
agent = create_tool_calling_agent(llm, tools, prompt)
|
123
|
+
agent_executor = AgentExecutor(
|
124
|
+
agent=agent,
|
125
|
+
tools=tools,
|
126
|
+
memory=memory,
|
127
|
+
verbose=True,
|
128
|
+
handle_parsing_errors=True,
|
129
|
+
)
|
130
|
+
|
131
|
+
print("Hello, This is simple slack agent using hyperpocket.")
|
132
|
+
while True:
|
133
|
+
print("user(q to quit) : ", end="")
|
134
|
+
user_input = input()
|
135
|
+
|
136
|
+
if user_input is None or user_input == "":
|
137
|
+
continue
|
138
|
+
elif user_input == "q":
|
139
|
+
print("Good bye!")
|
140
|
+
break
|
141
|
+
|
142
|
+
response = agent_executor.invoke({"input": user_input})
|
143
|
+
print("agent : ", response["output"])
|
144
|
+
print()
|
145
|
+
```
|
146
|
+
|
147
|
+
### 4. Done !
|
148
|
+
|
149
|
+
```shell
|
150
|
+
python langchain_example.py
|
151
|
+
```
|
152
|
+
|
153
|
+
## Usage
|
154
|
+
|
155
|
+
Supported agent frameworks
|
156
|
+
|
157
|
+
- [x] Langgraph [link](https://www.langchain.com/langgraph)
|
158
|
+
- [x] Langchain [link](https://www.langchain.com/)
|
159
|
+
- [x] Llamaindex [link](https://www.llamaindex.ai/)
|
160
|
+
|
161
|
+
Or just use LLM API Clients out of the box.
|
162
|
+
|
163
|
+
- [x] OpenAI [link](https://openai.com/)
|
164
|
+
- [x] Anthropic [link](https://www.anthropic.com/)
|
165
|
+
|
166
|
+
### Using out-of-the-box tools
|
167
|
+
|
168
|
+
```python
|
169
|
+
|
170
|
+
from langchain_openai import ChatOpenAI
|
171
|
+
|
172
|
+
from hyperpocket_langchain import PocketLangchain
|
173
|
+
|
174
|
+
pklc = PocketLangchain(
|
175
|
+
tools=[
|
176
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
177
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
178
|
+
]
|
179
|
+
)
|
180
|
+
tools = pklc.get_tools()
|
181
|
+
|
182
|
+
llm = ChatOpenAI()
|
183
|
+
llm_tool_binding = llm.bind_tools(tools)
|
184
|
+
llm_tool_binding.invoke(...)
|
185
|
+
```
|
186
|
+
|
187
|
+
### Using out-of-the-box auth for various tools
|
188
|
+
|
189
|
+
There are two kinds of auth process, one is using system auth(developer api key) and the other is using end user auth.
|
190
|
+
|
191
|
+
Pocket provides way to use end user auth easily.
|
192
|
+
(Of course, you can also just set your STRIPE_API_KEY when using Stripe API related tools)
|
193
|
+
|
194
|
+
- Supported methods
|
195
|
+
|
196
|
+
- [x] OAuth
|
197
|
+
- [x] Token
|
198
|
+
- [ ] Basic Auth (Username, Password)
|
199
|
+
|
200
|
+
- Supported OAuth Providers
|
201
|
+
|
202
|
+
- [x] Google
|
203
|
+
- [x] GitHub
|
204
|
+
- [x] Slack
|
205
|
+
- [x] Reddit
|
206
|
+
- [x] Calendly
|
207
|
+
- [ ] Facebook
|
208
|
+
- [ ] X (Previously Twitter)
|
209
|
+
- [ ] LinkedIn
|
210
|
+
- [ ] Discord
|
211
|
+
- [ ] Zoom
|
212
|
+
- [ ] Microsoft
|
213
|
+
- [ ] Spotify
|
214
|
+
- [ ] Twitch
|
215
|
+
|
216
|
+
- Supported Token Providers
|
217
|
+
- [x] Notion
|
218
|
+
- [x] Slack
|
219
|
+
- [x] Linear
|
220
|
+
- [x] Gumloop
|
221
|
+
- [x] Github
|
222
|
+
|
223
|
+
You can manage your auths in request-wise level. (e.g. you can use different auths for different requests)
|
224
|
+
|
225
|
+
```python
|
226
|
+
|
227
|
+
from langchain_openai import ChatOpenAI
|
228
|
+
from langgraph.graph import StateGraph, START, MessagesState
|
229
|
+
from langgraph.prebuilt import tools_condition
|
230
|
+
|
231
|
+
from hyperpocket_langgraph import PocketLanggraph
|
232
|
+
|
233
|
+
pklg = PocketLanggraph(
|
234
|
+
tools=[
|
235
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
236
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
237
|
+
],
|
238
|
+
)
|
239
|
+
llm = ChatOpenAI()
|
240
|
+
|
241
|
+
# Langgraph
|
242
|
+
pk_tool_node = pklg.get_tool_node()
|
243
|
+
llm_tool_binding = llm.bind_tools(pklg.get_tools())
|
244
|
+
|
245
|
+
# ...
|
246
|
+
|
247
|
+
graph_builder = StateGraph(MessagesState)
|
248
|
+
|
249
|
+
graph_builder.add_node('llm', llm)
|
250
|
+
graph_builder.add_node('tools', pk_tool_node)
|
251
|
+
graph_builder.add_edge(START, llm)
|
252
|
+
graph_builder.add_conditional_edges("llm", tools_condition)
|
253
|
+
graph_builder.add_edge(pk_tool_node, llm)
|
254
|
+
|
255
|
+
# ...
|
256
|
+
|
257
|
+
graph_builder.compile()
|
258
|
+
|
259
|
+
```
|
260
|
+
|
261
|
+
```python
|
262
|
+
import os
|
263
|
+
|
264
|
+
from llama_index.core.agent import FunctionCallingAgent
|
265
|
+
from llama_index.llms.openai import OpenAI
|
266
|
+
|
267
|
+
from hyperpocket_llamaindex import PocketLlamaindex
|
268
|
+
|
269
|
+
llm = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
270
|
+
pocket = PocketLlamaindex(
|
271
|
+
tools=[
|
272
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
273
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
274
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/linear/get-issues",
|
275
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/google/get-calendar-events",
|
276
|
+
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/google/get-calendar-list",
|
277
|
+
]
|
278
|
+
)
|
279
|
+
tools = pocket.get_tools()
|
280
|
+
|
281
|
+
agent = FunctionCallingAgent.from_tools(tools=tools, llm=llm)
|
282
|
+
```
|
283
|
+
|
284
|
+
### Auth flow included
|
285
|
+
|
286
|
+
```text
|
287
|
+
Human: List my slack messages in 'general' channel
|
288
|
+
|
289
|
+
Assistance: It looks like you need to authenticate to access the Slack messages. Please use [this link](https://slack.com/oauth/v2/authorize?user_scope=SCOPES&client_id=CLIENT_ID&redirect_uri=REDIRECT_URL) to authenticate your Slack account, and then let me know when you're done!
|
290
|
+
|
291
|
+
Human: done.
|
292
|
+
|
293
|
+
Assistance: Here are the recent 10 messages.
|
294
|
+
(...)
|
295
|
+
```
|
296
|
+
|
297
|
+
### Config
|
298
|
+
|
299
|
+
Running `hyperpocket config init` will create your config file in `${WORKDIR}/settings.toml` and
|
300
|
+
`${WORKDIR}/.secrets.toml`
|
301
|
+
|
302
|
+
The `settings.toml` looks as follows.
|
303
|
+
|
304
|
+
```toml
|
305
|
+
log_level = "debug"
|
306
|
+
internal_server_port = "8000" # optional, default is 8000
|
307
|
+
public_hostname = "localhost" # optional, default is localhost
|
308
|
+
public_server_protocol = "https" # optional, default is https
|
309
|
+
public_server_port = "8001" # optional, default is 8001
|
310
|
+
enable_local_callback_proxy = "true" # optional, default is true, can be turned off when running in production behind TLS termination
|
311
|
+
callback_url_rewrite_prefix = "proxy" # optional, default is proxy, auth callback url prefix
|
312
|
+
|
313
|
+
[session]
|
314
|
+
session_type = "redis" # optional, default is in-memory
|
315
|
+
[session.redis]
|
316
|
+
host = "localhost"
|
317
|
+
port = 6379
|
318
|
+
db = 0
|
319
|
+
|
320
|
+
[auth.slack] # add your slack app's client id and secret for slack auth
|
321
|
+
client_id = "" # your slack client id
|
322
|
+
client_secret = "" # your slack client secret
|
323
|
+
```
|
324
|
+
|
325
|
+
Or you put some sensitive data on `{WORKDIR}/.secrets.toml`
|
326
|
+
|
327
|
+
```toml
|
328
|
+
[auth.slack] # add your slack app's client id and secret for slack auth
|
329
|
+
client_id = "" # your slack client id
|
330
|
+
client_secret = "" # your slack client secret
|
331
|
+
```
|
332
|
+
|
333
|
+
- in this case, by putting your slack app client_id and client_secret on `.secrets.toml`, you can manage your sensitive
|
334
|
+
data more safely.
|
335
|
+
|
336
|
+
#### How to integrate github OAuth app
|
337
|
+
|
338
|
+
1. Follow the github documentation to create a new OAuth
|
339
|
+
app. https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app
|
340
|
+
|
341
|
+
- While creating your github OAuth app, configuring your app's `Authorization callback URL` is different for your
|
342
|
+
development environment and production environment.
|
343
|
+
- For local testing environment, you can use `https://localhost:8001/proxy/auth/<provider>/callback` for TLS enabled
|
344
|
+
redirect url. (ex. `https://localhost:8001/proxy/auth/github/callback`)
|
345
|
+
- **Note**: Default port for hyperpocket dev server is `8000`. If you are using a different port, make sure to
|
346
|
+
replace `8000` with your actual port number.
|
347
|
+
- **Note**: But for easy dev experience, you can use TLS proxy on port `8001` provided out-of-the-box.
|
348
|
+
- You can change the `proxy` prefix in settings.toml to your desired prefix with
|
349
|
+
`callback_url_rewrite_prefix` key.
|
350
|
+
- For production environment, you can use `https://yourdomain.com/auth/github/callback`
|
351
|
+
- **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
|
352
|
+
|
353
|
+
#### How to integrate SLACK OAuth app
|
354
|
+
|
355
|
+
1. Follow the slack documentation to create a new Oauth APP. https://api.slack.com/quickstart
|
356
|
+
|
357
|
+
2. Setting Redirect URLs, Scopes at OAuth & Permissions tap in slack APP page
|
358
|
+
|
359
|
+
- Redirect URLs :
|
360
|
+
`{public_server_protocol}://{public_hostname}:[{public_server_port}]/{callback_url_rewrite_prefix}/auth/slack/oauth2/callback`
|
361
|
+
- Scopes : What you want to request to user.
|
362
|
+
- Recommended scopes :
|
363
|
+
- channels:history,
|
364
|
+
- channels:read,
|
365
|
+
- chat:write,
|
366
|
+
- groups:history,
|
367
|
+
- groups:read,
|
368
|
+
- im:history,
|
369
|
+
- mpim:history,
|
370
|
+
- reactions:read,
|
371
|
+
- reactions:write,
|
372
|
+
|
373
|
+
3. Set your Slack APP Client ID / Client Secret in `{WORKDIR}/settings.toml`
|
374
|
+
|
375
|
+
## Special thanks
|
376
|
+
|
377
|
+
- [tott](https://x.com/tott____) for drawing the cute possum in a pocket.
|