Skip to main content

agora.common.toolformers.langchain

LangChainConversation Objects

class LangChainConversation(Conversation)

__init__

def __init__(agent: CompiledGraph,
messages: List[str],
category: Optional[str] = None) -> None

Initializes a LangChainConversation instance.

Arguments:

  • agent CompiledGraph - The compiled LangChain agent to process messages.
  • messages List[str] - The conversation history.
  • category Optional[str], optional - An optional category or tag for the conversation.

__call__

def __call__(message: str, print_output: bool = True) -> str

Sends a message to the conversation and returns the AI response.

Arguments:

  • message str - The user message or query.
  • print_output bool, optional - Whether to print the AI response as it streams.

Returns:

  • str - The concatenated AI response.

LangChainToolformer Objects

class LangChainToolformer(Toolformer)

__init__

def __init__(model: BaseChatModel)

Initializes a LangChainToolformer.

Arguments:

  • model BaseChatModel - The underlying language model for processing.

new_conversation

def new_conversation(prompt: str,
tools: List[ToolLike],
category: Optional[str] = None) -> Conversation

Creates a new conversation using the provided prompt and tools.

Arguments:

  • prompt str - The initial conversation prompt.
  • tools List[ToolLike] - Tools available to the conversation.
  • category Optional[str], optional - A category or tag for this conversation.

Returns:

  • Conversation - The conversation instance using the specified tools.