apify-haystack 0.1.0a1__tar.gz → 0.1.0a3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apify_haystack
3
- Version: 0.1.0a1
3
+ Version: 0.1.0a3
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.
@@ -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 as the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
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,7 +46,12 @@ 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 Website Content Crawler and convert it to Haystack Documents
50
+
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:
50
55
 
51
56
  ```python
52
57
  from dotenv import load_dotenv
@@ -54,8 +59,8 @@ from haystack import Document
54
59
 
55
60
  from apify_haystack import ApifyDatasetFromActorCall
56
61
 
57
- # Sey APIFY-API-TOKEN here or load it from .env file
58
- apify_token = "" or load_dotenv()
62
+ # Set APIFY_API_TOKEN here or load it from .env file
63
+ apify_api_token = "" or load_dotenv()
59
64
 
60
65
  actor_id = "apify/website-content-crawler"
61
66
  run_input = {
@@ -81,11 +86,13 @@ for d in dataset:
81
86
  print(d)
82
87
  ```
83
88
 
89
+ ### More Examples
90
+
84
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
85
92
 
86
- - Load a dataset from Apify and convert it to Haystack Documents
87
- - Call Apify Actor and load a dataset to convert it to Haystack Documents
88
- - Crawl website, scrape text content, and store it in the InMemoryDocumentStore
93
+ - Load a dataset from Apify and convert it to Haystack Document
94
+ - Call [Website Content Crawler](https://apify.com/apify/website-content-crawler) Actor and convert the data into the Haystack Documents
95
+ - Crawl website, retrieve text content, and store it in the `InMemoryDocumentStore`
89
96
  - Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
90
97
 
91
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.
@@ -9,7 +9,7 @@ Haystack offers an ecosystem of tools for building, managing, and deploying sear
9
9
 
10
10
  ## Installation
11
11
 
12
- Apify-haystack is available as the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
12
+ Apify-haystack is available at the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
13
13
 
14
14
  ```sh
15
15
  pip install apify-haystack
@@ -17,7 +17,12 @@ 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 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:
21
26
 
22
27
  ```python
23
28
  from dotenv import load_dotenv
@@ -25,8 +30,8 @@ from haystack import Document
25
30
 
26
31
  from apify_haystack import ApifyDatasetFromActorCall
27
32
 
28
- # Sey APIFY-API-TOKEN here or load it from .env file
29
- apify_token = "" or load_dotenv()
33
+ # Set APIFY_API_TOKEN here or load it from .env file
34
+ apify_api_token = "" or load_dotenv()
30
35
 
31
36
  actor_id = "apify/website-content-crawler"
32
37
  run_input = {
@@ -52,11 +57,13 @@ for d in dataset:
52
57
  print(d)
53
58
  ```
54
59
 
60
+ ### More Examples
61
+
55
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
56
63
 
57
- - Load a dataset from Apify and convert it to Haystack Documents
58
- - Call Apify Actor and load a dataset to convert it to Haystack Documents
59
- - Crawl website, scrape text content, and store it in the InMemoryDocumentStore
64
+ - Load a dataset from Apify and convert it to Haystack Document
65
+ - Call [Website Content Crawler](https://apify.com/apify/website-content-crawler) Actor and convert the data into the Haystack Documents
66
+ - Crawl website, retrieve text content, and store it in the `InMemoryDocumentStore`
60
67
  - Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
61
68
 
62
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.0a1"
7
+ version = "0.1.0a3"
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", "ApifyDatasetFromActorCall"]
7
+ __all__ = ["ApifyDatasetLoader", "ApifyDatasetFromActorCall", "ApifyDatasetFromTaskCall"]
@@ -19,8 +19,8 @@ from haystack import Document
19
19
 
20
20
  from apify_haystack import ApifyDatasetFromActorCall
21
21
 
22
- # Sey APIFY-API-TOKEN here or load it from .env file
23
- apify_token = "" or load_dotenv()
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,7 +34,10 @@ def dataset_mapping_function(dataset_item: dict) -> Document:
34
34
 
35
35
 
36
36
  actor = ApifyDatasetFromActorCall(
37
- actor_id=actor_id, run_input=run_input, dataset_mapping_function=dataset_mapping_function
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
42
  print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
40
43
  print("You can monitor the progress at: https://console.apify.com/actors/runs")
@@ -30,8 +30,8 @@ from apify_haystack import ApifyDatasetFromActorCall
30
30
 
31
31
  load_dotenv()
32
32
 
33
- # Set APIFY-API-TOKEN here or use it from .env file
34
- apify_token = "" or os.getenv("APIFY_API_TOKEN")
33
+ # Set APIFY_API_TOKEN here or use it from .env file
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, run_input=run_input, dataset_mapping_function=dataset_mapping_function
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()
@@ -31,9 +31,9 @@ from haystack.utils.auth import Secret
31
31
 
32
32
  from apify_haystack import ApifyDatasetFromActorCall
33
33
 
34
- # Set APIFY-API-TOKEN here or use it from .env file
34
+ # Set APIFY_API_TOKEN here or use it from .env file
35
35
  load_dotenv()
36
- apify_token = "" or os.getenv("APIFY_API_TOKEN")
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, run_input=run_input, dataset_mapping_function=dataset_mapping_function
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