Source code for chia.base.llm_call


from typing import List, Optional
from dataclasses import dataclass
from abc import ABC, abstractmethod
from chia.base.tools.ChiaTool import ChiaTool


[docs] @dataclass class QueryResult: """ Structured result from prompting an LLM or agent. :param result: The final response from the LLM or agent :param returncode: The returncode from running the prompt :param stderr: The stderr output from running the prompt (clis only) :param stream_result: The full transcript of all turns of the LLM or agent :param success: Whether the prompt completed successfully :type result: str :type returncode: int :type stderr: str :type stream_result: str :type success: bool """ result: str returncode: int stderr: str stream_result: str success: bool = False
[docs] class LLMCallBase(ABC): """ Polymorphic base container for generic LLM and agent configuration traits and behavior. Easy to switch between different backing providers, servers, and CLIs """ def __init__(self, system_message: str): self.system_message = system_message
[docs] @abstractmethod def prompt(self, user_message: str, tools: Optional[List[ChiaTool]] = []) -> QueryResult: """ Send a prompt to this LLM :param user_message: Message used to prompt the LLM :param tools: Tools available to the LLM during the call :type user_message: str :type tools: Optional[List[ChiaTool]] """ pass