Skip to main content

No project description provided

Project description

Langchain extensions

Biding Pocket Tools

from langchain_openai import ChatOpenAI

from hyperpocket.config.settings import settings
from hyperpocket_langchain import PocketLangchain

pocket = PocketLangchain(tools=[
    "https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
    "https://github.com/vessl-ai/hyperpocket/tree/main/tools/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

from hyperpocket_langchain import PocketLangchain

pocket = PocketLangchain(tools=[
    "https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
    "https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
])

# get langchain compatible tools from pocket
tools = pocket.get_tools()

llm = ChatOpenAI()

prompt = ChatPromptTemplate.from_messages(
        (
            "system",
            "You are very powerful linear assistant. You can help the user do something like commenting, get some issues",
        ),
        ("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
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperpocket_langchain-0.3.3.tar.gz (116.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperpocket_langchain-0.3.3-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file hyperpocket_langchain-0.3.3.tar.gz.

File metadata

File hashes

Hashes for hyperpocket_langchain-0.3.3.tar.gz
Algorithm Hash digest
SHA256 89354b348cbbfce5da35a67a12bb22b77a574f11336f9605b1d3e8bd4f8110a0
MD5 7858780f0b386b234d3174732fa6c359
BLAKE2b-256 5915b0a47f2485494f0575e3e31fc4aa2e6bda007ddbf04fb9422b314042e46d

See more details on using hashes here.

File details

Details for the file hyperpocket_langchain-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for hyperpocket_langchain-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c6a7cedc0664b1fa3b1daddf47f1e25f7d94dd754f3efc4c72f980d5459299bf
MD5 5f4ababa030f17e7d3d27bf635951237
BLAKE2b-256 02e0c125025ec6ea9676512d59270bb81d279452d5a7d02e02e4a8e32f2bad55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page