(llm_name)
| 43 | |
| 44 | # Function to check LLM API connectivity |
| 45 | async def check_llm_api(llm_name) -> bool: |
| 46 | print(f"Checking LLM API connectivity for {llm_name}...") |
| 47 | if llm_name not in CONFIG.llm_endpoints: |
| 48 | await log_unknown_provider("LLM", llm_name) |
| 49 | return False |
| 50 | |
| 51 | try: |
| 52 | schema = {"capital": "string"} |
| 53 | test_prompt = "What is the capital of France?" |
| 54 | # Using a larger timeout than the default because we don't want to fail on slow responses |
| 55 | output = await ask_llm(test_prompt, schema=schema, provider=llm_name, timeout=20) |
| 56 | #print(f"Output from {llm_name}: {output}") |
| 57 | if not output: |
| 58 | print(f"❌ LLM API connectivity check failed for {llm_name}: No valid output received.") |
| 59 | return False |
| 60 | elif str(output).__contains__("Paris") or str(output).__contains__("paris"): |
| 61 | print(f"✅ LLM API connectivity check successful for {llm_name}. Output contains expected answer.") |
| 62 | return True |
| 63 | else: |
| 64 | print(f"❌ LLM API connectivity check failed for {llm_name}: Output does not contain expected answer 'Paris'. Please verify manually: {output!s}") |
| 65 | return False |
| 66 | except Exception as e: |
| 67 | print(f"❌ LLM API connectivity check failed for {llm_name}: {type(e).__name__}: {e!s}") |
| 68 | return False |
| 69 | |
| 70 | |
| 71 | # Function to check embedding API connectivity |
no test coverage detected