Merge pull request #245 from Webifi/main
Fix disabled OpenAI models #243
This commit is contained in:
		
						commit
						36839e3f99
					
				| 
						 | 
					@ -274,6 +274,11 @@ export async function getModelOptions (): Promise<SelectOption[]> {
 | 
				
			||||||
  //       }
 | 
					  //       }
 | 
				
			||||||
  // })
 | 
					  // })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const openAiModelsLookup = openAiModels.data.reduce((a, v) => {
 | 
				
			||||||
 | 
					        a[v.id] = v
 | 
				
			||||||
 | 
					        return a
 | 
				
			||||||
 | 
					  }, {})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const modelOptions:SelectOption[] = Object.keys(supportedModels).reduce((a, m) => {
 | 
					  const modelOptions:SelectOption[] = Object.keys(supportedModels).reduce((a, m) => {
 | 
				
			||||||
        let disabled
 | 
					        let disabled
 | 
				
			||||||
        const modelDetail = getModelDetail(m)
 | 
					        const modelDetail = getModelDetail(m)
 | 
				
			||||||
| 
						 | 
					@ -283,7 +288,7 @@ export async function getModelOptions (): Promise<SelectOption[]> {
 | 
				
			||||||
            break
 | 
					            break
 | 
				
			||||||
          case 'OpenAIChat':
 | 
					          case 'OpenAIChat':
 | 
				
			||||||
          default:
 | 
					          default:
 | 
				
			||||||
            disabled = !(openAiModels.data && openAiModels.data.find((m) => m.id === m))
 | 
					            disabled = !(openAiModelsLookup[m])
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const o:SelectOption = {
 | 
					        const o:SelectOption = {
 | 
				
			||||||
          value: m,
 | 
					          value: m,
 | 
				
			||||||
| 
						 | 
					@ -296,6 +301,8 @@ export async function getModelOptions (): Promise<SelectOption[]> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (allowCache) modelOptionCache.set(modelOptions)
 | 
					  if (allowCache) modelOptionCache.set(modelOptions)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // console.log('openAiModels', openAiModels, openAiModelsLookup)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return modelOptions
 | 
					  return modelOptions
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue