diff --git a/haystack/components/evaluators/faithfulness.py b/haystack/components/evaluators/faithfulness.py index 249c78b20..995e58f9d 100644 --- a/haystack/components/evaluators/faithfulness.py +++ b/haystack/components/evaluators/faithfulness.py @@ -103,6 +103,7 @@ class FaithfulnessEvaluator(LLMEvaluator): "inputs" must be a dictionary with keys "questions", "contexts", and "predicted_answers". "outputs" must be a dictionary with "statements" and "statement_scores". Expected format: + ```python [{ "inputs": { "questions": "What is the capital of Italy?", "contexts": ["Rome is the capital of Italy."], @@ -113,6 +114,7 @@ class FaithfulnessEvaluator(LLMEvaluator): "statement_scores": [1, 0], }, }] + ``` :param progress_bar: Whether to show a progress bar during the evaluation. :param raise_on_failure: diff --git a/haystack/tools/component_tool.py b/haystack/tools/component_tool.py index 01a0851f1..59bc98e1c 100644 --- a/haystack/tools/component_tool.py +++ b/haystack/tools/component_tool.py @@ -107,22 +107,31 @@ class ComponentTool(Tool): Optional dictionary defining how a tool outputs should be converted into a string. If the source is provided only the specified output key is sent to the handler. If the source is omitted the whole tool result is sent to the handler. - Example: { + Example: + ```python + { "source": "docs", "handler": format_documents } + ``` :param inputs_from_state: Optional dictionary mapping state keys to tool parameter names. - Example: {"repository": "repo"} maps state's "repository" to tool's "repo" parameter. + Example: `{"repository": "repo"}` maps state's "repository" to tool's "repo" parameter. :param outputs_to_state: Optional dictionary defining how tool outputs map to keys within state as well as optional handlers. If the source is provided only the specified output key is sent to the handler. - Example: { + Example: + ```python + { "documents": {"source": "docs", "handler": custom_handler} } + ``` If the source is omitted the whole tool result is sent to the handler. - Example: { + Example: + ```python + { "documents": {"handler": custom_handler} } + ``` :raises ValueError: If the component is invalid or schema generation fails. """ if not isinstance(component, Component): diff --git a/haystack/tools/from_function.py b/haystack/tools/from_function.py index ab4f61c9c..215cdddbc 100644 --- a/haystack/tools/from_function.py +++ b/haystack/tools/from_function.py @@ -68,13 +68,16 @@ def create_tool_from_function( To intentionally leave the description empty, pass an empty string. :param inputs_from_state: Optional dictionary mapping state keys to tool parameter names. - Example: {"repository": "repo"} maps state's "repository" to tool's "repo" parameter. + Example: `{"repository": "repo"}` maps state's "repository" to tool's "repo" parameter. :param outputs_to_state: Optional dictionary defining how tool outputs map to state and message handling. - Example: { + Example: + ```python + { "documents": {"source": "docs", "handler": custom_handler}, "message": {"source": "summary", "handler": format_summary} } + ``` :returns: The Tool created from the function. diff --git a/haystack/tools/tool.py b/haystack/tools/tool.py index a54a6ec21..4401573d3 100644 --- a/haystack/tools/tool.py +++ b/haystack/tools/tool.py @@ -41,7 +41,7 @@ class Tool: ``` :param inputs_from_state: Optional dictionary mapping state keys to tool parameter names. - Example: {"repository": "repo"} maps state's "repository" to tool's "repo" parameter. + Example: `{"repository": "repo"}` maps state's "repository" to tool's "repo" parameter. :param outputs_to_state: Optional dictionary defining how tool outputs map to keys within state as well as optional handlers. If the source is provided only the specified output key is sent to the handler.