apify-haystack 0.0.1a4__tar.gz → 0.0.1a6__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.1a6
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,12 @@ pip install apify-haystack
45
46
 
46
47
  ## Examples
47
48
 
48
- Here are some practical examples to help you get started ...
49
+ 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
49
50
 
50
- ## Features
51
+ - Load a dataset from Apify and convert it to Haystack Documents
52
+ - Call Apify Actor and load a dataset to convert it to Haystack Documents
53
+ - Crawl website, scrape text content, and store it in the InMemoryDocumentStore
54
+ - Retrieval-Augmented Generation (RAG): Extracting text from a website & question answering
51
55
 
52
56
  ## Support
53
57
 
@@ -56,7 +60,7 @@ For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questio
56
60
 
57
61
  ## Contributing
58
62
 
59
- Your code contributions are welcome, and you'll be praised for eternity!
63
+ Your code contributions are welcome.
60
64
  If you have any ideas for improvements, either submit an issue or create a pull request.
61
65
  For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
62
66
 
@@ -1,10 +1,11 @@
1
1
  # Apify-Haystack integration
2
2
 
3
- Apify-Haystack integration allows to quickly fetch results from Apify Actors.
3
+ The Apify-Haystack integration allows easy interaction between the Apify platform and Haystack.
4
4
 
5
- 🚧 **Work In Progress** 🚧
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.
6
7
 
7
- This project is currently under active development.
8
+ Haystack offers an ecosystem of tools for building, managing, and deploying search engines and LLM applications.
8
9
 
9
10
  ## Installation
10
11
 
@@ -16,9 +17,12 @@ pip install apify-haystack
16
17
 
17
18
  ## Examples
18
19
 
19
- Here are some practical examples to help you get started ...
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
20
21
 
21
- ## Features
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
22
26
 
23
27
  ## Support
24
28
 
@@ -27,7 +31,7 @@ For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questio
27
31
 
28
32
  ## Contributing
29
33
 
30
- Your code contributions are welcome, and you'll be praised for eternity!
34
+ Your code contributions are welcome.
31
35
  If you have any ideas for improvements, either submit an issue or create a pull request.
32
36
  For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/apify-haystack/blob/master/CONTRIBUTING.md).
33
37
 
@@ -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.1a6"
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]}")