MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / main

Function main

AskAgent/python/testing/check_connectivity.py:129–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

127
128
129async def main():
130 # Create and run all checks simultaneously
131 tasks = []
132
133 # Parse command line arguments
134 parser = argparse.ArgumentParser(description="Check connectivity for all services required by NLWeb")
135 parser.add_argument("--all", action='store_true', default=False,
136 help="Run all connectivity checks for every known provider",)
137 args = parser.parse_args()
138
139 start_time = time.time()
140
141 if args.all:
142 """Run all connectivity checks"""
143 print("Running NLWeb connectivity checks for all known providers...")
144 print("This may take a while, please be patient...")
145 for llm_provider in CONFIG.llm_endpoints:
146 tasks.append(check_llm_api(llm_provider))
147
148 for embedding_provider in CONFIG.embedding_providers:
149 tasks.append(check_embedding_api(embedding_provider))
150
151 for retrieval_provider in CONFIG.retrieval_endpoints:
152 tasks.append(check_retriever(retrieval_provider))
153
154 else:
155 """Run connectivity checks for preferred providers only"""
156 print("Checking NLWeb configuration and connectivity...")
157
158 # Retrieve preferred provider from config
159 model_config = CONFIG.preferred_llm_endpoint
160 print(f"Using configuration from preferred LLM provider: {model_config}")
161 tasks.append(check_llm_api(model_config))
162
163 embedding_config = CONFIG.preferred_embedding_provider
164 print(f"Using configuration from preferred embedding provider: {embedding_config}")
165 tasks.append(check_embedding_api(embedding_config))
166
167 # NOTE: I can't use a retrieval client.enabled_endpoints here, because it does validation and will just remove any invalid endpoints.
168 # The purpose of this method is to surface these invalid endpoints to the user.
169 for retrieval_endpoint in CONFIG.retrieval_endpoints:
170 if CONFIG.retrieval_endpoints[retrieval_endpoint].enabled:
171 print(f"Using configuration from enabled retrieval endpoint: {retrieval_endpoint}")
172 tasks.append(check_retriever(retrieval_endpoint))
173
174 # Run all tasks concurrently
175 results = await asyncio.gather(*tasks, return_exceptions=True)
176
177 # Count successful connections
178 successful = sum(1 for r in results if r is True)
179 total = len(tasks)
180
181 print("\n====== SUMMARY ======")
182 print(f"✅ {successful}/{total} connections successful")
183
184 if successful < total:
185 print("❌ Some connections failed. Please check error messages above.")
186 else:

Callers 1

Calls 3

check_llm_apiFunction · 0.70
check_embedding_apiFunction · 0.70
check_retrieverFunction · 0.70

Tested by

no test coverage detected