def export_results()

in genai-on-vertex-ai/gemini/model_upgrades/document_qna/vertex_script/eval.py [0:0]


def export_results(baseline_model: str, baseline_results: EvalResult, candidate_model: str, candidate_results: EvalResult, file_name: str):
    '''Export combined results of the two eval runs to a single JSON file that can be visualized in LLM Comparator.'''
    with open(file_name, 'w') as f:
        f.write(json.dumps(dict(
            models=[dict(name=baseline_model), dict(name=candidate_model)],
            examples=combine_eval_runs(baseline_results, candidate_results),
            metadata={'custom_fields_schema':[]}
        )))
    print(f"Evaluation results saved to {file_name} in LLM Comparator format: https://pair-code.github.io/llm-comparator/")