kernelfoundry.algorithm.answer_processor

AnswerProcessor class for postprocessing LLM responses into Program objects.

Classes

AnswerProcessor(language, diff_format, ...)

Takes a response from an LLM and postprocess it (extract code, edit code, transform to program)

class kernelfoundry.algorithm.answer_processor.AnswerProcessor(language: str, diff_format: bool, postprocess_code: bool, postprocess_code_config)[source]

Takes a response from an LLM and postprocess it (extract code, edit code, transform to program)

__init__(language: str, diff_format: bool, postprocess_code: bool, postprocess_code_config)[source]

Initialize the answer processor for LLM responses.

Parameters:
  • language (str) – Programming language of the kernel.

  • diff_format (bool) – Whether to use diff format for code changes.

  • postprocess_code (bool) – Whether to apply code postprocessing (e.g. fix SYCL queue).

  • postprocess_code_config – Configuration for code postprocessing.

__call__(llm_response: str, iteration: int, parent: Program | None) Program[source]

Transforms an LLM output into a Program object

Parameters:
  • llm_response (str) – Raw output of the LLM

  • iteration (int) – Current iteration

  • parent (Program | None) – Program that was used as input to generate the current version

Returns:

new Program object storing code, parent id, etc

Return type:

Program