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 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


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.0.1.tar.gz (2.1 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.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hyperpocket_langchain-0.0.1.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

Hashes for hyperpocket_langchain-0.0.1.tar.gz
Algorithm Hash digest
SHA256 42a8e40cc1cc2c389cde09af6fa91fab3b9cf4db3181c7d697f5cee1906795b4
MD5 5ad0b9bd40b5c50ee5dbc17f3e0e9e62
BLAKE2b-256 38b7903a1ed2b16a6918c4b40e18ccbdee7eb9d3c4f59ff9fedc2292dc305d33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hyperpocket_langchain-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67ce4cfedd54442c634b595157aec16447ef3f3ffe71577f822eb13cbe3b708b
MD5 85d125b3a2e0ec492634db3589aba0c1
BLAKE2b-256 7993338ba6a88845faffbab96c265dc4b33e22976fff2bf093996bdb4918aad7

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