-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cheap and expensive unittests work now
- Loading branch information
Showing
11 changed files
with
121 additions
and
154 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
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 |
---|---|---|
@@ -1,30 +1,29 @@ | ||
from ._base_model import BaseModel | ||
from ._openai_model import OpenAIModel | ||
from ._mistral_model import MistralModel | ||
from ._anthropic_model import AnthropicModel | ||
|
||
|
||
class DummyModel(BaseModel): | ||
def predict(self, messages): | ||
return 'dummy reply' | ||
|
||
|
||
def model(heymans, model, **kwargs): | ||
|
||
"""A factory function that returns a Model instance.""" | ||
if model == 'gpt-4': | ||
from ._openai_model import OpenAIModel | ||
return OpenAIModel(heymans, 'gpt-4-1106-preview', **kwargs) | ||
if model == 'gpt-3.5': | ||
from ._openai_model import OpenAIModel | ||
return OpenAIModel(heymans, 'gpt-3.5-turbo-1106', **kwargs) | ||
if model == 'claude-2.1': | ||
from ._anthropic_model import AnthropicModel | ||
return AnthropicModel(heymans, 'claude-2.1', **kwargs) | ||
if model == 'claude-3-opus': | ||
from ._anthropic_model import AnthropicModel | ||
return AnthropicModel(heymans, 'claude-3-opus-20240229', **kwargs) | ||
if model == 'claude-3-sonnet': | ||
from ._anthropic_model import AnthropicModel | ||
return AnthropicModel(heymans, 'claude-3-sonnet-20240229', **kwargs) | ||
if model.startswith('mistral-'): | ||
from ._mistral_model import MistralModel | ||
if not model.endswith('-latest'): | ||
model += '-latest' | ||
return MistralModel(heymans, model, **kwargs) | ||
if model == 'dummy': | ||
from ._dummy_model import DummyModel | ||
return DummyModel(heymans, **kwargs) | ||
raise ValueError(f'Unknown model: {model}') |
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
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,17 @@ | ||
from ._base_model import BaseModel | ||
|
||
|
||
class DummyModel(BaseModel): | ||
|
||
def get_response(self, response): | ||
return response | ||
|
||
def invoke(self, messages): | ||
return 'dummy reply' | ||
|
||
async def _async_task(self): | ||
return 'dummy reply' | ||
|
||
def async_invoke(self, messages): | ||
import asyncio | ||
return asyncio.create_task(self._async_task()) |
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
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
Oops, something went wrong.