Skip to content

source_code_bot

dandy.cli.intelligence.bots.source_code_bot

SourceCodeBot

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 = 'Senior Developer' class-attribute instance-attribute

task = 'Read the instructions and write the source code for the user.' class-attribute instance-attribute

guidelines = Prompt().list(["You're only creating one file so focus on completeness.", 'The file name should not contain a path and must include the extensions']) class-attribute instance-attribute

intel_class = SourceCodeIntel class-attribute instance-attribute

process

Source code in dandy/cli/intelligence/bots/source_code_bot.py
@recorder_to_html_file('source_code_bot')
def process(self, user_input: str, code_reference_prompt: Prompt) -> SourceCodeIntel:
    self.llm.messages.add_message(
        role='user',
        text=(
            Prompt()
            .text(
                'Below is the code I want you to reference while writing the source code for my next request.'
            )
            .prompt(code_reference_prompt)
            .to_str()
        ),
    )

    self.llm.messages.add_message(
        role='system',
        text='I have read through the provided code and will use it as a reference.',
    )

    return self.llm.prompt_to_intel(prompt=user_input)