(repos: Repository[], getId: () => string)
| 7 | * Generate GitHub repository questions |
| 8 | */ |
| 9 | export function generateGithubQuestions(repos: Repository[], getId: () => string): Question[] { |
| 10 | const questions: Question[] = [] |
| 11 | |
| 12 | // Field retrieval: repository metadata |
| 13 | const repoFieldGenerators: Array<(repo: Repository, getId: () => string) => Question> = [ |
| 14 | (repo, getId) => new QuestionBuilder() |
| 15 | .id(getId()) |
| 16 | .prompt(`How many stars does ${repo.repo} have?`) |
| 17 | .groundTruth(String(repo.stars)) |
| 18 | .type('field-retrieval') |
| 19 | .dataset('github') |
| 20 | .answerType('integer') |
| 21 | .build(), |
| 22 | (repo, getId) => new QuestionBuilder() |
| 23 | .id(getId()) |
| 24 | .prompt(`How many forks does ${repo.repo} have?`) |
| 25 | .groundTruth(String(repo.forks)) |
| 26 | .type('field-retrieval') |
| 27 | .dataset('github') |
| 28 | .answerType('integer') |
| 29 | .build(), |
| 30 | (repo, getId) => new QuestionBuilder() |
| 31 | .id(getId()) |
| 32 | .prompt(`How many watchers does ${repo.repo} have?`) |
| 33 | .groundTruth(String(repo.watchers)) |
| 34 | .type('field-retrieval') |
| 35 | .dataset('github') |
| 36 | .answerType('integer') |
| 37 | .build(), |
| 38 | (repo, getId) => new QuestionBuilder() |
| 39 | .id(getId()) |
| 40 | .prompt(`What is the main branch of ${repo.repo}?`) |
| 41 | .groundTruth(repo.defaultBranch) |
| 42 | .type('field-retrieval') |
| 43 | .dataset('github') |
| 44 | .answerType('string') |
| 45 | .normalize({ caseSensitive: true }) |
| 46 | .build(), |
| 47 | ] |
| 48 | |
| 49 | questions.push(...rotateQuestions( |
| 50 | repos, |
| 51 | repoFieldGenerators, |
| 52 | QUESTION_LIMITS.github.fieldRetrievalRepos, |
| 53 | SAMPLE_STRIDES.REPO_FIELD, |
| 54 | getId, |
| 55 | )) |
| 56 | |
| 57 | // Aggregation: basic statistics |
| 58 | const totalRepos = repos.length |
| 59 | const totalStars = repos.reduce((sum, r) => sum + r.stars, 0) |
| 60 | const totalForks = repos.reduce((sum, r) => sum + r.forks, 0) |
| 61 | const avgStars = totalStars / totalRepos |
| 62 | |
| 63 | questions.push( |
| 64 | new QuestionBuilder() |
| 65 | .id(getId()) |
| 66 | .prompt('How many repositories are in the dataset?') |
no test coverage detected
searching dependent graphs…