add options to enable/disable presence/frequency penalty

This commit is contained in:
2025-01-21 05:31:37 +08:00
parent 1146d514d3
commit 3151fb8477
4 changed files with 39 additions and 4 deletions

View File

@@ -406,6 +406,30 @@ const Number = (props: {
}} }}
/> />
)} )}
{props.field === "presence_penalty" && (
<Checkbox
checked={chatStore.presence_penalty_enabled}
onCheckedChange={() => {
const newChatStore = { ...chatStore };
newChatStore.presence_penalty_enabled =
!newChatStore.presence_penalty_enabled;
setChatStore({ ...newChatStore });
}}
/>
)}
{props.field === "frequency_penalty" && (
<Checkbox
checked={chatStore.frequency_penalty_enabled}
onCheckedChange={() => {
const newChatStore = { ...chatStore };
newChatStore.frequency_penalty_enabled =
!newChatStore.frequency_penalty_enabled;
setChatStore({ ...newChatStore });
}}
/>
)}
</Label> </Label>
<Input <Input

View File

@@ -87,12 +87,15 @@ const Navbar: React.FC = () => {
<MenubarItem> <MenubarItem>
<ReceiptIcon className="w-4 h-4 mr-2" /> <ReceiptIcon className="w-4 h-4 mr-2" />
Price:{" "} Price:{" "}
{models[chatStore.model]?.price?.prompt * 1000 * 1000}$ {models[chatStore.model]?.price?.prompt *
/ 1M input tokens 1000 *
1000}$ / 1M input tokens
</MenubarItem> </MenubarItem>
<MenubarItem> <MenubarItem>
<WalletIcon className="w-4 h-4 mr-2" /> <WalletIcon className="w-4 h-4 mr-2" />
Total: {getTotalCost().toFixed(2)}$ Total: {getTotalCost().toFixed(
2
)}$
</MenubarItem> </MenubarItem>
<MenubarItem> <MenubarItem>
<ArrowUpDownIcon className="w-4 h-4 mr-2" /> <ArrowUpDownIcon className="w-4 h-4 mr-2" />
@@ -112,7 +115,9 @@ const Navbar: React.FC = () => {
</MenubarItem> </MenubarItem>
<MenubarItem> <MenubarItem>
<ScissorsIcon className="w-4 h-4 mr-2" /> <ScissorsIcon className="w-4 h-4 mr-2" />
{chatStore.postBeginIndex} / {chatStore.history.length} {
chatStore.postBeginIndex
} / {chatStore.history.length}
</MenubarItem> </MenubarItem>
<MenubarSeparator /> <MenubarSeparator />
<MenubarItem disabled> <MenubarItem disabled>

View File

@@ -26,7 +26,9 @@ export interface ChatStore {
top_p: number; top_p: number;
top_p_enabled: boolean; top_p_enabled: boolean;
presence_penalty: number; presence_penalty: number;
presence_penalty_enabled: boolean;
frequency_penalty: number; frequency_penalty: number;
frequency_penalty_enabled: boolean;
develop_mode: boolean; develop_mode: boolean;
whisper_api: string; whisper_api: string;
whisper_key: string; whisper_key: string;

View File

@@ -18,7 +18,9 @@ interface NewChatStoreOptions {
top_p?: number; top_p?: number;
top_p_enabled?: boolean; top_p_enabled?: boolean;
presence_penalty?: number; presence_penalty?: number;
presence_penalty_enabled?: boolean;
frequency_penalty?: number; frequency_penalty?: number;
frequency_penalty_enabled?: boolean;
dev?: boolean; dev?: boolean;
whisper_api?: string; whisper_api?: string;
whisper_key?: string; whisper_key?: string;
@@ -67,7 +69,9 @@ export const newChatStore = (options: NewChatStoreOptions): ChatStore => {
top_p: options.top_p ?? 1, top_p: options.top_p ?? 1,
top_p_enabled: options.top_p_enabled ?? false, top_p_enabled: options.top_p_enabled ?? false,
presence_penalty: options.presence_penalty ?? 0, presence_penalty: options.presence_penalty ?? 0,
presence_penalty_enabled: options.presence_penalty_enabled ?? false,
frequency_penalty: options.frequency_penalty ?? 0, frequency_penalty: options.frequency_penalty ?? 0,
frequency_penalty_enabled: options.frequency_penalty_enabled ?? false,
develop_mode: getDefaultParams("dev", options.dev ?? false), develop_mode: getDefaultParams("dev", options.dev ?? false),
whisper_api: getDefaultParams( whisper_api: getDefaultParams(
"whisper-api", "whisper-api",