No project description provided
Project description
Langchain extensions
Biding Pocket Tools
from langchain_openai import ChatOpenAI
from hyperpocket.config.settings import settings
from pocket_langchain import PocketLangchain
pocket = PocketLangchain(tools=[
'https://github.com/vessl-ai/tool-calling/tree/main/examples/slack-get-message',
'https://github.com/vessl-ai/tool-calling/tree/main/examples/slack-post-message',
])
# get langchain compatible tools from pocket
tools = pocket.get_tools()
llm = ChatOpenAI(
model="gpt-4o",
api_key=settings["OPENAI_API_KEY"]
)
# bind tool with llm
llm_with_tools = llm.bind_tools(tools)
Agent Examples
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain.memory import ConversationBufferMemory
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_openai import ChatOpenAI
import hyperpocket as pk
from pocket_langchain import PocketLangchain
pocket = PocketLangchain(tools=[
*pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
*pk.curated_tools.LINEAR,
"https://github.com/my-org/some-awesome-tool",
])
# get langchain compatible tools from pocket
tools = pocket.get_tools()
llm = ChatOpenAI()
prompt = ChatPromptTemplate.from_messages(
[
("placeholder", "{chat_history}"),
(
"system",
"You are very powerful linear assistant. You can help the user do something like commenting, get some issues",
),
("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
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hyperpocket_langchain-0.0.2.tar.gz.
File metadata
- Download URL: hyperpocket_langchain-0.0.2.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.10 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fd0af33286176a0027f5a2e6eea9f4ab2b4e2b29d4d9d3033c1467c5033bd59
|
|
| MD5 |
76cfa160013ebc5d43747e45509010ec
|
|
| BLAKE2b-256 |
ef7d24289443f853b1405cdcd547f8e35c3339111905d4f542048274c07682a9
|
File details
Details for the file hyperpocket_langchain-0.0.2-py3-none-any.whl.
File metadata
- Download URL: hyperpocket_langchain-0.0.2-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.10 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a9afb6e4e5b592e2c1eefec0eb7c863df9364292b236b1b59c7be9213e1dcd1
|
|
| MD5 |
15fdb005beb523eae8f3cff330ab3620
|
|
| BLAKE2b-256 |
0a470e6236b425c743da38cb6bcb2f5558e4c56ed7a85897a46ed0a5c0dab574
|