mirror of
https://github.com/onyx-dot-app/onyx.git
synced 2026-10-22 03:14:06 -05:00
28 lines
765 B
Python
28 lines
765 B
Python
import abc
|
|
from collections.abc import Iterator
|
|
|
|
from langchain.schema.language_model import LanguageModelInput
|
|
|
|
from danswer.utils.logger import setup_logger
|
|
|
|
|
|
logger = setup_logger()
|
|
|
|
|
|
class LLM(abc.ABC):
|
|
"""Mimics the LangChain LLM / BaseChatModel interfaces to make it easy
|
|
to use these implementations to connect to a variety of LLM providers."""
|
|
|
|
@property
|
|
def requires_warm_up(self) -> bool:
|
|
"""Is this model running in memory and needs an initial call to warm it up?"""
|
|
return False
|
|
|
|
@abc.abstractmethod
|
|
def invoke(self, prompt: LanguageModelInput) -> str:
|
|
raise NotImplementedError
|
|
|
|
@abc.abstractmethod
|
|
def stream(self, prompt: LanguageModelInput) -> Iterator[str]:
|
|
raise NotImplementedError
|