Support today's OpenAI models

This commit is contained in:
Enrico Ros
2023-06-13 10:44:33 -07:00
parent ec983adb0b
commit 8d6e7a8cfd
3 changed files with 23 additions and 9 deletions
+10 -3
View File
@@ -38,6 +38,7 @@ export function OpenAISourceSetup(props: { sourceId: DModelSourceId }) {
const { isFetching, refetch, isError } = apiQuery.openai.listModels.useQuery({ oaiKey, oaiHost, oaiOrg, heliKey }, {
enabled: !hasModels && shallFetchSucceed,
onSuccess: models => {
console.log('OpenAI models', models);
const llms = source ? models.map(model => openAIModelToDLLM(model, source)) : [];
useModelsStore.getState().addLLMs(llms);
},
@@ -134,10 +135,10 @@ export function OpenAISourceSetup(props: { sourceId: DModelSourceId }) {
// this will help with adding metadata to the models
const knownBases = [
{
id: 'gpt-4-32k',
label: 'GPT-4-32',
id: 'gpt-4-32k-0613',
label: 'GPT-4-32k (0613)',
context: 32768,
description: 'Largest context window for big thinking',
description: 'Largest context window for big problems',
},
{
id: 'gpt-4',
@@ -145,6 +146,12 @@ const knownBases = [
context: 8192,
description: 'Insightful, big thinker, slower, pricey',
},
{
id: 'gpt-3.5-turbo-16k',
label: '3.5-Turbo-16k',
context: 16384,
description: 'Fair speed and smarts, large context',
},
{
id: 'gpt-3.5-turbo',
label: '3.5-Turbo',
+12 -5
View File
@@ -82,11 +82,18 @@ export const openAIRouter = createTRPCRouter({
// model that have '-0' in their name go at the end
// if (a.id.includes('-0') && !b.id.includes('-0')) return 1;
// if (!a.id.includes('-0') && b.id.includes('-0')) return -1;
const aCount = a.id.split('-').length;
const bCount = b.id.split('-').length;
if (aCount === bCount)
return b.id.localeCompare(a.id);
return aCount - bCount;
// sort by the first 5 chars of id, decreasing, then by the number of '-' in the name
const aId = a.id.slice(0, 5);
const bId = b.id.slice(0, 5);
if (aId === bId) {
const aCount = a.id.split('-').length;
const bCount = b.id.split('-').length;
if (aCount === bCount)
return a.id.localeCompare(b.id);
return aCount - bCount;
}
return bId.localeCompare(aId);
});
return llms;
+1 -1
View File
@@ -132,7 +132,7 @@ export const useModelsStore = create<ModelsStore>()(
const defaultChatSuffixPreference = ['gpt-4', 'gpt-4-32k', 'gpt-3.5-turbo'];
const defaultFastSuffixPreference = ['gpt-3.5-turbo'];
const defaultFastSuffixPreference = ['gpt-3.5-turbo-16k', 'gpt-3.5-turbo'];
function findLlmIdBySuffix(llms: DLLM[], suffixes: string[]): DLLMId | null {
if (!llms?.length) return null;