Table of Contents
Module spoon_ai.llm.base
LLMBase Objects​
class LLMBase(ABC)
Base abstract class for LLM, defining interfaces that all LLM providers must implement
__init__​
def __init__(config_path: str = "config/config.toml",
config_name: str = "llm")
Initialize LLM interface
Arguments:
config_path- Configuration file pathconfig_name- Configuration name
chat​
@abstractmethod
async def chat(messages: List[Message],
system_msgs: Optional[List[Message]] = None,
**kwargs) -> LLMResponse
Send chat request to LLM and get response
Arguments:
messages- List of messagessystem_msgs- List of system messages**kwargs- Other parameters
Returns:
LLMResponse- LLM response
completion​
@abstractmethod
async def completion(prompt: str, **kwargs) -> LLMResponse
Send text completion request to LLM and get response
Arguments:
prompt- Prompt text**kwargs- Other parameters
Returns:
LLMResponse- LLM response
chat_with_tools​
@abstractmethod
async def chat_with_tools(messages: List[Message],
system_msgs: Optional[List[Message]] = None,
tools: Optional[List[Dict]] = None,
tool_choice: Literal["none", "auto",
"required"] = "auto",
**kwargs) -> LLMResponse
Send chat request that may contain tool calls to LLM and get response
Arguments:
messages- List of messagessystem_msgs- List of system messagestools- List of toolstool_choice- Tool selection mode**kwargs- Other parameters
Returns:
LLMResponse- LLM response
generate_image​
async def generate_image(prompt: str, **kwargs) -> Union[str, List[str]]
Generate image (optional implementation)
Arguments:
prompt- Prompt text**kwargs- Other parameters
Returns:
Union[str, List[str]]: Image URL or list of URLs
reset_output_handler​
def reset_output_handler()
Reset output handler