-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change to use dataclass for type safety
- Loading branch information
Showing
4 changed files
with
61 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,46 @@ | ||
from dataclasses import dataclass | ||
|
||
default_models = { | ||
"normal": "gpt-3.5-turbo", | ||
"expensive": "gpt-4-turbo-preview", | ||
"vision": "gpt-4-vision-preview", | ||
"embedding": "text-embedding-3-large" | ||
} | ||
|
||
@dataclass | ||
class DefaultModels: | ||
normal: str = "gpt-4o-mini" | ||
expensive: str = "gpt-4-turbo-preview" | ||
vision: str = "gpt-4o" | ||
embedding: str = "text-embedding-3-large" | ||
|
||
default_options = { | ||
"temperature": 0.2, | ||
"max_tokens": None, | ||
"frequency_penalty": None, | ||
"timeout": 600, | ||
"seed": None, | ||
} | ||
def __getitem__(self, item): | ||
return getattr(self, item) | ||
|
||
def __setitem__(self, key, value): | ||
setattr(self, key, value) | ||
|
||
class CacheOptions: | ||
def __init__(self): | ||
self.max_embedding_vecs = 1000 | ||
self.max_chat = 1000 | ||
def get_dict(self): | ||
return {k: v for k, v in self.__dict__.items() if v is not None} | ||
|
||
|
||
@dataclass | ||
class DefaultOptions: | ||
temperature: float = 0.2 | ||
max_tokens: int = None | ||
frequency_penalty: float = None | ||
timeout: int = 600 | ||
seed: int = None | ||
|
||
def __getitem__(self, item): | ||
return getattr(self, item) | ||
|
||
def __setitem__(self, key, value): | ||
setattr(self, key, value) | ||
|
||
def get_dict(self): | ||
return {k: v for k, v in self.__dict__.items() if v is not None} | ||
|
||
|
||
default_models = DefaultModels() | ||
|
||
default_options = DefaultOptions() | ||
|
||
from mllm.utils.parser import parse_options | ||
|
||
if __name__ == '__main__': | ||
print(default_options.get_dict()) |
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