MCPcopy Create free account
hub / github.com/microsoft/data-formulator / test_model

Function test_model

py-src/data_formulator/routes/agents.py:238–269  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

236
237@agent_bp.route('/test-model', methods=['GET', 'POST'])
238def 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'])
272def process_data_on_load_request():

Callers

nothing calls this directly

Calls 6

AppErrorClass · 0.90
json_okFunction · 0.90
get_clientFunction · 0.85
get_completionMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected