Title: Conversational Agent with Deepset Haystack Tags: [haystack]
To get started with this conversational agent, follow these steps:
- Ensure you have an OpenAI API key and set it as an environment variable
OPENAI_API_KEY. - Install the required libraries with
pip install chainlit haystack datasets. - Run the
app.pyscript to start the conversational agent.
get_retriever(): Initializes the document store and loads the dataset for the Seven Wonders. It returns a BM25Retriever instance for searching documents.get_agent(retriever): Sets up the conversational agent with the necessary tools and prompt template for interaction.init(): Starts the conversation with an initial question about the Rhodes Statue.answer(message: cl.Message): Handles incoming messages and provides responses from the agent.
Send a message to the agent using the init() function or the answer() function for follow-up questions. The agent will process the question and provide an answer based on the information retrieved from the dataset.
This example is an adapted tutorial from the haystack website using chainlit and the HaystackAgentCallbackHandler.