Spaces:
Running
Running
File size: 7,881 Bytes
e91ac58 806953a e91ac58 806953a e91ac58 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
class ModelMaps:
PROMPTS_THAT_NEED_DOMAIN_KNOWLEDGE = ["Version 1", "Version 1 PaLM 2"]
COLORS_EXPENSE_REPORT = {
'GPT_4': '#32CD32', # Lime Green
'GPT_3_5': '#008000', # Green
'GPT_3_5_INSTRUCT': '#3CB371', # Medium Sea Green
'GPT_4_TURBO': '#228B22', # Forest Green
'GPT_4_32K': '#006400', # Dark Green
'PALM2_TB_1': '#87CEEB', # Sky Blue
'PALM2_TB_2': '#1E90FF', # Dodger Blue
'PALM2_TU_1': '#0000FF', # Blue
'GEMINI_PRO': '#1E00FF', #
'AZURE_GPT_4': '#800080', # Purple
'AZURE_GPT_4_TURBO': '#9370DB', # Medium Purple
'AZURE_GPT_4_32K': '#8A2BE2', # Blue Violet
'AZURE_GPT_3_5_INSTRUCT': '#9400D3', # Dark Violet
'AZURE_GPT_3_5': '#9932CC', # Dark Orchid
'MISTRAL_TINY': '#FFA07A', # Light Salmon
'MISTRAL_SMALL': '#FF8C00', # Dark Orange
'MISTRAL_MEDIUM': '#FF4500', # Orange Red
'LOCAL_MIXTRAL_8X7B_INSTRUCT_V01': '#000000', # Black
'LOCAL_MISTRAL_7B_INSTRUCT_V02': '#4a4a4a', # Gray
'LOCAL_CPU_MISTRAL_7B_INSTRUCT_V02_GGUF': '#bababa', # Gray
}
MODELS_OPENAI = ["GPT 4",
"GPT 4 32k",
"GPT 4 Turbo 1106-preview",
"GPT 3.5",
"GPT 3.5 Instruct",
"Azure GPT 4",
"Azure GPT 4 32k",
"Azure GPT 4 Turbo 1106-preview",
"Azure GPT 3.5",
"Azure GPT 3.5 Instruct",]
MODELS_GOOGLE = ["PaLM 2 text-bison@001",
"PaLM 2 text-bison@002",
"PaLM 2 text-unicorn@001",
"Gemini Pro"]
MODELS_MISTRAL = ["Mistral Tiny",
"Mistral Small",
"Mistral Medium",]
MODELS_LOCAL = ["LOCAL Mixtral 8x7B Instruct v0.1",
"LOCAL Mistral 7B Instruct v0.2",
"LOCAL CPU Mistral 7B Instruct v0.2 GGUF",]
MODELS_GUI_DEFAULT = "Azure GPT 3.5 Instruct" # "GPT 4 Turbo 1106-preview"
version_mapping_cost = {
'GPT 4 32k': 'GPT_4_32K',
'GPT 4': 'GPT_4',
'GPT 4 Turbo 1106-preview': 'GPT_4_TURBO',
'GPT 3.5 Instruct': 'GPT_3_5_INSTRUCT',
'GPT 3.5': 'GPT_3_5',
'Azure GPT 4 32k': 'AZURE_GPT_4_32K',
'Azure GPT 4': 'AZURE_GPT_4',
'Azure GPT 4 Turbo 1106-preview': 'AZURE_GPT_4_TURBO',
'Azure GPT 3.5 Instruct': 'AZURE_GPT_3_5_INSTRUCT',
'Azure GPT 3.5': 'AZURE_GPT_3_5',
'Gemini Pro': 'GEMINI_PRO',
'PaLM 2 text-unicorn@001': 'PALM2_TU_1',
'PaLM 2 text-bison@001': 'PALM2_TB_1',
'PaLM 2 text-bison@002': 'PALM2_TB_2',
'Mistral Medium': 'MISTRAL_MEDIUM',
'Mistral Small': 'MISTRAL_SMALL',
'Mistral Tiny': 'MISTRAL_TINY',
'LOCAL Mixtral 8x7B Instruct v0.1': 'LOCAL_MIXTRAL_8X7B_INSTRUCT_V01',
'LOCAL Mistral 7B Instruct v0.2': 'LOCAL_MISTRAL_7B_INSTRUCT_V02',
'LOCAL CPU Mistral 7B Instruct v0.2 GGUF': 'LOCAL_CPU_MISTRAL_7B_INSTRUCT_V02_GGUF',
}
@classmethod
def get_version_has_key(cls, key, has_key_openai, has_key_azure_openai, has_key_google_application_credentials, has_key_mistral):
# Define the mapping for 'has_key' values
version_has_key = {
'GPT 4 Turbo 1106-preview': has_key_openai,
'GPT 4': has_key_openai,
'GPT 4 32k': has_key_openai,
'GPT 3.5': has_key_openai,
'GPT 3.5 Instruct': has_key_openai,
'Azure GPT 3.5': has_key_azure_openai,
'Azure GPT 3.5 Instruct': has_key_azure_openai,
'Azure GPT 4': has_key_azure_openai,
'Azure GPT 4 Turbo 1106-preview': has_key_azure_openai,
'Azure GPT 4 32k': has_key_azure_openai,
'PaLM 2 text-bison@001': has_key_google_application_credentials,
'PaLM 2 text-bison@002': has_key_google_application_credentials,
'PaLM 2 text-unicorn@001': has_key_google_application_credentials,
'Gemini Pro': has_key_google_application_credentials,
'Mistral Tiny': has_key_mistral,
'Mistral Small': has_key_mistral,
'Mistral Medium': has_key_mistral,
'LOCAL Mixtral 8x7B Instruct v0.1': True,
'LOCAL Mistral 7B Instruct v0.2': True,
'LOCAL CPU Mistral 7B Instruct v0.2 GGUF': True,
}
return version_has_key.get(key)
@classmethod
def get_version_mapping_is_azure(cls, key):
version_mapping_is_azure = {
"GPT 4 Turbo 1106-preview": False,
'GPT 4': False,
'GPT 4 32k': False,
'GPT 3.5': False,
'GPT 3.5 Instruct': False,
'Azure GPT 3.5': True,
'Azure GPT 3.5 Instruct': True,
'Azure GPT 4': True,
'Azure GPT 4 Turbo 1106-preview': True,
'Azure GPT 4 32k': True,
'PaLM 2 text-bison@001': False,
'PaLM 2 text-bison@002': False,
'PaLM 2 text-unicorn@001': False,
'Gemini Pro': False,
'Mistral Tiny': False,
'Mistral Small': False,
'Mistral Medium': False,
'LOCAL Mixtral 8x7B Instruct v0.1': False,
'LOCAL Mistral 7B Instruct v0.2': False,
'LOCAL CPU Mistral 7B Instruct v0.2 GGUF': False,
}
return version_mapping_is_azure.get(key)
@classmethod
def get_API_name(cls, key):
### OpenAI
if key == 'GPT_3_5':
return 'gpt-3.5-turbo-1106'
elif key == 'GPT_3_5_INSTRUCT':
return 'gpt-3.5-turbo-instruct'
elif key == 'GPT_4':
return 'gpt-4'
elif key == 'GPT_4_32K':
return 'gpt-4-32k'
elif key == 'GPT_4_TURBO':
return 'gpt-4-1106-preview'
### Azure
elif key == 'AZURE_GPT_3_5':
return 'gpt-35-turbo-1106'
elif key == 'AZURE_GPT_3_5_INSTRUCT':
return 'gpt-35-turbo-instruct'
elif key == 'AZURE_GPT_4':
return "gpt-4"
elif key == 'AZURE_GPT_4_TURBO':
return "gpt-4-1106-preview"
elif key == 'AZURE_GPT_4_32K':
return "gpt-4-32k"
### Google
elif key == 'PALM2_TB_1':
return "text-bison@001"
elif key == 'PALM2_TB_2':
return "text-bison@002"
elif key == 'PALM2_TU_1':
return "text-unicorn@001"
elif key == 'GEMINI_PRO':
return "gemini-pro"
### Mistral
elif key == 'MISTRAL_TINY':
return "mistral-tiny"
elif key == 'MISTRAL_SMALL':
return 'mistral-small'
elif key == 'MISTRAL_MEDIUM':
return 'mistral-medium'
### Mistral LOCAL
elif key == 'LOCAL_MIXTRAL_8X7B_INSTRUCT_V01':
return 'Mixtral-8x7B-Instruct-v0.1'
elif key == 'LOCAL_MISTRAL_7B_INSTRUCT_V02':
return 'Mistral-7B-Instruct-v0.2'
### Mistral LOCAL CPU
elif key == 'LOCAL_CPU_MISTRAL_7B_INSTRUCT_V02_GGUF':
return 'Mistral-7B-Instruct-v0.2-GGUF'
else:
raise ValueError(f"Invalid model name {key}. See model_maps.py")
@classmethod
def get_models_gui_list(cls):
return cls.MODELS_LOCAL + cls.MODELS_GOOGLE + cls.MODELS_OPENAI + cls.MODELS_MISTRAL
@classmethod
def get_version_mapping_cost(cls, key):
return cls.version_mapping_cost.get(key, None)
@classmethod
def get_all_mapping_cost(cls):
return cls.version_mapping_cost |