Skip to content

Commit 624a201

Browse files
authored
Merge branch 'main' into jinja2-set-vars-incorrect
2 parents a305317 + 1e04b57 commit 624a201

File tree

829 files changed

+17565
-3059
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

829 files changed

+17565
-3059
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"""
2+
This script creates an unstable documentation version at the time of branch-off for a new Haystack release.
3+
4+
Between branch-off and the actual release, two unstable doc versions coexist.
5+
If we branch off for 2.20, we have:
6+
1. the target unstable version, 2.20-unstable (lives in docs-website/versioned_docs/version-2.20-unstable)
7+
2. the next unstable version, 2.21-unstable (lives in docs-website/docs)
8+
9+
This script takes care of all the necessary updates to the documentation website.
10+
"""
11+
12+
import argparse
13+
import json
14+
import os
15+
import re
16+
import shutil
17+
import sys
18+
19+
VERSION_VALIDATOR = re.compile(r"^[0-9]+\.[0-9]+$")
20+
21+
22+
if __name__ == "__main__":
23+
parser = argparse.ArgumentParser()
24+
parser.add_argument(
25+
"-v", "--new-version", help="The new unstable version that is being created (e.g. 2.20).", required=True
26+
)
27+
args = parser.parse_args()
28+
29+
if VERSION_VALIDATOR.match(args.new_version) is None:
30+
sys.exit("Version must be formatted like so <major>.<minor>")
31+
32+
target_version = f"{args.new_version}" # e.g., "2.20" - the target release version
33+
major, minor = args.new_version.split(".")
34+
35+
target_unstable = f"{target_version}-unstable" # e.g., "2.20-unstable"
36+
next_unstable = f"{major}.{int(minor) + 1}-unstable" # e.g., "2.21-unstable" - next cycle
37+
previous_stable = f"{major}.{int(minor) - 1}" # e.g., "2.19" - previous stable release
38+
39+
versions = [
40+
folder.replace("version-", "")
41+
for folder in os.listdir("docs-website/versioned_docs")
42+
if os.path.isdir(os.path.join("docs-website/versioned_docs", folder))
43+
]
44+
45+
# Check if the versions we're about to create already exist in versioned_docs
46+
if target_version in versions:
47+
sys.exit(f"{target_version} already exists (already released). Aborting.")
48+
if target_unstable in versions:
49+
print(f"{target_unstable} already exists. Nothing to do.")
50+
sys.exit(0)
51+
52+
# Create new unstable from the currently existing one.
53+
# The new unstable will be made stable at a later time by another workflow
54+
print(f"Creating new unstable version {target_unstable} from main")
55+
56+
### Docusaurus updates
57+
58+
# copy docs to versioned_docs/version-target_unstable
59+
shutil.copytree("docs-website/docs", f"docs-website/versioned_docs/version-{target_unstable}")
60+
61+
# copy reference to reference_versioned_docs/version-target_unstable
62+
shutil.copytree("docs-website/reference", f"docs-website/reference_versioned_docs/version-{target_unstable}")
63+
64+
# copy versioned_sidebars/version-previous_stable-sidebars.json
65+
# to versioned_sidebars/version-target_unstable-sidebars.json
66+
shutil.copy(
67+
f"docs-website/versioned_sidebars/version-{previous_stable}-sidebars.json",
68+
f"docs-website/versioned_sidebars/version-{target_unstable}-sidebars.json",
69+
)
70+
71+
# copy reference_versioned_sidebars/version-previous_stable-sidebars.json
72+
# to reference_versioned_sidebars/version-target_unstable-sidebars.json
73+
shutil.copy(
74+
f"docs-website/reference_versioned_sidebars/version-{previous_stable}-sidebars.json",
75+
f"docs-website/reference_versioned_sidebars/version-{target_unstable}-sidebars.json",
76+
)
77+
78+
# add unstable version to versions.json
79+
with open("docs-website/versions.json", "r") as f:
80+
versions_list = json.load(f)
81+
versions_list.insert(0, target_unstable)
82+
with open("docs-website/versions.json", "w") as f:
83+
json.dump(versions_list, f)
84+
85+
# add unstable version to reference_versions.json
86+
with open("docs-website/reference_versions.json", "r") as f:
87+
reference_versions_list = json.load(f)
88+
reference_versions_list.insert(0, target_unstable)
89+
with open("docs-website/reference_versions.json", "w") as f:
90+
json.dump(reference_versions_list, f)
91+
92+
# in docusaurus.config.js, replace the target unstable version with the next unstable version
93+
with open("docs-website/docusaurus.config.js", "r") as f:
94+
config = f.read()
95+
config = config.replace(f"label: '{target_unstable}'", f"label: '{next_unstable}'")
96+
with open("docs-website/docusaurus.config.js", "w") as f:
97+
f.write(config)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
"""
2+
This script promotes an unstable documentation version to a stable version at the time of a new Haystack release.
3+
4+
To understand how unstable doc versions are created, see create_unstable_docs_docusaurus.py.
5+
"""
6+
7+
import argparse
8+
import json
9+
import os
10+
import re
11+
import shutil
12+
import sys
13+
14+
VERSION_VALIDATOR = re.compile(r"^[0-9]+\.[0-9]+$")
15+
16+
17+
if __name__ == "__main__":
18+
parser = argparse.ArgumentParser()
19+
parser.add_argument("-v", "--version", help="The version to promote to stable (e.g. 2.20).", required=True)
20+
args = parser.parse_args()
21+
22+
if VERSION_VALIDATOR.match(args.version) is None:
23+
sys.exit("Version must be formatted like so <major>.<minor>")
24+
25+
target_version = f"{args.version}" # e.g., "2.20" - the target release version
26+
major, minor = args.version.split(".")
27+
28+
target_unstable = f"{target_version}-unstable" # e.g., "2.20-unstable"
29+
previous_stable = f"{major}.{int(minor) - 1}" # e.g., "2.19" - previous stable release
30+
31+
versions = [
32+
folder.replace("version-", "")
33+
for folder in os.listdir("docs-website/versioned_docs")
34+
if os.path.isdir(os.path.join("docs-website/versioned_docs", folder))
35+
]
36+
37+
if target_version in versions:
38+
sys.exit(f"{target_version} already exists (already released). Aborting.")
39+
if not target_unstable in versions:
40+
sys.exit(f"Can't find version {target_unstable} to promote to {target_version}")
41+
42+
print(f"Promoting unstable version {target_unstable} to stable version {target_version}")
43+
44+
### Docusaurus updates
45+
46+
# rename versioned_docs/version-target_unstable to versioned_docs/version-target_version
47+
shutil.move(
48+
f"docs-website/versioned_docs/version-{target_unstable}",
49+
f"docs-website/versioned_docs/version-{target_version}",
50+
)
51+
52+
# rename reference_versioned_docs/version-target_unstable to reference_versioned_docs/version-target_version
53+
shutil.move(
54+
f"docs-website/reference_versioned_docs/version-{target_unstable}",
55+
f"docs-website/reference_versioned_docs/version-{target_version}",
56+
)
57+
58+
# copy versioned_sidebars/version-target_unstable-sidebars.json
59+
# to versioned_sidebars/version-target_version-sidebars.json
60+
shutil.move(
61+
f"docs-website/versioned_sidebars/version-{target_unstable}-sidebars.json",
62+
f"docs-website/versioned_sidebars/version-{target_version}-sidebars.json",
63+
)
64+
65+
# rename reference_versioned_sidebars/version-target_unstable-sidebars.json
66+
# to reference_versioned_sidebars/version-target_version-sidebars.json
67+
shutil.move(
68+
f"docs-website/reference_versioned_sidebars/version-{target_unstable}-sidebars.json",
69+
f"docs-website/reference_versioned_sidebars/version-{target_version}-sidebars.json",
70+
)
71+
72+
# replace unstable version with stable version in versions.json
73+
with open("docs-website/versions.json", "r") as f:
74+
versions_list = json.load(f)
75+
versions_list[versions_list.index(target_unstable)] = target_version
76+
with open("docs-website/versions.json", "w") as f:
77+
json.dump(versions_list, f)
78+
79+
# replace unstable version with stable version in reference_versions.json
80+
with open("docs-website/reference_versions.json", "r") as f:
81+
reference_versions_list = json.load(f)
82+
reference_versions_list[reference_versions_list.index(target_unstable)] = target_version
83+
with open("docs-website/reference_versions.json", "w") as f:
84+
json.dump(reference_versions_list, f)
85+
86+
# in docusaurus.config.js, replace previous stable version with the target version
87+
with open("docs-website/docusaurus.config.js", "r") as f:
88+
config = f.read()
89+
config = config.replace(f"lastVersion: '{previous_stable}'", f"lastVersion: '{target_version}'") # "2.19" -> "2.20"
90+
with open("docs-website/docusaurus.config.js", "w") as f:
91+
f.write(config)

.github/workflows/minor_version_release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Minor Version Release
22

33
on:
44
workflow_dispatch:
5-
65
env:
76
PYTHON_VERSION: "3.9"
87

@@ -77,3 +76,23 @@ jobs:
7776
run: |
7877
git checkout main
7978
python ./.github/utils/create_unstable_docs.py --new-version ${{ steps.versions.outputs.current_release_minor }}
79+
80+
- name: Generate unstable docs for Docusaurus
81+
run: |
82+
git checkout main
83+
python ./.github/utils/create_unstable_docs_docusaurus.py --new-version ${{ steps.versions.outputs.current_release_minor }}
84+
85+
- name: Create Pull Request with Docusaurus docs updates
86+
uses: peter-evans/create-pull-request@v7
87+
with:
88+
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
89+
commit-message: "Create unstable docs for Haystack ${{ steps.versions.outputs.current_release_minor }}"
90+
branch: create-unstable-docs-${{ steps.versions.outputs.current_release_minor }}
91+
base: main
92+
title: "docs: create unstable docs for Haystack ${{ steps.versions.outputs.current_release_minor }}"
93+
add-paths: |
94+
docs-website
95+
body: |
96+
This PR creates the unstable docs for Haystack ${{ steps.versions.outputs.current_release_minor }}.
97+
It is expected to run during the branch-off process.
98+
You can inspect the docs preview (two unstable versions will be available) and merge it.

