MCPcopy
hub / github.com/toon-format/toon / generateTabularQuestions

Function generateTabularQuestions

benchmarks/src/questions/tabular.ts:9–201  ·  view source on GitHub ↗
(employees: Employee[], getId: () => string)

Source from the content-addressed store, hash-verified

7 * Generate tabular (employee) questions
8 */
9export function generateTabularQuestions(employees: Employee[], getId: () => string): Question[] {
10 const questions: Question[] = []
11
12 // Field retrieval: specific employees
13 const fieldGenerators: Array<(emp: Employee, getId: () => string) => Question> = [
14 (emp, getId) => new QuestionBuilder()
15 .id(getId())
16 .prompt(`What is the salary of ${emp.name}?`)
17 .groundTruth(String(emp.salary))
18 .type('field-retrieval')
19 .dataset('tabular')
20 .answerType('integer')
21 .build(),
22 (emp, getId) => new QuestionBuilder()
23 .id(getId())
24 .prompt(`What department does ${emp.name} work in?`)
25 .groundTruth(emp.department)
26 .type('field-retrieval')
27 .dataset('tabular')
28 .answerType('string')
29 .build(),
30 (emp, getId) => new QuestionBuilder()
31 .id(getId())
32 .prompt(`What is the email address of ${emp.name}?`)
33 .groundTruth(emp.email)
34 .type('field-retrieval')
35 .dataset('tabular')
36 .answerType('string')
37 .build(),
38 (emp, getId) => new QuestionBuilder()
39 .id(getId())
40 .prompt(`How many years of experience does ${emp.name} have?`)
41 .groundTruth(String(emp.yearsExperience))
42 .type('field-retrieval')
43 .dataset('tabular')
44 .answerType('integer')
45 .build(),
46 (emp, getId) => new QuestionBuilder()
47 .id(getId())
48 .prompt(`Is ${emp.name} an active employee?`)
49 .groundTruth(emp.active ? 'yes' : 'no')
50 .type('field-retrieval')
51 .dataset('tabular')
52 .answerType('boolean')
53 .build(),
54 ]
55
56 questions.push(...rotateQuestions(
57 employees,
58 fieldGenerators,
59 QUESTION_LIMITS.tabular.fieldRetrieval,
60 SAMPLE_STRIDES.EMPLOYEE_FIELD,
61 getId,
62 ))
63
64 // Aggregation: count by department
65 const departments = [...new Set(employees.map(e => e.department))]
66 for (const dept of departments.slice(0, QUESTION_LIMITS.tabular.aggregationDepartments)) {

Callers 1

generateQuestionsFunction · 0.90

Calls 9

rotateQuestionsFunction · 0.90
getIdFunction · 0.85
buildMethod · 0.80
answerTypeMethod · 0.80
datasetMethod · 0.80
typeMethod · 0.80
groundTruthMethod · 0.80
promptMethod · 0.80
idMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…