DeepsetChatHistoryParser
Parse a string containing chat history and a current question into a list of ChatMessage
objects.
Basic Information
- Type:
deepset_cloud_custom_nodes.parsers.chat_history_parser.DeepsetChatHistoryParser
- Components it can connect with:
- Agent:
DeepsetChatHistoryParser
can send chat history and the current query to the Agent. - Query:
DeepsetChatHistoryParser
receives the query and converts it together with chat history into a list of ChatMessages.
- Agent:
Inputs
Parameter | Type | Default | Description |
---|---|---|---|
history_and_query | str | Chat history and the current question to convert into a list of ChatMessage objects. |
Outputs
Parameter | Type | Default | Description |
---|---|---|---|
messages | List[ChatMessage] | A list of ChatMessage objects. Each message has a role (either user or assistant) and content. |
Overview
DeepsetChatHistoryParser
is primarily used with an Agent to supply both the chat history and the current query. It expects input in the following format:
"Chat History: [{...array of messages...}] Current Question: {question text}"
. Each message in the chat history should be a dictionary containing two keys: role
and content
. If the input doesn't match this structure, DeepsetChatHistoryParser
returns it as a single message from the user.
Usage Example
Initializing the Component
components:
DeepsetChatHistoryParser:
type: parsers.chat_history_parser.DeepsetChatHistoryParser
init_parameters:
Using the Component in a Pipeline
This is an example of an agentic pipeline with DeepsetChatHistoryParser
used to provide the current query and chat history to the Agent:
components:
adapter:
init_parameters:
custom_filters: {}
output_type: typing.List[str]
template: '{{ [(messages|last).text] }}'
unsafe: false
type: haystack.components.converters.output_adapter.OutputAdapter
agent:
init_parameters:
chat_generator:
init_parameters:
api_base_url:
api_key:
env_vars:
- OPENAI_API_KEY
strict: false
type: env_var
generation_kwargs: {}
max_retries:
model: gpt-4o
organization:
streaming_callback:
timeout:
tools:
tools_strict: false
type: haystack.components.generators.chat.openai.OpenAIChatGenerator
exit_conditions:
- text
max_agent_steps: 100
raise_on_tool_invocation_failure: false
state_schema: {}
streaming_callback:
system_prompt: |-
You are a deep research assistant.
You create comprehensive research reports to answer the user's questions.
You use the 'search'-tool to answer any questions.
You perform multiple searches until you have the information you need to answer the question.
Make sure you research different aspects of the question.
Use markdown to format your response.
When you use information from the websearch results, cite your sources using markdown links.
It is important that you cite accurately.
tools:
- data:
component:
init_parameters:
input_mapping:
query:
- search.query
output_mapping:
builder.prompt: result
pipeline:
components:
builder:
init_parameters:
required_variables:
template: |-
{% for doc in docs %}
{% if doc.content and doc.meta.url|length > 0 %}
<search-result url="{{ doc.meta.url }}">
{{ doc.content|truncate(25000) }}
</search-result>
{% endif %}
{% endfor %}
variables:
type: haystack.components.builders.prompt_builder.PromptBuilder
converter:
init_parameters:
extraction_kwargs: {}
store_full_path: false
type: haystack.components.converters.html.HTMLToDocument
fetcher:
init_parameters:
raise_on_failure: false
retry_attempts: 2
timeout: 3
user_agents:
- haystack/LinkContentFetcher/2.11.1
type: haystack.components.fetchers.link_content.LinkContentFetcher
search:
init_parameters:
api_key:
env_vars:
- SERPERDEV_API_KEY
strict: false
type: env_var
search_params: {}
top_k: 10
type: haystack.components.websearch.serper_dev.SerperDevWebSearch
connection_type_validation: true
connections:
- receiver: fetcher.urls
sender: search.links
- receiver: converter.sources
sender: fetcher.streams
- receiver: builder.docs
sender: converter.documents
max_runs_per_component: 100
metadata: {}
type: haystack.core.super_component.super_component.SuperComponent
description: Use this tool to search for information on the internet.
inputs_from_state:
name: search
parameters:
type: haystack.tools.component_tool.ComponentTool
type: haystack.components.agents.agent.Agent
answer_builder:
init_parameters:
pattern:
reference_pattern:
type: haystack.components.builders.answer_builder.AnswerBuilder
history_parser:
init_parameters: {}
type: deepset_cloud_custom_nodes.parsers.chat_history_parser.DeepsetChatHistoryParser
connections:
- receiver: agent.messages
sender: history_parser.messages
- receiver: adapter.messages
sender: agent.messages
- receiver: answer_builder.replies
sender: adapter.output
inputs:
query:
- answer_builder.query
- history_parser.history_and_query
outputs:
answers: answer_builder.answers
pipeline_output_type: chat
max_runs_per_component: 100
metadata: {}
Parameters
Init Parameters
This component doesn't take any initialization parameters.
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
Parameter | Type | Default | Description |
---|---|---|---|
history_and_query | str | Chat history and the current query to be parsed into ChatMessages. |
Updated about 22 hours ago