Skip to content

Commit 7015c16

Browse files
Sync Haystack API reference on Docusaurus (#10962)
Co-authored-by: davidsbatista <7937824+davidsbatista@users.noreply.github.com>
1 parent 23c25d4 commit 7015c16

10 files changed

Lines changed: 196 additions & 148 deletions

File tree

docs-website/reference/haystack-api/connectors_api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ Sends an HTTP request as described by this path.
121121
- **data** (<code>Any | None</code>) – The request body to send.
122122
- **parameters** (<code>dict\[str, Any\] | None</code>) – The parameters used to create the path.
123123
- **raw_response** (<code>bool</code>) – If true, return the raw response instead of validating
124-
and exterpolating it.
124+
and extrapolating it.
125125
- **security** (<code>dict\[str, str\] | None</code>) – The security scheme to use, and the values it needs to
126126
process successfully.
127127
- **session** (<code>Any | None</code>) – A persistent request session.
128-
- **verify** (<code>bool | str</code>) – If we should do an ssl verification on the request or not.
128+
- **verify** (<code>bool | str</code>) – If we should do an SSL verification on the request or not.
129129
In case str was provided, will use that as the CA.
130130

131131
**Returns:**

docs-website/reference/haystack-api/converters_api.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ It can attach metadata to the resulting documents.
147147

148148
```python
149149
from haystack.components.converters.csv import CSVToDocument
150+
from datetime import datetime
150151
converter = CSVToDocument()
151152
results = converter.run(sources=["sample.csv"], meta={"date_added": datetime.now().isoformat()})
152153
documents = results["documents"]
@@ -1836,7 +1837,6 @@ Converts text files to documents.
18361837

18371838
### XLSXToDocument
18381839

1839-
````
18401840
Converts XLSX (Excel) files into Documents.
18411841

18421842
Supports reading data from specific sheets or all sheets in the Excel file. If all sheets are read, a Document is
@@ -1846,18 +1846,14 @@ created for each sheet. The content of the Document is the table which can be sa
18461846

18471847
```python
18481848
from haystack.components.converters.xlsx import XLSXToDocument
1849+
from datetime import datetime
18491850

18501851
converter = XLSXToDocument()
18511852
results = converter.run(sources=["sample.xlsx"], meta={"date_added": datetime.now().isoformat()})
18521853
documents = results["documents"]
18531854
print(documents[0].content)
1854-
# ",A,B
1855-
````
1856-
1857-
1,col_a,col_b
1858-
2,1.5,test
1859-
"
1860-
\`\`\`
1855+
# ",A,B\n1,col_a,col_b\n2,1.5,test\n"
1856+
```
18611857

18621858
#### __init__
18631859

docs-website/reference/haystack-api/document_stores_api.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,57 @@ Returns the number of unique values for each specified metadata field from docum
483483
- <code>dict\[str, int\]</code> – A dictionary mapping each metadata field name (without "meta." prefix)
484484
to the count of its unique values among the filtered documents.
485485

486+
#### get_metadata_fields_info_async
487+
488+
```python
489+
get_metadata_fields_info_async() -> dict[str, dict[str, str]]
490+
```
491+
492+
Returns information about the metadata fields present in the stored documents.
493+
494+
Types are inferred from the stored values (keyword, int, float, boolean).
495+
496+
**Returns:**
497+
498+
- <code>dict\[str, dict\[str, str\]\]</code> – A dictionary mapping each metadata field name to a dict with a "type" key.
499+
500+
#### get_metadata_field_min_max_async
501+
502+
```python
503+
get_metadata_field_min_max_async(metadata_field: str) -> dict[str, Any]
504+
```
505+
506+
Returns the minimum and maximum values for the given metadata field across all documents.
507+
508+
**Parameters:**
509+
510+
- **metadata_field** (<code>str</code>) – The metadata field name. Can include or omit the "meta." prefix.
511+
512+
**Returns:**
513+
514+
- <code>dict\[str, Any\]</code> – A dictionary with "min" and "max" keys. Returns `{"min": None, "max": None}`
515+
if the field is missing or has no values.
516+
517+
#### get_metadata_field_unique_values_async
518+
519+
```python
520+
get_metadata_field_unique_values_async(
521+
metadata_field: str, search_term: str | None = None
522+
) -> tuple[list[str], int]
523+
```
524+
525+
Returns unique values for a metadata field, optionally filtered by a search term in content.
526+
527+
**Parameters:**
528+
529+
- **metadata_field** (<code>str</code>) – The metadata field name. Can include or omit the "meta." prefix.
530+
- **search_term** (<code>str | None</code>) – If set, only documents whose content contains this term (case-insensitive)
531+
are considered.
532+
533+
**Returns:**
534+
535+
- <code>tuple\[list\[str\], int\]</code> – A tuple of (list of unique values, total count of unique values).
536+
486537
#### delete_all_documents_async
487538

488539
```python

docs-website/reference/haystack-api/evaluators_api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ print(result["score"])
635635
# 0.5
636636
print(result["results"])
637637
# [{'statements': ['Python is a high-level general-purpose programming language.',
638-
'Python was created by George Lucas.'], 'statement_scores': [1, 0], 'score': 0.5}]
638+
# 'Python was created by George Lucas.'], 'statement_scores': [1, 0], 'score': 0.5}]
639639
```
640640

641641
#### __init__

docs-website/reference/haystack-api/generators_api.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ print(result)
746746

747747
#### With paid inference endpoints
748748

749-
````python
749+
```python
750750
from haystack.components.generators.chat import HuggingFaceAPIChatGenerator
751751
from haystack.dataclasses import ChatMessage
752752
from haystack.utils import Secret
@@ -760,6 +760,7 @@ generator = HuggingFaceAPIChatGenerator(api_type="inference_endpoints",
760760

761761
result = generator.run(messages)
762762
print(result)
763+
```
763764

764765
#### With self-hosted text generation inference
765766

@@ -775,7 +776,7 @@ generator = HuggingFaceAPIChatGenerator(api_type="text_generation_inference",
775776

776777
result = generator.run(messages)
777778
print(result)
778-
````
779+
```
779780

780781
#### __init__
781782

@@ -2140,11 +2141,11 @@ client = OpenAIGenerator()
21402141
response = client.run("What's Natural Language Processing? Be brief.")
21412142
print(response)
21422143

2143-
>> {'replies': ['Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on
2144-
>> the interaction between computers and human language. It involves enabling computers to understand, interpret,
2145-
>> and respond to natural human language in a way that is both meaningful and useful.'], 'meta': [{'model':
2146-
>> 'gpt-5-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 16,
2147-
>> 'completion_tokens': 49, 'total_tokens': 65}}]}
2144+
# >> {'replies': ['Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on
2145+
# >> the interaction between computers and human language. It involves enabling computers to understand, interpret,
2146+
# >> and respond to natural human language in a way that is both meaningful and useful.'], 'meta': [{'model':
2147+
# >> 'gpt-5-mini', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 16,
2148+
# >> 'completion_tokens': 49, 'total_tokens': 65}}]}
21482149
```
21492150

21502151
#### __init__

docs-website/reference/haystack-api/joiners_api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ result = pipe.run(
199199
print(json.loads(result["validator"]["validated"][0].text))
200200

201201

202-
>> {'first_name': 'Peter', 'last_name': 'Parker', 'nationality': 'American', 'name': 'Spider-Man', 'occupation':
203-
>> 'Superhero', 'age': 23, 'location': 'New York City'}
202+
# >> {'first_name': 'Peter', 'last_name': 'Parker', 'nationality': 'American', 'name': 'Spider-Man', 'occupation':
203+
# >> 'Superhero', 'age': 23, 'location': 'New York City'}
204204
```
205205

206206
Note that `BranchJoiner` can manage only one data type at a time. In this case, `BranchJoiner` is created for
@@ -545,7 +545,7 @@ pipeline.connect("prompt_builder_2.prompt", "string_joiner.strings")
545545

546546
print(pipeline.run(data={"prompt_builder_1": {"query": string_1}, "prompt_builder_2": {"query": string_2}}))
547547

548-
>> {"string_joiner": {"strings": ["Builder 1: What's Natural Language Processing?", "Builder 2: What is life?"]}}
548+
# >> {"string_joiner": {"strings": ["Builder 1: What's Natural Language Processing?", "Builder 2: What is life?"]}}
549549
```
550550

551551
#### run

docs-website/reference/haystack-api/pipeline_api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ Answer:
420420

421421
retriever = InMemoryBM25Retriever(document_store=document_store)
422422
prompt_builder = PromptBuilder(template=prompt_template)
423+
api_key = "your-openai-api-key"
423424
llm = OpenAIGenerator(api_key=Secret.from_token(api_key))
424425

425426
rag_pipeline = Pipeline()

docs-website/reference/haystack-api/preprocessors_api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,12 @@ AI technology is widely used throughout industry, government, and science. Some
861861
doc = Document(content=text)
862862
doc_chunks = chunker.run([doc])
863863
print(doc_chunks["documents"])
864-
>[
865-
>Document(id=..., content: 'Artificial intelligence (AI) - Introduction\n\n', meta: {'original_id': '...', 'split_id': 0, 'split_idx_start': 0, '_split_overlap': []})
866-
>Document(id=..., content: 'AI, in its broadest sense, is intelligence exhibited by machines, particularly computer systems.\n', meta: {'original_id': '...', 'split_id': 1, 'split_idx_start': 45, '_split_overlap': []})
867-
>Document(id=..., content: 'AI technology is widely used throughout industry, government, and science.', meta: {'original_id': '...', 'split_id': 2, 'split_idx_start': 142, '_split_overlap': []})
868-
>Document(id=..., content: ' Some high-profile applications include advanced web search engines; recommendation systems; interac...', meta: {'original_id': '...', 'split_id': 3, 'split_idx_start': 216, '_split_overlap': []})
869-
>]
864+
# [
865+
# Document(id=..., content: 'Artificial intelligence (AI) - Introduction\n\n', meta: {'original_id': '...', 'split_id': 0, 'split_idx_start': 0, '_split_overlap': []})
866+
# Document(id=..., content: 'AI, in its broadest sense, is intelligence exhibited by machines, particularly computer systems.\n', meta: {'original_id': '...', 'split_id': 1, 'split_idx_start': 45, '_split_overlap': []})
867+
# Document(id=..., content: 'AI technology is widely used throughout industry, government, and science.', meta: {'original_id': '...', 'split_id': 2, 'split_idx_start': 142, '_split_overlap': []})
868+
# Document(id=..., content: ' Some high-profile applications include advanced web search engines; recommendation systems; interac...', meta: {'original_id': '...', 'split_id': 3, 'split_idx_start': 216, '_split_overlap': []})
869+
# ]
870870
```
871871

872872
#### __init__

docs-website/reference/haystack-api/routers_api.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,12 @@ Categorize files or byte streams according to their MIME types.
516516

517517
### LLMMessagesRouter
518518

519-
````
520519
Routes Chat Messages to different connections using a generative Language Model to perform classification.
521520

522521
This component can be used with general-purpose LLMs and with specialized LLMs for moderation like Llama Guard.
523522

524523
### Usage example
524+
525525
```python
526526
from haystack.components.generators.chat import HuggingFaceAPIChatGenerator
527527
from haystack.components.routers.llm_messages_router import LLMMessagesRouter
@@ -541,20 +541,17 @@ router = LLMMessagesRouter(chat_generator=chat_generator,
541541
print(router.run([ChatMessage.from_user("How to rob a bank?")]))
542542

543543
# {
544-
# 'chat_generator_text': 'unsafe
545-
````
546-
547-
S2',
548-
\# 'unsafe': \[
549-
\# ChatMessage(
550-
\# \_role=\<ChatRole.USER: 'user'>,
551-
\# \_content=[TextContent(text='How to rob a bank?')],
552-
\# \_name=None,
553-
\# \_meta={}
554-
\# )
555-
\# \]
556-
\# }
557-
\`\`\`
544+
# 'chat_generator_text': 'unsafe\nS2',
545+
# 'unsafe': [
546+
# ChatMessage(
547+
# _role=<ChatRole.USER: 'user'>,
548+
# _content=[TextContent(text='How to rob a bank?')],
549+
# _name=None,
550+
# _meta={}
551+
# )
552+
# ]
553+
# }
554+
```
558555

559556
#### __init__
560557

0 commit comments

Comments
 (0)