apify-haystack 0.0.1a3__tar.gz → 0.0.1a4__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.1a3 → apify_haystack-0.0.1a4}/PKG-INFO +1 -1
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/pyproject.toml +1 -1
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/examples/crawl_and_process_data.py +12 -5
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/examples/rag_with_crawled_website.py +9 -6
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/LICENSE +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/README.md +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/__init__.py +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/apify_dataset.py +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/constants.py +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/examples/apify_actor_call.py +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/examples/apify_dataset_load.py +0 -0
- {apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/main.py +0 -0
|
@@ -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.
|
|
7
|
+
version = "0.0.1a4"
|
|
8
8
|
description = "Apify-haystack integration"
|
|
9
9
|
authors = ["Apify Technologies s.r.o. <support@apify.com>"]
|
|
10
10
|
homepage = "https://apify.com"
|
|
@@ -14,17 +14,23 @@ meta: {'url': 'https://haystack.deepset.ai/overview/quick-start',
|
|
|
14
14
|
.....
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
+
import os
|
|
18
|
+
|
|
17
19
|
from dotenv import load_dotenv
|
|
18
20
|
from haystack import Document, Pipeline
|
|
19
|
-
from haystack.components.embedders import
|
|
21
|
+
from haystack.components.embedders import OpenAIDocumentEmbedder
|
|
20
22
|
from haystack.components.preprocessors import DocumentCleaner, DocumentSplitter
|
|
21
23
|
from haystack.components.writers import DocumentWriter
|
|
22
24
|
from haystack.document_stores.in_memory import InMemoryDocumentStore
|
|
25
|
+
from haystack.utils.auth import Secret
|
|
23
26
|
|
|
24
27
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
load_dotenv()
|
|
30
|
+
|
|
31
|
+
# Set APIFY-API-TOKEN here or use it from .env file
|
|
32
|
+
apify_token = "" or os.getenv("APIFY_API_TOKEN")
|
|
33
|
+
openai_api_key = "" or os.getenv("OPENAI_API_KEY")
|
|
28
34
|
|
|
29
35
|
actor_id = "apify/website-content-crawler"
|
|
30
36
|
run_input = {
|
|
@@ -46,7 +52,7 @@ print(f"Initialized InMemoryDocumentStore with {document_store.count_documents()
|
|
|
46
52
|
|
|
47
53
|
document_cleaner = DocumentCleaner()
|
|
48
54
|
document_splitter = DocumentSplitter(split_by="word", split_length=150, split_overlap=50)
|
|
49
|
-
document_embedder =
|
|
55
|
+
document_embedder = OpenAIDocumentEmbedder(api_key=Secret.from_token(openai_api_key))
|
|
50
56
|
document_writer = DocumentWriter(document_store)
|
|
51
57
|
|
|
52
58
|
pipe = Pipeline()
|
|
@@ -72,6 +78,7 @@ pipe.run({"document_loader": {}})
|
|
|
72
78
|
|
|
73
79
|
print(f"Added {document_store.count_documents()} to vector from Website Content Crawler")
|
|
74
80
|
|
|
75
|
-
print("
|
|
81
|
+
print("\nRetrieving documents from the document store: query='Haystack'")
|
|
82
|
+
print("query='Haystack'\n")
|
|
76
83
|
for doc in document_store.bm25_retrieval("Haystack", top_k=1):
|
|
77
84
|
print(doc)
|
|
@@ -21,17 +21,22 @@ Haystack is an open-source framework for building production-ready LLM applicati
|
|
|
21
21
|
......
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
|
+
import os
|
|
25
|
+
|
|
24
26
|
from dotenv import load_dotenv
|
|
25
27
|
from haystack import Document, Pipeline
|
|
26
28
|
from haystack.components.builders import PromptBuilder
|
|
27
|
-
from haystack.components.embedders import
|
|
29
|
+
from haystack.components.embedders import OpenAIDocumentEmbedder, OpenAITextEmbedder
|
|
28
30
|
from haystack.components.generators import OpenAIGenerator
|
|
29
31
|
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever
|
|
30
32
|
from haystack.document_stores.in_memory import InMemoryDocumentStore
|
|
33
|
+
from haystack.utils.auth import Secret
|
|
31
34
|
|
|
32
35
|
from apify_haystack import ApifyDatasetFromActorCall
|
|
33
36
|
|
|
34
|
-
#
|
|
37
|
+
# Set APIFY-API-TOKEN here or use it from .env file
|
|
38
|
+
apify_token = "" or os.getenv("APIFY_API_TOKEN")
|
|
39
|
+
openai_api_key = "" or os.getenv("OPENAI_API_KEY")
|
|
35
40
|
load_dotenv()
|
|
36
41
|
|
|
37
42
|
actor_id = "apify/website-content-crawler"
|
|
@@ -52,10 +57,8 @@ apify_dataset_loader = ApifyDatasetFromActorCall(
|
|
|
52
57
|
# Components
|
|
53
58
|
document_store = InMemoryDocumentStore()
|
|
54
59
|
|
|
55
|
-
docs_embedder =
|
|
56
|
-
|
|
57
|
-
text_embedder = SentenceTransformersTextEmbedder(model="sentence-transformers/all-MiniLM-L6-v2")
|
|
58
|
-
text_embedder.warm_up()
|
|
60
|
+
docs_embedder = OpenAIDocumentEmbedder(api_key=Secret.from_token(openai_api_key))
|
|
61
|
+
text_embedder = OpenAITextEmbedder(api_key=Secret.from_token(openai_api_key))
|
|
59
62
|
retriever = InMemoryEmbeddingRetriever(document_store)
|
|
60
63
|
generator = OpenAIGenerator(model="gpt-3.5-turbo")
|
|
61
64
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/examples/apify_actor_call.py
RENAMED
|
File without changes
|
{apify_haystack-0.0.1a3 → apify_haystack-0.0.1a4}/src/apify_haystack/examples/apify_dataset_load.py
RENAMED
|
File without changes
|
|
File without changes
|