Skip to main content

No project description provided

Project description

Langchain extensions

Biding Pocket Tools

from hyperpocket.config.settings import settings
from hyperpocket.tool import from_git
from langchain_openai import ChatOpenAI

from hyperpocket_langchain import PocketLangchain

pocket = PocketLangchain(tools=[
    from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
    from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-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 hyperpocket.tool import from_git
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=[
    from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/get-message"),
    from_git("https://github.com/vessl-ai/hyperawesometools", "main", "managed-tools/slack/post-message"),
])

# 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


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.1.8.tar.gz (103.0 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.1.8-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hyperpocket_langchain-0.1.8.tar.gz
Algorithm Hash digest
SHA256 bbbc9bc4f0956b528c5b7e95c145a0eddb9a8aac6d43ebf4db7dfb46177b98f7
MD5 93f84903d3d26c6a9e7f9b1d0e3b9508
BLAKE2b-256 9b189f34adc4a6cef6fe8b498cb13b2a2fb98d7fe6efd1c7e4c5a5eb021ec972

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hyperpocket_langchain-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fe125098fc551c480d0778d2ccffa6783e25bac0a088d71dc5f10a7b78e922d4
MD5 22d79fc01c4d8fed01ce124d047ad9d2
BLAKE2b-256 2231ad49905b5686be633027992af294b9dccfcf3339846da92534a07c7e1203

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