@@ -4,6 +4,8 @@ import { getVersion } from '@tauri-apps/api/app'
44import { AiConfig } from '@/app/core/setting/config'
55import { GitlabInstanceType } from '@/lib/gitlab.types'
66import { noteGenDefaultModels , noteGenModelKeys } from '@/app/model-config'
7+ import { fetch } from '@tauri-apps/plugin-http'
8+ import { v4 as uuid } from 'uuid' ;
79
810export enum GenTemplateRange {
911 All = 'all' ,
@@ -210,6 +212,38 @@ const useSettingStore = create<SettingState>((set, get) => ({
210212 set ( { imageMethodModel : 'note-gen-vlm' } )
211213 }
212214
215+ // 获取 NoteGen 限时免费模型
216+ const apiKey = noteGenDefaultModels [ 0 ] . apiKey
217+ const headers = {
218+ 'Content-Type' : 'application/json' ,
219+ 'Authorization' : `Bearer ${ apiKey } `
220+ }
221+ const res = await fetch ( 'http://api.notegen.top/v1/models' , {
222+ method : 'GET' ,
223+ headers
224+ } )
225+
226+ const resModels = await res . json ( )
227+
228+ if ( resModels . data && resModels . data . length > 0 ) {
229+ finalAiModelList = finalAiModelList . filter ( model => model . title !== 'NoteGen Limited' )
230+ const limitFreeModels = resModels . data . filter ( ( model : any ) => {
231+ return noteGenDefaultModels . every ( item => item . model !== model . id )
232+ } ) . map ( ( model : any ) => ( {
233+ apiKey,
234+ baseURL : "http://api.notegen.top/v1" ,
235+ "key" : uuid ( ) ,
236+ "model" : model . id ,
237+ "modelType" : "chat" ,
238+ "temperature" : 0.7 ,
239+ "title" : "NoteGen Limited" ,
240+ "topP" : 1
241+ } ) )
242+ finalAiModelList . unshift ( ...limitFreeModels )
243+ await store . set ( 'aiModelList' , finalAiModelList )
244+ set ( { aiModelList : finalAiModelList } )
245+ }
246+
213247 Object . entries ( get ( ) ) . forEach ( async ( [ key , value ] ) => {
214248 const res = await store . get ( key )
215249
0 commit comments