Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example code for Astra DB pipeline #481

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions integrations/astra/examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@
logger.info(file_paths)

collection_name = os.getenv("COLLECTION_NAME", "haystack_vector_search")
keyspace_name = os.getenv("KEYSPACE_NAME", "recommender_demo")

# Make sure ASTRA_API_ENDPOINT and ASTRA_TOKEN environment variables are set before proceeding
# Make sure ASTRA_DB_API_ENDPOINT and ASTRA_DB_APPLICATION_TOKEN environment variables are set before proceeding

# We support many different databases. Here, we load a simple and lightweight in-memory database.
document_store = AstraDocumentStore(
astra_collection=collection_name,
astra_keyspace=keyspace_name,
collection_name=collection_name,
duplicates_policy=DuplicatePolicy.OVERWRITE,
embedding_dim=384,
embedding_dimension=384,
)

# Create components and an indexing pipeline that converts txt files to documents,
Expand Down
10 changes: 4 additions & 6 deletions integrations/astra/examples/pipeline_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@
"""

collection_name = os.getenv("COLLECTION_NAME", "haystack_vector_search")
keyspace_name = os.getenv("KEYSPACE_NAME", "recommender_demo")

# Make sure ASTRA_API_ENDPOINT and ASTRA_TOKEN environment variables are set before proceeding
# Make sure ASTRA_DB_API_ENDPOINT and ASTRA_DB_APPLICATION_TOKEN environment variables are set before proceeding

# We support many different databases. Here, we load a simple and lightweight in-memory database.
document_store = AstraDocumentStore(
astra_collection=collection_name,
astra_keyspace=keyspace_name,
collection_name=collection_name,
duplicates_policy=DuplicatePolicy.SKIP,
embedding_dim=384,
embedding_dimension=384,
)


Expand Down Expand Up @@ -74,7 +72,7 @@
)
rag_pipeline.add_component(instance=AstraEmbeddingRetriever(document_store=document_store), name="retriever")
rag_pipeline.add_component(instance=PromptBuilder(template=prompt_template), name="prompt_builder")
rag_pipeline.add_component(instance=OpenAIGenerator(api_key=os.environ.get("OPENAI_API_KEY")), name="llm")
rag_pipeline.add_component(instance=OpenAIGenerator(), name="llm")
rag_pipeline.add_component(instance=AnswerBuilder(), name="answer_builder")
rag_pipeline.connect("embedder", "retriever")
rag_pipeline.connect("retriever", "prompt_builder.documents")
Expand Down
3 changes: 2 additions & 1 deletion integrations/astra/examples/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
haystack-ai==2.0.0b4
sentence_transformers==2.2.2
openai==1.6.1
openai==1.6.1
astrapy>=0.7.0