Skip to content

code_explainer_bot

dandy.cli.actions.explain.intelligence.bots.code_explainer_bot

CodeExplainerBot

Bases: Bot

Source code in dandy/bot/bot.py
def __init__(
    self,
    llm_config: str | None = None,
    llm_temperature: float | None = None,
    **kwargs,
) -> None:
    super().__init__(
        llm_config=llm_config,
        llm_temperature=llm_temperature,
        **kwargs,
    )

    self.recorder_event_id = ''
    self._recorder_called = None

    for key, value in kwargs.items():
        setattr(self, key, value)

    self.__post_init__()

role = 'Code Explainer' class-attribute instance-attribute

task = 'Explain how the code in the provided files works in reflection to the users request.' class-attribute instance-attribute

guidelines = Prompt().list(['Explain code in the order that a developer would need to learn it.', 'Then proceed to explain what would be most relevant to the user after the base explanation.', 'Use the code provided to then show an example']) class-attribute instance-attribute

process

Source code in dandy/cli/actions/explain/intelligence/bots/code_explainer_bot.py
def process(self, user_input: Prompt | str, file_paths: Sequence[Path | str]):
    prompt = Prompt()
    prompt.heading('User Request')
    prompt.text(user_input)
    prompt.line_break()

    prompt.heading('Files')
    for file_path in file_paths:
        prompt.file(
            file_path,
            triple_backtick=True,
            triple_backtick_label=str(file_path)
        )
        prompt.line_break()

    return self.llm.prompt_to_intel(prompt=prompt)