Skip to content

Commit

Permalink
Fix example code for Astra DB pipeline (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
erichare authored Feb 26, 2024
1 parent 8e4db9e commit 6119e5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
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

0 comments on commit 6119e5c

Please sign in to comment.