@@ -69,7 +69,7 @@ def documents():
6969GreenTech Ltd. Leads SolarGrid Initiative
7070
7171San Francisco, CA — GreenTech Ltd. has emerged as a leader in renewable energy projects with the SolarGrid Initiative,
72- a collaboration with ACME Corporation. Jane Smith, the project’s Lead Manager, highlighted its ambitious goal:
72+ a collaboration with ACME Corporation. Jane Smith, the SolarGrid project’s Lead Manager, highlighted its ambitious goal:
7373providing affordable solar energy to underserved communities.
7474
7575GreenTech, headquartered in San Francisco, has worked closely with ACME since their partnership began in May 2021.
@@ -136,7 +136,7 @@ def graph_store(collection, entity_extraction_model, documents) -> MongoDBGraphS
136136
137137@pytest .fixture
138138def query_connection ():
139- return "How are Jane Smith and John Doe related?"
139+ return "How are the project manager Jane Smith and the Chief Technology Officer John Doe related?"
140140
141141
142142def test_add_docs_store (graph_store ):
@@ -145,17 +145,19 @@ def test_add_docs_store(graph_store):
145145 assert 4 <= len (extracted_entities ) < 8
146146
147147
148- @flaky
148+ @flaky ( max_runs = 3 , min_passes = 2 )
149149def test_extract_entity_names (graph_store , query_connection ):
150150 query_entity_names = graph_store .extract_entity_names (query_connection )
151151 assert set (query_entity_names ) == {"John Doe" , "Jane Smith" }
152152
153+
154+ def test_extract_entities_from_empty_string_names (graph_store ):
153155 no_names = graph_store .extract_entity_names ("" )
154156 assert isinstance (no_names , list )
155157 assert len (no_names ) == 0
156158
157159
158- @flaky
160+ @flaky ( max_runs = 3 , min_passes = 1 )
159161def test_related_entities (graph_store ):
160162 entity_names = ["John Doe" , "Jane Smith" ]
161163 related_entities = graph_store .related_entities (entity_names )
@@ -166,7 +168,7 @@ def test_related_entities(graph_store):
166168 assert len (no_entities ) == 0
167169
168170
169- @flaky
171+ @flaky ( max_runs = 3 , min_passes = 1 )
170172def test_additional_entity_examples (entity_extraction_model , entity_example , documents ):
171173 # First, create one client just to drop any existing collections
172174 client = MongoClient (CONNECTION_STRING )
@@ -190,15 +192,15 @@ def test_additional_entity_examples(entity_extraction_model, entity_example, doc
190192 assert len (new_entities ) >= 2
191193
192194
193- @flaky
195+ @flaky ( max_runs = 3 , min_passes = 1 )
194196def test_chat_response (graph_store , query_connection ):
195197 """Displays querying an existing Knowledge Graph Database"""
196198 answer = graph_store .chat_response (query_connection )
197199 assert isinstance (answer , AIMessage )
198200 assert "acme corporation" in answer .content .lower ()
199201
200202
201- @flaky
203+ @flaky ( max_runs = 3 , min_passes = 1 )
202204def test_similarity_search (graph_store , query_connection ):
203205 docs = graph_store .similarity_search (query_connection )
204206 assert len (docs ) >= 4
@@ -207,7 +209,7 @@ def test_similarity_search(graph_store, query_connection):
207209 assert any ("attributes" in d .keys () for d in docs )
208210
209211
210- @flaky
212+ @flaky ( max_runs = 3 , min_passes = 1 )
211213def test_validator (documents , entity_extraction_model ):
212214 # Case 1. No existing collection.
213215 client = MongoClient (CONNECTION_STRING )
@@ -261,7 +263,7 @@ def test_validator(documents, entity_extraction_model):
261263 client .close ()
262264
263265
264- @flaky
266+ @flaky ( max_runs = 3 , min_passes = 1 )
265267def test_allowed_entity_types (documents , entity_extraction_model ):
266268 """Add allowed_entity_types. Use the validator to confirm behaviour."""
267269 allowed_entity_types = ["Person" ]
@@ -289,7 +291,7 @@ def test_allowed_entity_types(documents, entity_extraction_model):
289291 all ([len (e ["relationships" ].get ("attributes" , [])) == 0 for e in entities ])
290292
291293
292- @flaky
294+ @flaky ( max_runs = 3 , min_passes = 1 )
293295def test_allowed_relationship_types (documents , entity_extraction_model ):
294296 # drop collection
295297 client = MongoClient (CONNECTION_STRING )
0 commit comments