apify-haystack 0.0.1a6__tar.gz → 0.1.0a2__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.0.1a6 → apify_haystack-0.1.0a2}/PKG-INFO +46 -6
- apify_haystack-0.1.0a2/README.md +80 -0
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/pyproject.toml +1 -1
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/__init__.py +2 -2
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/examples/apify_actor_call.py +9 -4
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/examples/crawl_and_process_data.py +5 -2
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/examples/rag_with_crawled_website.py +5 -2
- apify_haystack-0.0.1a6/README.md +0 -40
- apify_haystack-0.0.1a6/src/apify_haystack/main.py +0 -5
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/LICENSE +0 -0
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/apify_dataset.py +0 -0
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/constants.py +0 -0
- {apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/examples/apify_dataset_load.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: apify_haystack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.0a2
|
|
4
4
|
Summary: Apify-haystack integration
|
|
5
5
|
Home-page: https://apify.com
|
|
6
6
|
License: Apache-2.0
|
|
@@ -38,7 +38,7 @@ Haystack offers an ecosystem of tools for building, managing, and deploying sear
|
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
41
|
-
Apify-haystack is available
|
|
41
|
+
Apify-haystack is available at the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
44
|
pip install apify-haystack
|
|
@@ -46,11 +46,51 @@ pip install apify-haystack
|
|
|
46
46
|
|
|
47
47
|
## Examples
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Crawl website using Apify Website Content Crawler and convert it to Haystack Documents.
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
You need to have an Apify account and API token to run this example.
|
|
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).
|
|
53
|
+
|
|
54
|
+
In the example below, specify `apify_api_token` and run the script:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from dotenv import load_dotenv
|
|
58
|
+
from haystack import Document
|
|
59
|
+
|
|
60
|
+
from apify_haystack import ApifyDatasetFromActorCall
|
|
61
|
+
|
|
62
|
+
# Sey APIFY-API-TOKEN here or load it from .env file
|
|
63
|
+
apify_api_token = "" or load_dotenv()
|
|
64
|
+
|
|
65
|
+
actor_id = "apify/website-content-crawler"
|
|
66
|
+
run_input = {
|
|
67
|
+
"maxCrawlPages": 3, # limit the number of pages to crawl
|
|
68
|
+
"startUrls": [{"url": "https://haystack.deepset.ai/"}],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def dataset_mapping_function(dataset_item: dict) -> Document:
|
|
73
|
+
return Document(content=dataset_item.get("text"), meta={"url": dataset_item.get("url")})
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
actor = ApifyDatasetFromActorCall(
|
|
77
|
+
actor_id=actor_id, run_input=run_input, dataset_mapping_function=dataset_mapping_function
|
|
78
|
+
)
|
|
79
|
+
print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
|
|
80
|
+
print("You can monitor the progress at: https://console.apify.com/actors/runs")
|
|
81
|
+
|
|
82
|
+
dataset = actor.run().get("documents")
|
|
83
|
+
|
|
84
|
+
print(f"Loaded {len(dataset)} documents from the Apify Actor {actor_id}:")
|
|
85
|
+
for d in dataset:
|
|
86
|
+
print(d)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
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
|
+
|
|
91
|
+
- Load a dataset from Apify and convert it to Haystack Document
|
|
92
|
+
- Call [Website Content Crawler](https://apify.com/apify/website-content-crawler) Actor and convert the data into the Haystack Documents
|
|
93
|
+
- Crawl website, retrieve text content, and store it in the `InMemoryDocumentStore`
|
|
54
94
|
- Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
|
|
55
95
|
|
|
56
96
|
## Support
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Apify-Haystack integration
|
|
2
|
+
|
|
3
|
+
The Apify-Haystack integration allows easy interaction between the Apify platform and Haystack.
|
|
4
|
+
|
|
5
|
+
Apify is a platform for web scraping, data extraction, and web automation tasks.
|
|
6
|
+
It provides serverless applications called Actors for different tasks, like crawling websites, and scraping Facebook, Instagram, and Google results, etc.
|
|
7
|
+
|
|
8
|
+
Haystack offers an ecosystem of tools for building, managing, and deploying search engines and LLM applications.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Apify-haystack is available at the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pip install apify-haystack
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
Crawl website using Apify Website Content Crawler and convert it to Haystack Documents.
|
|
21
|
+
|
|
22
|
+
You need to have an Apify account and API token to run this example.
|
|
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).
|
|
24
|
+
|
|
25
|
+
In the example below, specify `apify_api_token` and run the script:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from dotenv import load_dotenv
|
|
29
|
+
from haystack import Document
|
|
30
|
+
|
|
31
|
+
from apify_haystack import ApifyDatasetFromActorCall
|
|
32
|
+
|
|
33
|
+
# Sey APIFY-API-TOKEN here or load it from .env file
|
|
34
|
+
apify_api_token = "" or load_dotenv()
|
|
35
|
+
|
|
36
|
+
actor_id = "apify/website-content-crawler"
|
|
37
|
+
run_input = {
|
|
38
|
+
"maxCrawlPages": 3, # limit the number of pages to crawl
|
|
39
|
+
"startUrls": [{"url": "https://haystack.deepset.ai/"}],
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def dataset_mapping_function(dataset_item: dict) -> Document:
|
|
44
|
+
return Document(content=dataset_item.get("text"), meta={"url": dataset_item.get("url")})
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
actor = ApifyDatasetFromActorCall(
|
|
48
|
+
actor_id=actor_id, run_input=run_input, dataset_mapping_function=dataset_mapping_function
|
|
49
|
+
)
|
|
50
|
+
print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
|
|
51
|
+
print("You can monitor the progress at: https://console.apify.com/actors/runs")
|
|
52
|
+
|
|
53
|
+
dataset = actor.run().get("documents")
|
|
54
|
+
|
|
55
|
+
print(f"Loaded {len(dataset)} documents from the Apify Actor {actor_id}:")
|
|
56
|
+
for d in dataset:
|
|
57
|
+
print(d)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
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
|
+
|
|
62
|
+
- Load a dataset from Apify and convert it to Haystack Document
|
|
63
|
+
- Call [Website Content Crawler](https://apify.com/apify/website-content-crawler) Actor and convert the data into the Haystack Documents
|
|
64
|
+
- Crawl website, retrieve text content, and store it in the `InMemoryDocumentStore`
|
|
65
|
+
- Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
|
|
66
|
+
|
|
67
|
+
## Support
|
|
68
|
+
|
|
69
|
+
If you find any bug or issue, please [submit an issue on GitHub](https://github.com/apify/apify-haystack/issues).
|
|
70
|
+
For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify), in GitHub Discussions or you can join our [Discord server](https://discord.com/invite/jyEM2PRvMU).
|
|
71
|
+
|
|
72
|
+
## Contributing
|
|
73
|
+
|
|
74
|
+
Your code contributions are welcome.
|
|
75
|
+
If you have any ideas for improvements, either submit an issue or create a pull request.
|
|
76
|
+
For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](https://github.com/apify/apify-haystack/blob/master/LICENSE) file for details.
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "apify_haystack"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.1.0a2"
|
|
8
8
|
description = "Apify-haystack integration"
|
|
9
9
|
authors = ["Apify Technologies s.r.o. <support@apify.com>"]
|
|
10
10
|
homepage = "https://apify.com"
|
|
@@ -2,6 +2,6 @@ from importlib import metadata
|
|
|
2
2
|
|
|
3
3
|
__version__ = metadata.version("apify-haystack")
|
|
4
4
|
|
|
5
|
-
from apify_haystack.apify_dataset import ApifyDatasetFromActorCall, ApifyDatasetLoader
|
|
5
|
+
from apify_haystack.apify_dataset import ApifyDatasetFromActorCall, ApifyDatasetFromTaskCall, ApifyDatasetLoader
|
|
6
6
|
|
|
7
|
-
__all__ = ["ApifyDatasetLoader", "ApifyDatasetFromActorCall", "
|
|
7
|
+
__all__ = ["ApifyDatasetLoader", "ApifyDatasetFromActorCall", "ApifyDatasetFromTaskCall"]
|
{apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/examples/apify_actor_call.py
RENAMED
|
@@ -19,8 +19,8 @@ from haystack import Document
|
|
|
19
19
|
|
|
20
20
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
21
21
|
|
|
22
|
-
#
|
|
23
|
-
|
|
22
|
+
# Set APIFY-API-TOKEN here or load it from .env file
|
|
23
|
+
apify_api_token = "" or load_dotenv()
|
|
24
24
|
|
|
25
25
|
actor_id = "apify/website-content-crawler"
|
|
26
26
|
run_input = {
|
|
@@ -34,9 +34,14 @@ def dataset_mapping_function(dataset_item: dict) -> Document:
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
actor = ApifyDatasetFromActorCall(
|
|
37
|
-
actor_id=actor_id,
|
|
37
|
+
actor_id=actor_id,
|
|
38
|
+
run_input=run_input,
|
|
39
|
+
dataset_mapping_function=dataset_mapping_function,
|
|
40
|
+
apify_api_token=str(apify_api_token),
|
|
38
41
|
)
|
|
39
|
-
print(f"Calling Apify actor {actor_id} ... crawling will take some time ...")
|
|
42
|
+
print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
|
|
43
|
+
print("You can monitor the progress at: https://console.apify.com/actors/runs")
|
|
44
|
+
|
|
40
45
|
dataset = actor.run().get("documents")
|
|
41
46
|
|
|
42
47
|
print(f"Loaded {len(dataset)} documents from the Apify Actor {actor_id}:")
|
|
@@ -31,7 +31,7 @@ from apify_haystack import ApifyDatasetFromActorCall
|
|
|
31
31
|
load_dotenv()
|
|
32
32
|
|
|
33
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
|
|
|
37
37
|
actor_id = "apify/website-content-crawler"
|
|
@@ -46,7 +46,10 @@ def dataset_mapping_function(dataset_item: dict) -> Document:
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
document_loader = ApifyDatasetFromActorCall(
|
|
49
|
-
actor_id=actor_id,
|
|
49
|
+
actor_id=actor_id,
|
|
50
|
+
run_input=run_input,
|
|
51
|
+
dataset_mapping_function=dataset_mapping_function,
|
|
52
|
+
apify_api_token=apify_api_token,
|
|
50
53
|
)
|
|
51
54
|
|
|
52
55
|
document_store = InMemoryDocumentStore()
|
|
@@ -33,7 +33,7 @@ from apify_haystack import ApifyDatasetFromActorCall
|
|
|
33
33
|
|
|
34
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")
|
|
38
38
|
|
|
39
39
|
actor_id = "apify/website-content-crawler"
|
|
@@ -48,7 +48,10 @@ def dataset_mapping_function(dataset_item: dict) -> Document:
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
apify_dataset_loader = ApifyDatasetFromActorCall(
|
|
51
|
-
actor_id=actor_id,
|
|
51
|
+
actor_id=actor_id,
|
|
52
|
+
run_input=run_input,
|
|
53
|
+
dataset_mapping_function=dataset_mapping_function,
|
|
54
|
+
apify_api_token=apify_api_token,
|
|
52
55
|
)
|
|
53
56
|
|
|
54
57
|
# Components
|
apify_haystack-0.0.1a6/README.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# Apify-Haystack integration
|
|
2
|
-
|
|
3
|
-
The Apify-Haystack integration allows easy interaction between the Apify platform and Haystack.
|
|
4
|
-
|
|
5
|
-
Apify is a platform for web scraping, data extraction, and web automation tasks.
|
|
6
|
-
It provides serverless applications called Actors for different tasks, like crawling websites, and scraping Facebook, Instagram, and Google results, etc.
|
|
7
|
-
|
|
8
|
-
Haystack offers an ecosystem of tools for building, managing, and deploying search engines and LLM applications.
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
Apify-haystack is available as the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
pip install apify-haystack
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Examples
|
|
19
|
-
|
|
20
|
-
See 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
|
|
21
|
-
|
|
22
|
-
- Load a dataset from Apify and convert it to Haystack Documents
|
|
23
|
-
- Call Apify Actor and load a dataset to convert it to Haystack Documents
|
|
24
|
-
- Crawl website, scrape text content, and store it in the InMemoryDocumentStore
|
|
25
|
-
- Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
|
|
26
|
-
|
|
27
|
-
## Support
|
|
28
|
-
|
|
29
|
-
If you find any bug or issue, please [submit an issue on GitHub](https://github.com/apify/apify-haystack/issues).
|
|
30
|
-
For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify), in GitHub Discussions or you can join our [Discord server](https://discord.com/invite/jyEM2PRvMU).
|
|
31
|
-
|
|
32
|
-
## Contributing
|
|
33
|
-
|
|
34
|
-
Your code contributions are welcome.
|
|
35
|
-
If you have any ideas for improvements, either submit an issue or create a pull request.
|
|
36
|
-
For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
|
|
37
|
-
|
|
38
|
-
## License
|
|
39
|
-
|
|
40
|
-
This project is licensed under the Apache License 2.0 - see the [LICENSE](https://github.com/apify/apify-haystack/blob/master/LICENSE) file for details.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{apify_haystack-0.0.1a6 → apify_haystack-0.1.0a2}/src/apify_haystack/examples/apify_dataset_load.py
RENAMED
|
File without changes
|