mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 15:24:10 +08:00
refactor: benchmarks code style
This commit is contained in:
@@ -28,8 +28,20 @@ export const models: Record<string, LanguageModelV2> = {
|
|||||||
* Evaluate a single question with a specific format and model
|
* Evaluate a single question with a specific format and model
|
||||||
*/
|
*/
|
||||||
export async function evaluateQuestion(
|
export async function evaluateQuestion(
|
||||||
{ question, formatName, formattedData, model, modelName}:
|
{
|
||||||
{ question: Question, formatName: string, formattedData: string, model: LanguageModelV2, modelName: string },
|
question,
|
||||||
|
formatName,
|
||||||
|
formattedData,
|
||||||
|
model,
|
||||||
|
modelName,
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
question: Question
|
||||||
|
formatName: string
|
||||||
|
formattedData: string
|
||||||
|
model: LanguageModelV2
|
||||||
|
modelName: string
|
||||||
|
},
|
||||||
): Promise<EvaluationResult> {
|
): Promise<EvaluationResult> {
|
||||||
const prompt = `
|
const prompt = `
|
||||||
Given the following data in ${formatName} format:
|
Given the following data in ${formatName} format:
|
||||||
@@ -79,7 +91,11 @@ async function validateAnswer(
|
|||||||
expected,
|
expected,
|
||||||
question,
|
question,
|
||||||
}:
|
}:
|
||||||
{ actual: string, expected: string, question: string },
|
{
|
||||||
|
actual: string
|
||||||
|
expected: string
|
||||||
|
question: string
|
||||||
|
},
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const prompt = `
|
const prompt = `
|
||||||
You are validating answers to questions about structured data.
|
You are validating answers to questions about structured data.
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ function toCSV(data: unknown): string {
|
|||||||
* Convert data to XML format
|
* Convert data to XML format
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* Uses fast-xml-parser to generate well-formatted XML with:
|
* Uses `fast-xml-parser` to generate well-formatted XML with:
|
||||||
* - 2-space indentation for readability
|
* - 2-space indentation for readability
|
||||||
* - Empty nodes suppressed
|
* - Empty nodes suppressed
|
||||||
* - Proper escaping of special characters
|
* - Proper escaping of special characters
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ export function generateQuestions(): Question[] {
|
|||||||
let idCounter = 1
|
let idCounter = 1
|
||||||
|
|
||||||
// Get datasets with proper typing
|
// Get datasets with proper typing
|
||||||
const tabular = (datasets.find(d => d.name === 'tabular')?.data.employees as Employee[]) || []
|
const tabular = (datasets.find(d => d.name === 'tabular')?.data.employees as Employee[]) ?? []
|
||||||
const nested = (datasets.find(d => d.name === 'nested')?.data.orders as Order[]) || []
|
const nested = (datasets.find(d => d.name === 'nested')?.data.orders as Order[]) ?? []
|
||||||
const analytics = (datasets.find(d => d.name === 'analytics')?.data.metrics as AnalyticsMetric[]) || []
|
const analytics = (datasets.find(d => d.name === 'analytics')?.data.metrics as AnalyticsMetric[]) ?? []
|
||||||
const github = (datasets.find(d => d.name === 'github')?.data.repositories as Repository[]) || []
|
const github = (datasets.find(d => d.name === 'github')?.data.repositories as Repository[]) ?? []
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
// TABULAR DATASET QUESTIONS (70 questions)
|
// TABULAR DATASET QUESTIONS (70 questions)
|
||||||
|
|||||||
Reference in New Issue
Block a user