@@ -19,13 +19,15 @@ export const Models = {
1919 chatgptApi4_32k : { value : 'gpt-4-32k' , desc : 'ChatGPT (GPT-4-32k)' } ,
2020 gptApiDavinci : { value : 'text-davinci-003' , desc : 'GPT-3.5' } ,
2121 customModel : { value : '' , desc : 'Custom Model' } ,
22+ azureOpenAi : { value : '' , desc : 'ChatGPT (Azure)' } ,
2223}
2324
2425export const chatgptWebModelKeys = [ 'chatgptFree35' , 'chatgptPlus4' ]
2526export const bingWebModelKeys = [ 'bingFree4' ]
2627export const gptApiModelKeys = [ 'gptApiDavinci' ]
2728export const chatgptApiModelKeys = [ 'chatgptApi35' , 'chatgptApi4_8k' , 'chatgptApi4_32k' ]
2829export const customApiModelKeys = [ 'customModel' ]
30+ export const azureOpenAiApiModelKeys = [ 'azureOpenAi' ]
2931
3032export const TriggerMode = {
3133 always : 'Always' ,
@@ -60,13 +62,21 @@ export const defaultConfig = {
6062 themeMode : 'auto' ,
6163 /** @type {keyof Models }*/
6264 modelName : 'chatgptFree35' ,
63- apiKey : '' ,
64- /** @type {keyof ModelMode }*/
65- modelMode : 'balanced' ,
65+
6666 preferredLanguage : getNavigatorLanguage ( ) ,
6767 insertAtTop : isMobile ( ) ,
6868 lockWhenAnswer : false ,
6969 autoRegenAfterSwitchModel : false ,
70+
71+ apiKey : '' , // openai ApiKey
72+
73+ azureApiKey : '' ,
74+ azureEndpoint : '' ,
75+ azureDeploymentName : '' ,
76+
77+ /** @type {keyof ModelMode }*/
78+ modelMode : 'balanced' ,
79+
7080 customModelApiUrl : 'http://localhost:8000/chat/completions' ,
7181 customModelName : 'llama-7b-int4' ,
7282
@@ -154,6 +164,10 @@ export function isUsingCustomModel(configOrSession) {
154164 return customApiModelKeys . includes ( configOrSession . modelName )
155165}
156166
167+ export function isUsingAzureOpenAi ( configOrSession ) {
168+ return azureOpenAiApiModelKeys . includes ( configOrSession . modelName )
169+ }
170+
157171export async function getPreferredLanguageKey ( ) {
158172 const config = await getUserConfig ( )
159173 if ( config . preferredLanguage === 'auto' ) return config . userLanguage
@@ -166,12 +180,6 @@ export async function getPreferredLanguageKey() {
166180 */
167181export async function getUserConfig ( ) {
168182 const options = await Browser . storage . local . get ( Object . keys ( defaultConfig ) )
169-
170- // version compatibility
171- if ( options . modelName === 'chatgptFree' ) options . modelName = 'chatgptFree35'
172- else if ( options . modelName === 'chatgptApi' ) options . modelName = 'chatgptApi35'
173- else if ( options . modelName === 'gptDavinci' ) options . modelName = 'gptApiDavinci'
174-
175183 return defaults ( options , defaultConfig )
176184}
177185
0 commit comments