.github/workflows/promote_unstable_docs.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ jobs:
3636
RDME_API_KEY: ${{ secrets.README_API_KEY }}
3737
run: |
3838
python ./.github/utils/promote_unstable_docs.py --version ${{ steps.version.outputs.version }}
39+
40+
- name: Promote unstable docs for Docusaurus
41+
run: |
42+
git checkout main
43+
python ./.github/utils/promote_unstable_docs_docusaurus.py --version ${{ steps.version.outputs.version }}
44+
45+
- name: Create Pull Request with Docusaurus docs updates
46+
uses: peter-evans/create-pull-request@v7
47+
with:
48+
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
49+
commit-message: "Promote unstable docs for Haystack ${{ steps.version.outputs.version }}"
50+
branch: promote-unstable-docs-${{ steps.version.outputs.version }}
51+
base: main
52+
title: "docs: promote unstable docs for Haystack ${{ steps.version.outputs.version }}"
53+
add-paths: |
54+
docs-website
55+
body: |
56+
This PR promotes the unstable docs for Haystack ${{ steps.version.outputs.version }} to stable.
57+
It is expected to run at the time of the release.
58+
You can inspect the docs preview and merge it. There should now be only one unstable version representing the next (main) branch.

docs-website/docs/concepts/agents/state.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
title: "State"
33
id: state
44
slug: "/state"
5-
description: "`State` is a container for storing shared information during Agent and Tool execution. It provides a structured way to maintain conversation history, share data between tools, and store intermediate results throughout an agent's workflow."
5+
description: "`State` is a container for storing shared information during Agent and Tool execution. It provides a structured way to store messages during execution, share data between tools, and store intermediate results throughout an agent's workflow."
66
---
77

88
# State
99

10-
`State` is a container for storing shared information during Agent and Tool execution. It provides a structured way to maintain conversation history, share data between tools, and store intermediate results throughout an agent's workflow.
10+
`State` is a container for storing shared information during Agent and Tool execution. It provides a structured way to store messages during execution, share data between tools, and store intermediate results throughout an agent's workflow.
1111

1212
## Overview
1313

@@ -30,7 +30,7 @@ State supports standard Python types:
3030

3131
### Automatic Message Handling
3232

33-
State automatically includes a `messages` field to store conversation history. You don't need to define this in your schema.
33+
State automatically includes a `messages` field to store messages during execution. You don't need to define this in your schema.
3434

3535
```python
3636
## State automatically adds messages field
@@ -40,11 +40,11 @@ state = State(schema={"user_id": {"type": str}})
4040
print("messages" in state.schema) # True
4141
print(state.schema["messages"]["type"]) # list[ChatMessage]
4242

43-
## Access conversation history
43+
## Access messages
4444
messages = state.get("messages", [])
4545
```
4646

47-
The `messages` field uses `list[ChatMessage]` type and `merge_lists` handler by default, which means new messages are appended to the conversation history.
47+
The `messages` field uses `list[ChatMessage]` type and `merge_lists` handler by default, which means new messages are appended during execution.
4848

