-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update LLM interface organization
- Loading branch information
Showing
3 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"""Define public interface for llm wrapping package.""" | ||
from .openai import OpenAIChatCompletion, OpenAICompletion | ||
from .typedefs import ChatCompletionModel, CompletionModel | ||
|
||
__all__ = [ | ||
"OpenAIChatCompletion", | ||
"OpenAICompletion", | ||
"CompletionModel", | ||
"ChatCompletionModel", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Provide standard interface on tops of LLMs.""" | ||
import abc | ||
import dataclasses | ||
|
||
|
||
@dataclasses.dataclass(kw_only=True) | ||
class CompletionModel(abc.ABC): | ||
"""Abstract completion model interface.""" | ||
|
||
def __call__(self, prompt: str) -> str: | ||
"""Call the model.""" | ||
raise NotImplementedError() | ||
|
||
|
||
@dataclasses.dataclass(kw_only=True) | ||
class ChatCompletionModel(abc.ABC): | ||
"""Abstract chat completion model interface.""" | ||
|
||
def __call__(self, messages: list[dict[str, str]]) -> str: | ||
"""Call the model.""" | ||
raise NotImplementedError() |