feat: max token option for litellm models

This commit is contained in:
Timothy J. Baek 2024-03-08 13:41:38 -08:00
parent 2b84af878a
commit 9a83bde7e5
2 changed files with 22 additions and 2 deletions

View File

@ -77,6 +77,7 @@ type AddLiteLLMModelForm = {
api_base: string; api_base: string;
api_key: string; api_key: string;
rpm: string; rpm: string;
max_tokens: string;
}; };
export const addLiteLLMModel = async (token: string = '', payload: AddLiteLLMModelForm) => { export const addLiteLLMModel = async (token: string = '', payload: AddLiteLLMModelForm) => {
@ -95,7 +96,8 @@ export const addLiteLLMModel = async (token: string = '', payload: AddLiteLLMMod
model: payload.model, model: payload.model,
...(payload.api_base === '' ? {} : { api_base: payload.api_base }), ...(payload.api_base === '' ? {} : { api_base: payload.api_base }),
...(payload.api_key === '' ? {} : { api_key: payload.api_key }), ...(payload.api_key === '' ? {} : { api_key: payload.api_key }),
...(isNaN(parseInt(payload.rpm)) ? {} : { rpm: parseInt(payload.rpm) }) ...(isNaN(parseInt(payload.rpm)) ? {} : { rpm: parseInt(payload.rpm) }),
...(payload.max_tokens === '' ? {} : { max_tokens: payload.max_tokens })
} }
}) })
}) })

View File

@ -27,6 +27,7 @@
let liteLLMAPIBase = ''; let liteLLMAPIBase = '';
let liteLLMAPIKey = ''; let liteLLMAPIKey = '';
let liteLLMRPM = ''; let liteLLMRPM = '';
let liteLLMMaxTokens = '';
let deleteLiteLLMModelId = ''; let deleteLiteLLMModelId = '';
@ -326,7 +327,8 @@
model: liteLLMModel, model: liteLLMModel,
api_base: liteLLMAPIBase, api_base: liteLLMAPIBase,
api_key: liteLLMAPIKey, api_key: liteLLMAPIKey,
rpm: liteLLMRPM rpm: liteLLMRPM,
max_tokens: liteLLMMaxTokens
}).catch((error) => { }).catch((error) => {
toast.error(error); toast.error(error);
return null; return null;
@ -821,6 +823,22 @@
</div> </div>
</div> </div>
</div> </div>
<div>
<div class="mb-1.5 text-sm font-medium">Max Tokens</div>
<div class="flex w-full">
<div class="flex-1">
<input
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
placeholder="Enter Max Tokens (litellm_params.max_tokens)"
bind:value={liteLLMMaxTokens}
type="number"
min="1"
autocomplete="off"
/>
</div>
</div>
</div>
{/if} {/if}
</div> </div>