()
| 236 | |
| 237 | @agent_bp.route('/test-model', methods=['GET', 'POST']) |
| 238 | def test_model(): |
| 239 | if not request.is_json: |
| 240 | raise AppError(ErrorCode.INVALID_REQUEST, "Invalid request format") |
| 241 | |
| 242 | logger.info("# test-model request") |
| 243 | content = request.get_json() |
| 244 | |
| 245 | logger.debug("content------------------------------") |
| 246 | logger.debug(content) |
| 247 | |
| 248 | client = get_client(content['model']) |
| 249 | |
| 250 | try: |
| 251 | response = client.get_completion( |
| 252 | messages=[ |
| 253 | {"role": "system", "content": "You are a helpful assistant."}, |
| 254 | {"role": "user", "content": "Respond 'I can hear you.' if you can hear me. Do not say anything other than 'I can hear you.'"}, |
| 255 | ] |
| 256 | ) |
| 257 | |
| 258 | logger.debug(f"model: {content['model']}") |
| 259 | logger.debug(f"welcome message: {response.choices[0].message.content}") |
| 260 | |
| 261 | if "I can hear you." in response.choices[0].message.content: |
| 262 | return json_ok({"model": content['model'], "message": ""}) |
| 263 | else: |
| 264 | raise AppError(ErrorCode.AGENT_ERROR, "Model responded but did not pass connectivity check") |
| 265 | except AppError: |
| 266 | raise |
| 267 | except Exception as e: |
| 268 | logger.exception(f"Error testing model {content['model'].get('id', '')}") |
| 269 | raise classify_and_wrap_llm_error(e) from e |
| 270 | |
| 271 | @agent_bp.route('/process-data-on-load', methods=['GET', 'POST']) |
| 272 | def process_data_on_load_request(): |
nothing calls this directly
no test coverage detected