1+ import json
12import os
23import uuid
3- import json
44from typing import Literal , Optional
55
6- from fastmcp import FastMCP
76from dingo .exec import Executor
87from dingo .io import InputArgs
98from dingo .utils import log
9+ from fastmcp import FastMCP
1010
1111# Dingo log level can be set via InputArgs('log_level') if needed
1212
@@ -23,7 +23,7 @@ def run_dingo_evaluation(
2323 task_name : Optional [str ] = None ,
2424 save_data : bool = True ,
2525 save_correct : bool = True ,
26- kwargs : dict = {}
26+ kwargs : dict = {}
2727) -> str :
2828 """Runs a Dingo evaluation (rule-based or LLM-based).
2929
@@ -41,14 +41,14 @@ def run_dingo_evaluation(
4141 save_data: Whether to save the detailed JSONL output (default: True).
4242 save_correct: Whether to save correct data (default: True).
4343 kwargs: Dictionary containing additional arguments compatible with dingo.io.InputArgs.
44- Use for: dataset, data_format, column_content, column_id,
44+ Use for: dataset, data_format, column_content, column_id,
4545 column_prompt, column_image, custom_config, max_workers, etc.
4646 API keys for LLMs should be set via environment variables in mcp.json.
4747
4848 Returns:
4949 The absolute path to the primary output file (summary.json or first .jsonl).
5050 """
51- log .info (f"Received Dingo request: type={ evaluation_type } , group={ eval_group_name } , input={ input_path } " )
51+ log .info (f"Received Dingo request: type={ evaluation_type } , group={ eval_group_name } , input={ input_path } " )
5252
5353 # --- Path Resolution ---
5454 abs_input_path = None
@@ -109,7 +109,7 @@ def run_dingo_evaluation(
109109 original_config = loaded_custom_config
110110 normalized_config = {}
111111 llm_eval_section = original_config .get ('llm_eval' , {})
112-
112+
113113 # Extract prompts
114114 prompts = []
115115 evaluations = llm_eval_section .get ('evaluations' , [])
@@ -123,7 +123,7 @@ def run_dingo_evaluation(
123123 log .info (f"Normalized prompt_list: { prompts } " )
124124 else :
125125 log .warning ("Could not extract prompt name(s) for normalization." )
126-
126+
127127 # Extract llm_config
128128 models_section = llm_eval_section .get ('models' , {})
129129 if models_section and isinstance (models_section , dict ):
@@ -138,7 +138,7 @@ def run_dingo_evaluation(
138138 log .info (f"Normalized llm_config for model '{ model_name } ': { model_details } " )
139139 else :
140140 log .warning ("Could not extract model details for normalization." )
141-
141+
142142 if 'prompt_list' in normalized_config and 'llm_config' in normalized_config :
143143 loaded_custom_config = normalized_config
144144 log .info ("Successfully normalized custom_config structure." )
@@ -160,9 +160,9 @@ def run_dingo_evaluation(
160160 raise ValueError ("Cannot determine default output directory without an input_path." )
161161 input_parent_dir = os .path .dirname (abs_input_path )
162162 abs_output_dir = os .path .join (input_parent_dir , f"dingo_output_{ task_name_for_path } " )
163- abs_output_dir = abs_output_dir .replace ("\\ " ,"/" )
163+ abs_output_dir = abs_output_dir .replace ("\\ " ,"/" )
164164 log .info (f"Using default output directory relative to input: { abs_output_dir } " )
165-
165+
166166 os .makedirs (abs_output_dir , exist_ok = True )
167167
168168 # --- Prepare Dingo InputArgs Data ---
@@ -229,18 +229,18 @@ def run_dingo_evaluation(
229229 log .error (f"Evaluation result missing valid 'output_path' attribute." )
230230 raise RuntimeError ("Dingo execution finished, but couldn't determine output path." )
231231
232- result_output_dir = result .output_path
232+ result_output_dir = result .output_path
233233 log .info (f"Dingo reported output directory: { result_output_dir } " )
234234
235235 if not os .path .isdir (result_output_dir ):
236236 log .error (f"Output directory from Dingo ({ result_output_dir } ) does not exist." )
237237 # Fallback: Return the parent dir used in InputArgs
238238 log .warning (f"Returning the base output directory used in InputArgs: { abs_output_dir } " )
239- return abs_output_dir
240-
239+ return abs_output_dir
240+
241241 # --- Find Primary Output File ---
242242 # Priority 1: summary.json
243- summary_path = os .path .join (result_output_dir , "summary.json" )
243+ summary_path = os .path .join (result_output_dir , "summary.json" )
244244 if os .path .isfile (summary_path ):
245245 summary_path_abs = os .path .abspath (summary_path ).replace ("\\ " , "/" )
246246 log .info (f"Found summary.json. Returning path: { summary_path_abs } " )
@@ -256,7 +256,7 @@ def run_dingo_evaluation(
256256 log .info (f"Found first .jsonl: { first_jsonl_path } . Returning this path." )
257257 break
258258 if first_jsonl_path : break
259-
259+
260260 if first_jsonl_path :
261261 return first_jsonl_path
262262 else :
@@ -271,4 +271,4 @@ def run_dingo_evaluation(
271271
272272
273273if __name__ == "__main__" :
274- mcp .run ()
274+ mcp .run ()
0 commit comments