apify-haystack 0.0.1a5__tar.gz → 0.1.0a1__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.0.1a5
3
+ Version: 0.1.0a1
4
4
  Summary: Apify-haystack integration
5
5
  Home-page: https://apify.com
6
6
  License: Apache-2.0
@@ -46,10 +46,47 @@ pip install apify-haystack
46
46
 
47
47
  ## Examples
48
48
 
49
- - Load a dataset from Apify and convert it to Haystack Documents: [apify_dataset_load.py](src/apify_haystack/examples/apify_dataset_load.py)
50
- - Call Apify Actor and load a dataset to convert it to Haystack Documents: [apify_actor_call.py](src/apify_haystack/examples/apify_actor_call.py)
51
- - Crawl website, scrape text content, and store it in the InMemoryDocumentStore: [crawl_and_process_data.py](src/apify_haystack/examples/crawl_and_process_data.py)
52
- - Retrieval-Augmented Generation (RAG): Extracting text content from a website and using it for question answering [rag_with_crawled_website.py](src/apify_haystack/examples/rag_with_crawled_website.py)
49
+ Crawl website using Apify Website Content Crawler and convert it to Haystack Documents
50
+
51
+ ```python
52
+ from dotenv import load_dotenv
53
+ from haystack import Document
54
+
55
+ from apify_haystack import ApifyDatasetFromActorCall
56
+
57
+ # Sey APIFY-API-TOKEN here or load it from .env file
58
+ apify_token = "" or load_dotenv()
59
+
60
+ actor_id = "apify/website-content-crawler"
61
+ run_input = {
62
+ "maxCrawlPages": 3, # limit the number of pages to crawl
63
+ "startUrls": [{"url": "https://haystack.deepset.ai/"}],
64
+ }
65
+
66
+
67
+ def dataset_mapping_function(dataset_item: dict) -> Document:
68
+ return Document(content=dataset_item.get("text"), meta={"url": dataset_item.get("url")})
69
+
70
+
71
+ actor = ApifyDatasetFromActorCall(
72
+ actor_id=actor_id, run_input=run_input, dataset_mapping_function=dataset_mapping_function
73
+ )
74
+ print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
75
+ print("You can monitor the progress at: https://console.apify.com/actors/runs")
76
+
77
+ dataset = actor.run().get("documents")
78
+
79
+ print(f"Loaded {len(dataset)} documents from the Apify Actor {actor_id}:")
80
+ for d in dataset:
81
+ print(d)
82
+ ```
83
+
84
+ 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
+
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
89
+ - Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
53
90
 
54
91
  ## Support
55
92
 
@@ -58,7 +95,7 @@ For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questio
58
95
 
59
96
  ## Contributing
60
97
 
61
- Your code contributions are welcome, and you'll be praised for eternity!
98
+ Your code contributions are welcome.
62
99
  If you have any ideas for improvements, either submit an issue or create a pull request.
63
100
  For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
64
101
 
@@ -17,10 +17,47 @@ pip install apify-haystack
17
17
 
18
18
  ## Examples
19
19
 
20
- - Load a dataset from Apify and convert it to Haystack Documents: [apify_dataset_load.py](src/apify_haystack/examples/apify_dataset_load.py)
21
- - Call Apify Actor and load a dataset to convert it to Haystack Documents: [apify_actor_call.py](src/apify_haystack/examples/apify_actor_call.py)
22
- - Crawl website, scrape text content, and store it in the InMemoryDocumentStore: [crawl_and_process_data.py](src/apify_haystack/examples/crawl_and_process_data.py)
23
- - Retrieval-Augmented Generation (RAG): Extracting text content from a website and using it for question answering [rag_with_crawled_website.py](src/apify_haystack/examples/rag_with_crawled_website.py)
20
+ Crawl website using Apify Website Content Crawler and convert it to Haystack Documents
21
+
22
+ ```python
23
+ from dotenv import load_dotenv
24
+ from haystack import Document
25
+
26
+ from apify_haystack import ApifyDatasetFromActorCall
27
+
28
+ # Sey APIFY-API-TOKEN here or load it from .env file
29
+ apify_token = "" or load_dotenv()
30
+
31
+ actor_id = "apify/website-content-crawler"
32
+ run_input = {
33
+ "maxCrawlPages": 3, # limit the number of pages to crawl
34
+ "startUrls": [{"url": "https://haystack.deepset.ai/"}],
35
+ }
36
+
37
+
38
+ def dataset_mapping_function(dataset_item: dict) -> Document:
39
+ return Document(content=dataset_item.get("text"), meta={"url": dataset_item.get("url")})
40
+
41
+
42
+ actor = ApifyDatasetFromActorCall(
43
+ actor_id=actor_id, run_input=run_input, dataset_mapping_function=dataset_mapping_function
44
+ )
45
+ print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
46
+ print("You can monitor the progress at: https://console.apify.com/actors/runs")
47
+
48
+ dataset = actor.run().get("documents")
49
+
50
+ print(f"Loaded {len(dataset)} documents from the Apify Actor {actor_id}:")
51
+ for d in dataset:
52
+ print(d)
53
+ ```
54
+
55
+ 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
+
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
60
+ - Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
24
61
 
25
62
  ## Support
26
63
 
@@ -29,7 +66,7 @@ For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questio
29
66
 
30
67
  ## Contributing
31
68
 
32
- Your code contributions are welcome, and you'll be praised for eternity!
69
+ Your code contributions are welcome.
33
70
  If you have any ideas for improvements, either submit an issue or create a pull request.
34
71
  For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
35
72
 
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "apify_haystack"
7
- version = "0.0.1a5"
7
+ version = "0.1.0a1"
8
8
  description = "Apify-haystack integration"
9
9
  authors = ["Apify Technologies s.r.o. <support@apify.com>"]
10
10
  homepage = "https://apify.com"
@@ -36,7 +36,9 @@ def dataset_mapping_function(dataset_item: dict) -> Document:
36
36
  actor = ApifyDatasetFromActorCall(
37
37
  actor_id=actor_id, run_input=run_input, dataset_mapping_function=dataset_mapping_function
38
38
  )
39
- print(f"Calling Apify actor {actor_id} ... crawling will take some time ...")
39
+ print(f"Calling the Apify actor {actor_id} ... crawling will take some time ...")
40
+ print("You can monitor the progress at: https://console.apify.com/actors/runs")
41
+
40
42
  dataset = actor.run().get("documents")
41
43
 
42
44
  print(f"Loaded {len(dataset)} documents from the Apify Actor {actor_id}:")
@@ -1,5 +0,0 @@
1
- from __future__ import annotations
2
-
3
-
4
- def main() -> None:
5
- """Main function."""