Skip to content

toqprotocol/toq-plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toq protocol framework plugins

LangChain and CrewAI integrations for toq protocol. Give your agents the ability to communicate with other agents.

CI PyPI PyPI License


Packages

This monorepo contains three packages:

Package Description Install
toq-langchain 17 LangChain tools for toq pip install toq-langchain
toq-crewai 17 CrewAI tools for toq pip install toq-crewai
toq-plugins-common Shared binary management and daemon lifecycle (installed automatically)

All packages require Python 3.10+.

Prerequisites

  1. Install the toq binary
  2. Run toq setup
  3. Run toq up

LangChain

import toq
from toq_langchain import make_tools

client = toq.connect()
tools = make_tools(client)

# Use with any LangChain agent
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, tools)

Or use the built-in connect() which handles binary extraction, setup, and daemon startup:

from toq_langchain import connect

toq_client = connect(agent_name="alice", connection_mode="open")
tools = toq_client.tools()
sdk = toq_client.sdk  # direct access to toq.Client

Listening for Messages

from toq_langchain import listen

# Feeds incoming toq messages into your LangChain agent
await listen(async_client, agent)

CrewAI

import toq
from toq_crewai import make_tools

client = toq.connect()
tools = make_tools(client)

# Use with any CrewAI crew
from crewai import Agent, Task, Crew

agent = Agent(
    role="Communicator",
    goal="Send and receive messages via toq protocol",
    tools=tools,
)

Or use the built-in connect():

from toq_crewai import connect

toq_client = connect(agent_name="alice", connection_mode="open")
tools = toq_client.tools()

Available Tools

Both plugins expose the same 17 tools:

Tool Description
toq_send Send a message to a remote agent
toq_send_stream Send a streaming message (word-by-word delivery)
toq_peers List known peers with connection status
toq_status Check daemon status
toq_block Block a peer by key, address, or wildcard
toq_unblock Unblock a peer
toq_approvals List pending approval requests
toq_approve Approve a request or pre-approve by pattern
toq_deny Deny a pending request
toq_revoke Revoke an approved rule
toq_history Query received message history
toq_permissions List all permission rules
toq_ping Ping a remote agent
toq_handlers List registered message handlers
toq_add_handler Register a new handler
toq_remove_handler Remove a handler
toq_stop_handler Stop running handler processes

Repo Structure

_common/          toq-plugins-common: binary management, daemon lifecycle, setup
langchain/        toq-langchain: LangChain tools + SSE listener
crewai/           toq-crewai: CrewAI tools + SSE listener

License

Apache 2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages