r"""Generate tasks from role files. Args: languages_path (str, optional): The path to the file containing the language names. (default: :obj:`"data/code/languages.txt"`) domains_path (str, optional): The path to the file containing the
(
self,
languages_path: str = "data/code/languages.txt",
domains_path: str = "data/code/domains.txt",
)
| 328 | self.num_tasks = num_tasks |
| 329 | |
| 330 | def from_role_files( |
| 331 | self, |
| 332 | languages_path: str = "data/code/languages.txt", |
| 333 | domains_path: str = "data/code/domains.txt", |
| 334 | ) -> Generator[Tuple[TextPrompt, str, str], None, None]: |
| 335 | r"""Generate tasks from role files. |
| 336 | |
| 337 | Args: |
| 338 | languages_path (str, optional): The path to the file containing |
| 339 | the language names. (default: :obj:`"data/code/languages.txt"`) |
| 340 | domains_path (str, optional): The path to the file containing |
| 341 | the domain names. (default: :obj:`"data/code/domains.txt"`) |
| 342 | |
| 343 | Returns: |
| 344 | Generator[Tuple[TextPrompt, str, str], None, None]: A generator |
| 345 | that yields tuples of task prompts, language names, and domain |
| 346 | names. |
| 347 | """ |
| 348 | language_generator = SingleTxtGenerator( |
| 349 | languages_path |
| 350 | ).from_role_files() |
| 351 | |
| 352 | for language in language_generator: |
| 353 | domains_generator = SingleTxtGenerator( |
| 354 | domains_path |
| 355 | ).from_role_files() |
| 356 | for domain in domains_generator: |
| 357 | generated_tasks_prompt = self.generate_tasks_prompt.format( |
| 358 | language=language, domain=domain, num_tasks=self.num_tasks |
| 359 | ) |
| 360 | yield generated_tasks_prompt, language, domain |
| 361 | |
| 362 | def from_role_generator( |
| 363 | self, role_generator: Generator[Tuple, None, None] |
nothing calls this directly
no test coverage detected