| 
									
										
										
										
											2023-09-06 12:14:08 +02:00
										 |  |  | import os | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import pytest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from examples.getting_started import getting_started | 
					
						
							|  |  |  | from haystack.schema import Answer, Document | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-12 22:36:49 +02:00
										 |  |  | @pytest.mark.parametrize("provider", ["cohere", "huggingface", "openai"]) | 
					
						
							| 
									
										
										
										
											2023-09-06 12:14:08 +02:00
										 |  |  | def test_getting_started(provider): | 
					
						
							|  |  |  |     if provider == "anthropic": | 
					
						
							|  |  |  |         api_key = os.environ.get("ANTHROPIC_API_KEY", "") | 
					
						
							|  |  |  |     elif provider == "cohere": | 
					
						
							|  |  |  |         api_key = os.environ.get("COHERE_API_KEY", "") | 
					
						
							|  |  |  |     elif provider == "huggingface": | 
					
						
							|  |  |  |         api_key = os.environ.get("HUGGINGFACE_API_KEY", "") | 
					
						
							|  |  |  |     elif provider == "openai": | 
					
						
							|  |  |  |         api_key = os.environ.get("OPENAI_API_KEY", "") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-10 16:38:52 +02:00
										 |  |  |     if api_key: | 
					
						
							|  |  |  |         result = getting_started(provider=provider, API_KEY=api_key) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Testing only for functionality. Since model predictions from APIs might change, we cannot test those directly. | 
					
						
							|  |  |  |         assert isinstance(result, dict) | 
					
						
							|  |  |  |         assert type(result["answers"][0]) == Answer | 
					
						
							|  |  |  |         assert type(result["documents"][0]) == Document |