(embedding_name)
| 70 | |
| 71 | # Function to check embedding API connectivity |
| 72 | async def check_embedding_api(embedding_name) -> bool: |
| 73 | print(f"Checking embedding API connectivity for {embedding_name}...") |
| 74 | if embedding_name not in CONFIG.embedding_providers: |
| 75 | await log_unknown_provider("embedding", embedding_name) |
| 76 | return False |
| 77 | |
| 78 | try: |
| 79 | test_prompt = "What is the capital of France?" |
| 80 | output = await get_embedding(test_prompt, provider=embedding_name, model=CONFIG.embedding_providers[embedding_name].model, timeout=30) |
| 81 | #print(f"Output from {embedding_name}: {output}") |
| 82 | #print(str(output)) |
| 83 | if not output: |
| 84 | print(f"❌ Embedding API connectivity check failed for {embedding_name}: No valid output received.") |
| 85 | return False |
| 86 | # Verify output is a list of floats |
| 87 | elif isinstance(output, list) and len(output) > 2 and all(isinstance(i, float) for i in output): |
| 88 | print(f"✅ Embedding API connectivity check successful for {embedding_name}. Output is list of floats.") |
| 89 | return True |
| 90 | else: |
| 91 | print(f"❌ Embedding API connectivity check failed for {embedding_name}: Output is not a list of floats. Please verify manually: {output!s}") |
| 92 | return False |
| 93 | except Exception as e: |
| 94 | print(f"❌ Embedding API connectivity check failed for {embedding_name}: {type(e).__name__}: {e!s}") |
| 95 | return False |
| 96 | |
| 97 | |
| 98 | # Function to check retriever connectivity |
no test coverage detected