apify-haystack 0.1.0a2__tar.gz → 0.1.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/PKG-INFO +9 -7
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/README.md +8 -6
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/pyproject.toml +1 -1
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/apify_dataset.py +7 -7
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/examples/apify_actor_call.py +3 -3
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/examples/apify_dataset_load.py +1 -1
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/examples/crawl_and_process_data.py +3 -3
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/examples/rag_with_crawled_website.py +3 -3
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/LICENSE +0 -0
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/__init__.py +0 -0
- {apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/constants.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: apify_haystack
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0b1
|
|
4
4
|
Summary: Apify-haystack integration
|
|
5
5
|
Home-page: https://apify.com
|
|
6
6
|
License: Apache-2.0
|
|
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
|
|
|
29
29
|
|
|
30
30
|
# Apify-Haystack integration
|
|
31
31
|
|
|
32
|
-
The Apify-Haystack integration allows easy interaction between the Apify platform and Haystack.
|
|
32
|
+
The Apify-Haystack integration allows easy interaction between the [Apify](https://apify.com/) platform and [Haystack](https://haystack.deepset.ai/).
|
|
33
33
|
|
|
34
34
|
Apify is a platform for web scraping, data extraction, and web automation tasks.
|
|
35
35
|
It provides serverless applications called Actors for different tasks, like crawling websites, and scraping Facebook, Instagram, and Google results, etc.
|
|
@@ -46,7 +46,7 @@ pip install apify-haystack
|
|
|
46
46
|
|
|
47
47
|
## Examples
|
|
48
48
|
|
|
49
|
-
Crawl website using Apify Website Content Crawler and convert it to Haystack Documents
|
|
49
|
+
### Crawl a website using Apify's Website Content Crawler and convert it to Haystack Documents
|
|
50
50
|
|
|
51
51
|
You need to have an Apify account and API token to run this example.
|
|
52
52
|
You can start with a free account at [Apify](https://apify.com/) and get your [API token](https://docs.apify.com/platform/integrations/api).
|
|
@@ -59,7 +59,7 @@ from haystack import Document
|
|
|
59
59
|
|
|
60
60
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
61
61
|
|
|
62
|
-
#
|
|
62
|
+
# Set APIFY_API_TOKEN here or load it from .env file
|
|
63
63
|
apify_api_token = "" or load_dotenv()
|
|
64
64
|
|
|
65
65
|
actor_id = "apify/website-content-crawler"
|
|
@@ -86,11 +86,13 @@ for d in dataset:
|
|
|
86
86
|
print(d)
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
### More examples
|
|
90
|
+
|
|
89
91
|
See other examples in the [examples directory](https://github.com/apify/apify-haystack/blob/master/src/apify_haystack/examples) for more examples, here is a list of few of them
|
|
90
92
|
|
|
91
|
-
- Load a dataset from Apify and convert it to Haystack Document
|
|
92
|
-
- Call [Website Content Crawler](https://apify.com/apify/website-content-crawler)
|
|
93
|
-
- Crawl
|
|
93
|
+
- Load a dataset from Apify and convert it to a Haystack Document
|
|
94
|
+
- Call [Website Content Crawler](https://apify.com/apify/website-content-crawler) and convert the data into the Haystack Documents
|
|
95
|
+
- Crawl websites, retrieve text content, and store it in the `InMemoryDocumentStore`
|
|
94
96
|
- Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
|
|
95
97
|
|
|
96
98
|
## Support
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Apify-Haystack integration
|
|
2
2
|
|
|
3
|
-
The Apify-Haystack integration allows easy interaction between the Apify platform and Haystack.
|
|
3
|
+
The Apify-Haystack integration allows easy interaction between the [Apify](https://apify.com/) platform and [Haystack](https://haystack.deepset.ai/).
|
|
4
4
|
|
|
5
5
|
Apify is a platform for web scraping, data extraction, and web automation tasks.
|
|
6
6
|
It provides serverless applications called Actors for different tasks, like crawling websites, and scraping Facebook, Instagram, and Google results, etc.
|
|
@@ -17,7 +17,7 @@ pip install apify-haystack
|
|
|
17
17
|
|
|
18
18
|
## Examples
|
|
19
19
|
|
|
20
|
-
Crawl website using Apify Website Content Crawler and convert it to Haystack Documents
|
|
20
|
+
### Crawl a website using Apify's Website Content Crawler and convert it to Haystack Documents
|
|
21
21
|
|
|
22
22
|
You need to have an Apify account and API token to run this example.
|
|
23
23
|
You can start with a free account at [Apify](https://apify.com/) and get your [API token](https://docs.apify.com/platform/integrations/api).
|
|
@@ -30,7 +30,7 @@ from haystack import Document
|
|
|
30
30
|
|
|
31
31
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
32
32
|
|
|
33
|
-
#
|
|
33
|
+
# Set APIFY_API_TOKEN here or load it from .env file
|
|
34
34
|
apify_api_token = "" or load_dotenv()
|
|
35
35
|
|
|
36
36
|
actor_id = "apify/website-content-crawler"
|
|
@@ -57,11 +57,13 @@ for d in dataset:
|
|
|
57
57
|
print(d)
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
### More examples
|
|
61
|
+
|
|
60
62
|
See other examples in the [examples directory](https://github.com/apify/apify-haystack/blob/master/src/apify_haystack/examples) for more examples, here is a list of few of them
|
|
61
63
|
|
|
62
|
-
- Load a dataset from Apify and convert it to Haystack Document
|
|
63
|
-
- Call [Website Content Crawler](https://apify.com/apify/website-content-crawler)
|
|
64
|
-
- Crawl
|
|
64
|
+
- Load a dataset from Apify and convert it to a Haystack Document
|
|
65
|
+
- Call [Website Content Crawler](https://apify.com/apify/website-content-crawler) and convert the data into the Haystack Documents
|
|
66
|
+
- Crawl websites, retrieve text content, and store it in the `InMemoryDocumentStore`
|
|
65
67
|
- Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
|
|
66
68
|
|
|
67
69
|
## Support
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "apify_haystack"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.0b1"
|
|
8
8
|
description = "Apify-haystack integration"
|
|
9
9
|
authors = ["Apify Technologies s.r.o. <support@apify.com>"]
|
|
10
10
|
homepage = "https://apify.com"
|
|
@@ -12,7 +12,7 @@ from apify_haystack.constants import HAYSTACK_ATTRIBUTE_USER_AGENT
|
|
|
12
12
|
|
|
13
13
|
@component
|
|
14
14
|
class ApifyDatasetLoader:
|
|
15
|
-
"""Load datasets produced by
|
|
15
|
+
"""Load datasets produced by `Apify Actors`.
|
|
16
16
|
|
|
17
17
|
Actors are serverless functions that can be used to scrape, crawl, and extract data from the web.
|
|
18
18
|
For details, see https://docs.apify.com/platform/integrations/haystack
|
|
@@ -64,12 +64,12 @@ class ApifyDatasetLoader:
|
|
|
64
64
|
|
|
65
65
|
@component
|
|
66
66
|
class ApifyDatasetFromActorCall:
|
|
67
|
-
"""Get Apify dataset by calling Apify Actor.
|
|
67
|
+
"""Get an Apify dataset by calling an Apify Actor.
|
|
68
68
|
|
|
69
|
-
Perform call of Apify
|
|
69
|
+
Perform call of Apify Actor and load produced dataset.
|
|
70
70
|
For details, see https://docs.apify.com/platform/integrations/haystack
|
|
71
71
|
|
|
72
|
-
To use, you should have the ``apify-client`` python package installed,
|
|
72
|
+
To use it, you should have the ``apify-client`` python package installed,
|
|
73
73
|
and the environment variable ``APIFY_API_TOKEN`` set with your API key, or pass
|
|
74
74
|
`apify_api_token` as a named parameter to the constructor.
|
|
75
75
|
"""
|
|
@@ -147,9 +147,9 @@ class ApifyDatasetFromActorCall:
|
|
|
147
147
|
|
|
148
148
|
@component
|
|
149
149
|
class ApifyDatasetFromTaskCall:
|
|
150
|
-
"""Get Apify dataset by calling Apify
|
|
150
|
+
"""Get an Apify dataset by calling an Apify task.
|
|
151
151
|
|
|
152
|
-
Perform call of Apify task and load produced dataset.
|
|
152
|
+
Perform a call of an Apify task and load the produced dataset.
|
|
153
153
|
"""
|
|
154
154
|
|
|
155
155
|
def __init__(
|
|
@@ -171,7 +171,7 @@ class ApifyDatasetFromTaskCall:
|
|
|
171
171
|
dataset_mapping_function (Callable): A function that takes a single
|
|
172
172
|
dictionary (an Apify dataset item) and converts it to an
|
|
173
173
|
instance of the Document class.
|
|
174
|
-
build (str, optional): Optionally specifies the
|
|
174
|
+
build (str, optional): Optionally specifies the Actor build to run.
|
|
175
175
|
It can be either a build tag or build number.
|
|
176
176
|
memory_mbytes (int, optional): Optional memory limit for the run, in megabytes.
|
|
177
177
|
timeout_secs (int, optional): Optional timeout for the run, in seconds.
|
{apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/examples/apify_actor_call.py
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Call Apify Actor and load a dataset to convert it to Haystack Documents.
|
|
2
|
+
Call an Apify Actor and load a dataset to convert it to Haystack Documents.
|
|
3
3
|
|
|
4
4
|
This script demonstrates how to use Apify's Website Content Crawler to scrape text content from a specified website
|
|
5
5
|
and convert the scraped data into Haystack Documents.
|
|
6
6
|
|
|
7
7
|
For example, if you want to crawl and get text content from https://haystack.deepset.ai/, you can use this script
|
|
8
|
-
to call the Apify
|
|
8
|
+
to call the Apify Actor and retrieve the data in a structured format.
|
|
9
9
|
|
|
10
10
|
The script should produce the following output (an example of a single Document):
|
|
11
11
|
......
|
|
@@ -19,7 +19,7 @@ from haystack import Document
|
|
|
19
19
|
|
|
20
20
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
21
21
|
|
|
22
|
-
# Set
|
|
22
|
+
# Set APIFY_API_TOKEN here or load it from .env file
|
|
23
23
|
apify_api_token = "" or load_dotenv()
|
|
24
24
|
|
|
25
25
|
actor_id = "apify/website-content-crawler"
|
{apify_haystack-0.1.0a2 → apify_haystack-0.1.0b1}/src/apify_haystack/examples/apify_dataset_load.py
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Load a dataset from Apify and convert it to Haystack Documents.
|
|
3
3
|
|
|
4
4
|
This script demonstrates how to load a dataset from Apify and convert it into Haystack Documents.
|
|
5
|
-
Assuming you have run an Apify
|
|
5
|
+
Assuming you have run an Apify Actor that scraped web pages from https://docs.haystack.deepset.ai/,
|
|
6
6
|
you can use the dataset ID to load the dataset and transform it into a structured format suitable for Haystack.
|
|
7
7
|
|
|
8
8
|
The script should produce the following output (an example of a single Document):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Crawl
|
|
2
|
+
Crawl websites, scrape text content, and store it in the InMemoryDocumentStore.
|
|
3
3
|
|
|
4
|
-
This script demonstrates how to extract content from a website using
|
|
4
|
+
This script demonstrates how to extract content from a website using Apify's Website Content Crawler.
|
|
5
5
|
The content is then cleaned, split into smaller chunks, embedded, and stored in the InMemoryDocumentStore.
|
|
6
6
|
|
|
7
7
|
After the pipeline is executed, the documents are retrieved from the document store using BM25 retrieval.
|
|
@@ -30,7 +30,7 @@ from apify_haystack import ApifyDatasetFromActorCall
|
|
|
30
30
|
|
|
31
31
|
load_dotenv()
|
|
32
32
|
|
|
33
|
-
# Set
|
|
33
|
+
# Set APIFY_API_TOKEN here or use it from .env file
|
|
34
34
|
apify_api_token = "" or os.getenv("APIFY_API_TOKEN")
|
|
35
35
|
openai_api_key = "" or os.getenv("OPENAI_API_KEY")
|
|
36
36
|
|
|
@@ -31,7 +31,7 @@ from haystack.utils.auth import Secret
|
|
|
31
31
|
|
|
32
32
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
33
33
|
|
|
34
|
-
# Set
|
|
34
|
+
# Set APIFY_API_TOKEN here or use it from .env file
|
|
35
35
|
load_dotenv()
|
|
36
36
|
apify_api_token = "" or os.getenv("APIFY_API_TOKEN")
|
|
37
37
|
openai_api_key = "" or os.getenv("OPENAI_API_KEY")
|
|
@@ -64,6 +64,8 @@ retriever = InMemoryEmbeddingRetriever(document_store)
|
|
|
64
64
|
generator = OpenAIGenerator(model="gpt-3.5-turbo")
|
|
65
65
|
|
|
66
66
|
# Load documents from Apify
|
|
67
|
+
print("Crawling will take some time ...")
|
|
68
|
+
print("You can visit https://console.apify.com/actors/runs to monitor the progress")
|
|
67
69
|
docs = apify_dataset_loader.run()
|
|
68
70
|
embeddings = docs_embedder.run(docs.get("documents"))
|
|
69
71
|
document_store.write_documents(embeddings["documents"])
|
|
@@ -97,8 +99,6 @@ pipe.connect("prompt_builder", "llm")
|
|
|
97
99
|
|
|
98
100
|
question = "What is haystack?"
|
|
99
101
|
|
|
100
|
-
print("Running pipeline ... crawling will take some time ...")
|
|
101
|
-
print("You can visit https://console.apify.com/actors/runs to monitor the progress")
|
|
102
102
|
|
|
103
103
|
response = pipe.run({"embedder": {"text": question}, "prompt_builder": {"question": question}})
|
|
104
104
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|