llm_interface

Interface for the LLM model.

Classes

LLMInterface

Initializes the LLM interface.

Module Contents

class llm_interface.LLMInterface(default_response: str = None)

Bases: abc.ABC

Initializes the LLM interface.

Parameters:

default_response – Default response to be used if the LLM fails to generate a response.

abstract generate_utterance(prompt: usersimcrs.simulator.llm.prompt.utterance_generation_prompt.UtteranceGenerationPrompt) dialoguekit.core.Utterance

Generates an utterance given a prompt.

Parameters:

prompt – Prompt for generating the utterance.

Raises:

NotImplementedError – If the method is not implemented in subclass.

Returns:

Utterance in natural language.

abstract get_llm_api_response(prompt: str, **kwargs) str

Gets the raw response from the LLM API.

This method should be used to interact directly with the LLM API, i.e., for everything that is not related to the generation of an utterance.

Parameters:
  • prompt – Prompt for the LLM.

  • **kwargs – Additional arguments to be passed to the API call.

Raises:

NotImplementedError – If the method is not implemented in subclass.

Returns:

Response from the LLM API without any post-processing.