The current Haystack integration allows you to run chainlit apps and visualise intermediary steps. Playground capabilities will be added with the release of Haystack 2.0.

Haystack is an end-to-end NLP framework that enables you to build NLP applications powered by LLMs, Transformer models, vector search and more. Whether you want to perform question answering, answer generation, semantic document search, or build tools that are capable of complex decision making and query resolution, you can use the state-of-the-art NLP models with Haystack to build end-to-end NLP applications solving your use case. Check out their repo: https://github.com/deepset-ai/haystack.

A Haystack agent run with reasoning steps

Installation

pip install farm-haystack chainlit

Integration

Create a new Python file named app.py with the code below.

from haystack.agents.conversational import ConversationalAgent
import chainlit as cl

## Agent Code

agent = ConversationalAgent(
  prompt_node=conversational_agent_prompt_node,
  memory=memory,
  prompt_template=agent_prompt,
  tools=[search_tool],
)

cl.HaystackAgentCallbackHandler(agent)

@cl.on_message
async def main(message: cl.Message):
    response = await cl.make_async(agent.run)(message.content)
    await cl.Message(author="Agent", content=response["answers"][0].answer).send()

This code adds the Chainlit callback handler to the Haystack callback manager. The callback handler is responsible for listening to the chain’s intermediate steps and sending them to the UI.

Then, you can run chainlit run app.py in your terminal to run the app and interact with your agent.

Example

Check out this full example from the cookbook: https://github.com/Chainlit/cookbook/tree/main/haystack