4949
## Usage
5050

@@ -171,7 +171,7 @@ You can also override handlers for individual operations:
171171
```python
172172
def concatenate_strings(current, new):
173173
return f"{current}-{new}" if current else new
174-
174+
175175
schema = {"user_name": {"type": str}}
176176
state = State(schema=schema)
177177

@@ -505,7 +505,7 @@ result = agent.run(
505505
factorial_result = result["factorial_result"]
506506
calc_result = result["calc_result"]
507507

508-
## Access conversation messages
508+
## Access messages from execution
509509
for message in result["messages"]:
510510
print(f"{message.role}: {message.text}")
511-
```
511+
```

docs-website/docs/concepts/components.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ Components are connected to each other using a [pipeline](pipelines.mdx), and th
1717

1818
You can integrate components in a pipeline to perform a specific task. But you can also use some of them stand-alone, outside of a pipeline. For example, you can run `DocumentWriter` on its own, to write documents into a Document Store. To check how to use a component and if it's usable outside of a pipeline, check the _Usage_ section on the component's documentation page.
1919

20-
Each component has a `run()` method. When you connect components in a pipeline, and you run the pipeline by calling `Pipeline.run()`, it invokes the `run()` method for each component sequentially.
20+
Each component has a `run()` method. When you connect components in a pipeline, and you run the pipeline by calling `Pipeline.run()`, it invokes the `run()` method for each component sequentially.
2121

2222
## Input and Output
2323

24-
To connect components in a pipeline, you need to know the names of the inputs and outputs they accept. The output of one component must be compatible with the input the subsequent component accepts. For example, to connect Retriever and Ranker in a pipeline, you must know that the Retriever outputs `documents` and the Ranker accepts `documents` as input.
24+
To connect components in a pipeline, you need to know the names of the inputs and outputs they accept. The output of one component must be compatible with the input the subsequent component accepts. For example, to connect Retriever and Ranker in a pipeline, you must know that the Retriever outputs `documents` and the Ranker accepts `documents` as input.
2525

2626
The mandatory inputs and outputs are listed in a table at the top of each component's documentation page so that you can quickly check them:
27-
<ClickableImage src="/img/3a53f3e-inputs_and_outputs.png" alt="" />
27+
<ClickableImage src="/img/3a53f3e-inputs_and_outputs.png" alt="DocumentWriter component specification table showing Name, Folder Path, Position in Pipeline, Inputs (documents list), and Outputs (documents_written integer)" />
2828

2929
You can also look them up in the code in the component`run()` method. Here's an example of the inputs and outputs of `TransformerSimilarityRanker`:
3030

@@ -56,6 +56,6 @@ result = doc_embedder.run([doc]) # And finally, run it
5656
print(result['documents'][0].embedding)
5757
```
5858

59-
If you're using a component that has the `warm_up()` method in a pipeline, you don't have to do anything additionally. The pipeline takes care of warming it up before running.
59+
If you're using a component that has the `warm_up()` method in a pipeline, you don't have to do anything additionally. The pipeline takes care of warming it up before running.
6060

61-
The `warm_up()` method is a nice way to keep the `init()` methods lightweight and the validation fast. (Validation in the pipeline happens when connecting the components but before warming them up and running.)
61+
The `warm_up()` method is a nice way to keep the `init()` methods lightweight and the validation fast. (Validation in the pipeline happens when connecting the components but before warming them up and running.)

docs-website/docs/concepts/components/custom-components.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ An example of an extended component is Haystack's [FaithfulnessEvaluator](https:
8181

8282
## Additional References
8383

84-
:cook: Cookbooks:
84+
🧑‍🍳 Cookbooks:
8585

8686
- [Build quizzes and adventures with Character Codex and llamafile](https://haystack.deepset.ai/cookbook/charactercodex_llamafile/)
8787
- [Run tasks concurrently within a custom component](https://haystack.deepset.ai/cookbook/concurrent_tasks/)
8888
- [Chat With Your SQL Database](https://haystack.deepset.ai/cookbook/chat_with_sql_3_ways/)
89-
- [Hacker News Summaries with Custom Components](https://haystack.deepset.ai/cookbook/hackernews-custom-component-rag/)
89+
- [Hacker News Summaries with Custom Components](https://haystack.deepset.ai/cookbook/hackernews-custom-component-rag/)

0 commit comments

Comments
 (0)