diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index fce7eee4e12..79d485562bb 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -1,4 +1,8 @@ -import { OpenaiPath, REQUEST_TIMEOUT_MS } from "@/app/constant"; +import { + DEFAULT_API_HOST, + OpenaiPath, + REQUEST_TIMEOUT_MS, +} from "@/app/constant"; import { useAccessStore, useAppConfig, useChatStore } from "@/app/store"; import { ChatOptions, getHeaders, LLMApi, LLMUsage } from "../api"; @@ -12,6 +16,9 @@ import { prettyObject } from "@/app/utils/format"; export class ChatGPTApi implements LLMApi { path(path: string): string { let openaiUrl = useAccessStore.getState().openaiUrl; + if (openaiUrl.length === 0) { + openaiUrl = DEFAULT_API_HOST; + } if (openaiUrl.endsWith("/")) { openaiUrl = openaiUrl.slice(0, openaiUrl.length - 1); } diff --git a/app/components/button.module.scss b/app/components/button.module.scss index 5aa53dcf950..e332df2d2c8 100644 --- a/app/components/button.module.scss +++ b/app/components/button.module.scss @@ -27,6 +27,26 @@ fill: white !important; } } + + &.danger { + color: rgba($color: red, $alpha: 0.8); + border-color: rgba($color: red, $alpha: 0.5); + background-color: rgba($color: red, $alpha: 0.05); + + &:hover { + border-color: red; + background-color: rgba($color: red, $alpha: 0.1); + } + + path { + fill: red !important; + } + } + + &:hover, + &:focus { + border-color: var(--primary); + } } .shadow { @@ -37,10 +57,6 @@ border: var(--border-in-light); } -.icon-button:hover { - border-color: var(--primary); -} - .icon-button-icon { width: 16px; height: 16px; @@ -56,9 +72,12 @@ } .icon-button-text { - margin-left: 5px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + + &:not(:first-child) { + margin-left: 5px; + } } diff --git a/app/components/button.tsx b/app/components/button.tsx index f93741b392f..7a5633924c5 100644 --- a/app/components/button.tsx +++ b/app/components/button.tsx @@ -2,16 +2,20 @@ import * as React from "react"; import styles from "./button.module.scss"; +export type ButtonType = "primary" | "danger" | null; + export function IconButton(props: { onClick?: () => void; icon?: JSX.Element; - type?: "primary" | "danger"; + type?: ButtonType; text?: string; bordered?: boolean; shadow?: boolean; className?: string; title?: string; disabled?: boolean; + tabIndex?: number; + autoFocus?: boolean; }) { return (