@@ -4,17 +4,32 @@ import modelsTemplate from "@/models";
44import cloneDeep from "lodash.clonedeep" ;
55
66const defaultAPIBase = [
7- "https://api.devchat.ai" ,
7+ "https://api.devchat.ai/v1 " ,
88 "https://api.devchat-ai.cn/v1" ,
99] ;
1010
1111export const ConfigStore = types
1212 . model ( "Config" , {
1313 config : types . optional ( types . frozen ( ) , { } ) ,
14+ modelsTemplate : types . optional ( types . frozen ( ) , { } ) ,
1415 settle : types . optional ( types . boolean , false ) ,
1516 defaultModel : types . optional ( types . string , "" ) ,
1617 } )
1718 . actions ( ( self ) => ( {
19+ setTemplate : ( value : any ) => {
20+ const models = value
21+ . filter ( ( item ) => item . category === "chat" )
22+ . map ( ( item ) => {
23+ return {
24+ name : item . model ,
25+ max_input_tokens : item . max_input_tokens ,
26+ provider : "devchat" ,
27+ stream : true ,
28+ } ;
29+ } ) ;
30+ console . log ( "models: " , models ) ;
31+ self . modelsTemplate = models ;
32+ } ,
1833 updateSettle : ( value : boolean ) => {
1934 self . settle = value ;
2035 } ,
@@ -36,6 +51,12 @@ export const ConfigStore = types
3651 } ,
3752 getAPIBase : ( ) => {
3853 if ( self . config ?. providers ?. devchat ?. api_base ) {
54+ if (
55+ self . config . providers . devchat . api_base === "custom" &&
56+ self . config . providers . devchat . cumstom_api_base
57+ ) {
58+ return self . config . providers . devchat . cumstom_api_base ;
59+ }
3960 return self . config . providers . devchat . api_base ;
4061 }
4162 if ( self . config ?. providers ?. openai ?. api_base ) {
@@ -49,7 +70,7 @@ export const ConfigStore = types
4970 if ( ! data . models ) {
5071 newConfig . models = { } ;
5172 }
52- modelsTemplate . forEach ( ( item ) => {
73+ self . modelsTemplate . forEach ( ( item ) => {
5374 const currentModel : any = {
5475 ...item ,
5576 } ;
@@ -96,7 +117,7 @@ export const ConfigStore = types
96117 self . defaultModel = newConfig . default_model ;
97118 } ,
98119 getModelList : ( ) => {
99- const modelsArray = modelsTemplate . map ( ( item ) => {
120+ const modelsArray = self . modelsTemplate . map ( ( item ) => {
100121 return item . name ;
101122 } ) ;
102123 return modelsArray ;
0 commit comments