apify-haystack 0.0.1a4__tar.gz → 0.0.1a5__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.1a4
3
+ Version: 0.0.1a5
4
4
  Summary: Apify-haystack integration
5
5
  Home-page: https://apify.com
6
6
  License: Apache-2.0
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Topic :: Software Development :: Libraries
21
21
  Requires-Dist: apify-client (>=1.7.1,<2.0.0)
22
- Requires-Dist: haystack-ai (>=2.3.0,<3.0.0)
22
+ Requires-Dist: haystack-ai (>=2.3.1,<3.0.0)
23
23
  Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
24
24
  Project-URL: Changelog, https://github.com/apify/apify-haystack/blob/master/CHANGELOG.md
25
25
  Project-URL: Documentation, https://github.com/apify/apify-haystack
@@ -29,11 +29,12 @@ Description-Content-Type: text/markdown
29
29
 
30
30
  # Apify-Haystack integration
31
31
 
32
- Apify-Haystack integration allows to quickly fetch results from Apify Actors.
32
+ The Apify-Haystack integration allows easy interaction between the Apify platform and Haystack.
33
33
 
34
- 🚧 **Work In Progress** 🚧
34
+ Apify is a platform for web scraping, data extraction, and web automation tasks.
35
+ It provides serverless applications called Actors for different tasks, like crawling websites, and scraping Facebook, Instagram, and Google results, etc.
35
36
 
36
- This project is currently under active development.
37
+ Haystack offers an ecosystem of tools for building, managing, and deploying search engines and LLM applications.
37
38
 
38
39
  ## Installation
39
40
 
@@ -45,9 +46,10 @@ pip install apify-haystack
45
46
 
46
47
  ## Examples
47
48
 
48
- Here are some practical examples to help you get started ...
49
-
50
- ## Features
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)
51
53
 
52
54
  ## Support
53
55
 
@@ -0,0 +1,38 @@
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
+ - 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)
24
+
25
+ ## Support
26
+
27
+ If you find any bug or issue, please [submit an issue on GitHub](https://github.com/apify/apify-haystack/issues).
28
+ 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).
29
+
30
+ ## Contributing
31
+
32
+ Your code contributions are welcome, and you'll be praised for eternity!
33
+ If you have any ideas for improvements, either submit an issue or create a pull request.
34
+ For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
35
+
36
+ ## License
37
+
38
+ 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.0.1a4"
7
+ version = "0.0.1a5"
8
8
  description = "Apify-haystack integration"
9
9
  authors = ["Apify Technologies s.r.o. <support@apify.com>"]
10
10
  homepage = "https://apify.com"
@@ -44,7 +44,7 @@ keywords = [
44
44
  [tool.poetry.dependencies]
45
45
  python = "^3.9"
46
46
  apify-client = "^1.7.1"
47
- haystack-ai = "^2.3.0"
47
+ haystack-ai = "^2.3.1"
48
48
  python-dotenv = "^1.0.1"
49
49
 
50
50
  [tool.poetry.group.dev.dependencies]
@@ -1,4 +1,6 @@
1
1
  """
2
+ Crawl website, scrape text content, and store it in the InMemoryDocumentStore.
3
+
2
4
  This script demonstrates how to extract content from a website using the Apify actor: Website Content Crawler.
3
5
  The content is then cleaned, split into smaller chunks, embedded, and stored in the InMemoryDocumentStore.
4
6
 
@@ -78,7 +80,7 @@ pipe.run({"document_loader": {}})
78
80
 
79
81
  print(f"Added {document_store.count_documents()} to vector from Website Content Crawler")
80
82
 
81
- print("\nRetrieving documents from the document store: query='Haystack'")
82
- print("query='Haystack'\n")
83
+ print("Retrieving documents from the document store: query='Haystack'")
84
+ print("query='Haystack'")
83
85
  for doc in document_store.bm25_retrieval("Haystack", top_k=1):
84
86
  print(doc)
@@ -1,8 +1,5 @@
1
1
  """
2
- Retrieval-Augmented Generation (RAG)
3
-
4
- This script demonstrates how to extract text content from a website, store it in a vector database, and use
5
- it for question answering.
2
+ Retrieval-Augmented Generation (RAG): Extracting text content from a website and using it for question answering.
6
3
 
7
4
  Steps involved:
8
5
  - Load environment variables, including API keys.
@@ -35,9 +32,9 @@ from haystack.utils.auth import Secret
35
32
  from apify_haystack import ApifyDatasetFromActorCall
36
33
 
37
34
  # Set APIFY-API-TOKEN here or use it from .env file
35
+ load_dotenv()
38
36
  apify_token = "" or os.getenv("APIFY_API_TOKEN")
39
37
  openai_api_key = "" or os.getenv("OPENAI_API_KEY")
40
- load_dotenv()
41
38
 
42
39
  actor_id = "apify/website-content-crawler"
43
40
  run_input = {
@@ -55,6 +52,7 @@ apify_dataset_loader = ApifyDatasetFromActorCall(
55
52
  )
56
53
 
57
54
  # Components
55
+ print("Initializing components...")
58
56
  document_store = InMemoryDocumentStore()
59
57
 
60
58
  docs_embedder = OpenAIDocumentEmbedder(api_key=Secret.from_token(openai_api_key))
@@ -82,6 +80,7 @@ Answer:
82
80
  prompt_builder = PromptBuilder(template=template)
83
81
 
84
82
  # Add components to your pipeline
83
+ print("Initializing pipeline...")
85
84
  pipe = Pipeline()
86
85
  pipe.add_component("embedder", text_embedder)
87
86
  pipe.add_component("retriever", retriever)
@@ -95,6 +94,9 @@ pipe.connect("prompt_builder", "llm")
95
94
 
96
95
  question = "What is haystack?"
97
96
 
97
+ print("Running pipeline ... crawling will take some time ...")
98
+ print("You can visit https://console.apify.com/actors/runs to monitor the progress")
99
+
98
100
  response = pipe.run({"embedder": {"text": question}, "prompt_builder": {"question": question}})
99
101
 
100
102
  print(f"question: {question}")
@@ -108,4 +110,5 @@ examples = [
108
110
 
109
111
  for example in examples:
110
112
  response = pipe.run({"embedder": {"text": example}, "prompt_builder": {"question": example}})
111
- print(response["llm"]["replies"][0])
113
+ print(f"question: {question}")
114
+ print(f"answer: {response['llm']['replies'][0]}")
@@ -1,36 +0,0 @@
1
- # Apify-Haystack integration
2
-
3
- Apify-Haystack integration allows to quickly fetch results from Apify Actors.
4
-
5
- 🚧 **Work In Progress** 🚧
6
-
7
- This project is currently under active development.
8
-
9
- ## Installation
10
-
11
- Apify-haystack is available as the [`apify-haystack`](https://pypi.org/project/apify-haystack/) PyPI package.
12
-
13
- ```sh
14
- pip install apify-haystack
15
- ```
16
-
17
- ## Examples
18
-
19
- Here are some practical examples to help you get started ...
20
-
21
- ## Features
22
-
23
- ## Support
24
-
25
- If you find any bug or issue, please [submit an issue on GitHub](https://github.com/apify/apify-haystack/issues).
26
- 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).
27
-
28
- ## Contributing
29
-
30
- Your code contributions are welcome, and you'll be praised for eternity!
31
- If you have any ideas for improvements, either submit an issue or create a pull request.
32
- For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
33
-
34
- ## License
35
-
36
- 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.