Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 58 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ client_id = "<SLACK_CLIENT_ID>"
client_secret = "<SLACK_CLIENT_SECRET>"
```

#### When using Basic Auth

IMPORTANT: You should update `auth_encryption_secret_key` in `{WORKDIR}/.secret.toml` with your own secret key.

```toml
[auth]
auth_encryption_secret_key = "<YOUR_SECRET_KEY>"
```

The secret key should be a 32 Base64 encoded string.

You can generate the secret key with the following command.

```shell
pip install cryptography
python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())'
```

setting openai api key env for this example.

```shell
Expand Down Expand Up @@ -168,32 +186,32 @@ Pocket provides way to use end user auth easily.

- Supported methods

- [x] OAuth
- [x] Token
- [ ] Basic Auth (Username, Password)
- [x] OAuth
- [x] Token
- [ ] Basic Auth (Username, Password)

- Supported OAuth Providers

- [x] Google
- [x] GitHub
- [x] Slack
- [x] Reddit
- [x] Calendly
- [ ] Facebook
- [ ] X (Previously Twitter)
- [ ] LinkedIn
- [ ] Discord
- [ ] Zoom
- [ ] Microsoft
- [ ] Spotify
- [ ] Twitch
- [x] Google
- [x] GitHub
- [x] Slack
- [x] Reddit
- [x] Calendly
- [ ] Facebook
- [ ] X (Previously Twitter)
- [ ] LinkedIn
- [ ] Discord
- [ ] Zoom
- [ ] Microsoft
- [ ] Spotify
- [ ] Twitch

- Supported Token Providers
- [x] Notion
- [x] Slack
- [x] Linear
- [x] Gumloop
- [x] Github
- [x] Notion
- [x] Slack
- [x] Linear
- [x] Gumloop
- [x] Github

You can manage your auths in request-wise level. (e.g. you can use different auths for different requests)

Expand Down Expand Up @@ -315,15 +333,15 @@ client_secret = "" # your slack client secret

- While creating your github OAuth app, configuring your app's `Authorization callback URL` is different for your
development environment and production environment.
- For local testing environment, you can use `https://localhost:8001/proxy/auth/<provider>/callback` for TLS enabled
redirect url. (ex. `https://localhost:8001/proxy/auth/github/callback`)
- **Note**: Default port for hyperpocket dev server is `8000`. If you are using a different port, make sure to
replace `8000` with your actual port number.
- **Note**: But for easy dev experience, you can use TLS proxy on port `8001` provided out-of-the-box.
- You can change the `proxy` prefix in settings.toml to your desired prefix with
`callback_url_rewrite_prefix` key.
- For production environment, you can use `https://yourdomain.com/auth/github/callback`
- **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
- For local testing environment, you can use `https://localhost:8001/proxy/auth/<provider>/callback` for TLS enabled
redirect url. (ex. `https://localhost:8001/proxy/auth/github/callback`)
- **Note**: Default port for hyperpocket dev server is `8000`. If you are using a different port, make sure to
replace `8000` with your actual port number.
- **Note**: But for easy dev experience, you can use TLS proxy on port `8001` provided out-of-the-box.
- You can change the `proxy` prefix in settings.toml to your desired prefix with
`callback_url_rewrite_prefix` key.
- For production environment, you can use `https://yourdomain.com/auth/github/callback`
- **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.

#### How to integrate SLACK OAuth app

Expand All @@ -334,16 +352,16 @@ client_secret = "" # your slack client secret
- Redirect URLs :
`{public_server_protocol}://{public_hostname}:[{public_server_port}]/{callback_url_rewrite_prefix}/auth/slack/oauth2/callback`
- Scopes : What you want to request to user.
- Recommended scopes :
- channels:history,
- channels:read,
- chat:write,
- groups:history,
- groups:read,
- im:history,
- mpim:history,
- reactions:read,
- reactions:write,
- Recommended scopes :
- channels:history,
- channels:read,
- chat:write,
- groups:history,
- groups:read,
- im:history,
- mpim:history,
- reactions:read,
- reactions:write,

3. Set your Slack APP Client ID / Client Secret in `{WORKDIR}/settings.toml`

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import os

from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain.memory import ConversationBufferMemory
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_openai import ChatOpenAI

from hyperpocket_langchain import PocketLangchain


def agent(pocket: PocketLangchain):
tools = pocket.get_tools()

llm = ChatOpenAI(model="gpt-4o", api_key=os.getenv("OPENAI_API_KEY"))

prompt = ChatPromptTemplate.from_messages(
[
("placeholder", "{chat_history}"),
(
"system",
"You are a tool calling assistant. You can help the user by calling proper tools",
),
("placeholder", "{chat_history}"),
("user", "{input}"),
MessagesPlaceholder(variable_name="agent_scratchpad"),
]
)

memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
memory=memory,
verbose=True,
handle_parsing_errors=True,
)

print("\n\n\n")
print("Hello, this is linkedin browseruse agent.")
while True:
print("user(q to quit) : ", end="")
user_input = input()
if user_input == "q":
print("Good bye!")
break

response = agent_executor.invoke({"input": user_input})
print("slack agent : ", response["output"])
print()


if __name__ == "__main__":
with PocketLangchain(
tools=[
"https://github.com/vessl-ai/hyperpocket/tree/kyle/tools/tools/linkedin/get-recent-connections",
"https://github.com/vessl-ai/hyperpocket/tree/kyle/tools/tools/linkedin/send-messages",
],
) as pocket:
agent(pocket)
19 changes: 19 additions & 0 deletions examples/langchain/linkedin-browseruse-agent/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[project]
name = "tool-calling-agent"
version = "0.0.1"
description = "Tool calling agent with hyperpocket and Langchain"
authors = [{ name = "Hyperpocket Team", email = "hyperpocket@vessl.ai" }]
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"hyperdock-container",
"hyperpocket",
"hyperpocket-langchain",
"langchain>=0.3.15",
"langchain-openai>=0.3.1",
]

[tool.uv.sources]
hyperpocket = { path = "../../../libs/hyperpocket", editable = true }
hyperpocket-langchain = { path = "../../../libs/extensions/langchain", editable = true }
hyperdock-container = { path = "../../../libs/docks/hyperdock-container", editable = true }
Empty file.
Loading
Loading