1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Object-Oriented Programming in Python

Connected

Exercise

Creating a ChatBot

Large language models, or LLM's are generative AI tools that can perform tasks such as text summarization and sentence completion with a simple call to an API. In this exercise, you'll design a ChatBot class that leverages a factory method to "hot-swap" LLM's in order to perform sentence completion. Below is the LLM "product" interface that has been created for you. Good luck!

class LLM(ABC):
  @abstractmethod
  def complete_sentence(self, prompt):
    pass

Instructions 1/3

undefined XP
    1
    2
    3
  • Complete implementing the LLM interface for the OpenAI and Anthropic concrete products by creating a complete_sentence() method that takes a prompt, and returns the completed sentence.