Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Inconsistent text color, hidden api-key field, chatcompletion field under advance setting #4532

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 64 additions & 38 deletions web/screens/Settings/Engines/RemoteEngineSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ScrollArea, Input, TextArea } from '@janhq/joi'
import { useAtomValue } from 'jotai'

import { set } from 'lodash'
import { ChevronDown, ChevronRight } from 'lucide-react'
import { ChevronDown, ChevronRight, Eye, EyeOff } from 'lucide-react'
import { twMerge } from 'tailwind-merge'

import { updateEngine, useGetEngines } from '@/hooks/useEngineManagement'
Expand All @@ -36,7 +36,7 @@ const RemoteEngineSettings = ({
}) => {
const { engines, mutate } = useGetEngines()
const downloadedModels = useAtomValue(downloadedModelsAtom)

const [showApiKey, setShowApiKey] = useState(false)
const remoteModels = downloadedModels.filter((e) => e.engine === name)
const [isActiveAdvanceSetting, setisActiveAdvanceSetting] = useState(false)

Expand Down Expand Up @@ -147,42 +147,35 @@ const RemoteEngineSettings = ({
</p>
</div>
<div className="w-full">
<Input
placeholder="Enter API Key"
value={data?.api_key}
onChange={(e) => handleChange('api_key', e.target.value)}
/>
</div>
</div>
</div>
</div>
</div>
</div>

<div className="block w-full px-4">
<div className="mb-3 mt-4 border-b border-[hsla(var(--app-border))] pb-4">
<div className="flex w-full flex-col items-start justify-between sm:flex-row">
<div className="w-full flex-shrink-0 space-y-1.5">
<div className="flex items-start justify-between gap-x-2">
<div className="w-full sm:w-3/4">
<h6 className="line-clamp-1 font-semibold">
Chat Completion URL
</h6>
<p className="mt-1 text-[hsla(var(--text-secondary))]">
Enter your chat completion URL.
</p>
</div>
<div className="w-full">
<Input
placeholder="Enter Chat Completion URL"
value={data?.metadata.transform_req.chat_completions.url}
onChange={(e) =>
handleChange(
'metadata.transform_req.chat_completions.url',
e.target.value
)
}
/>
<div className="relative">
{data?.api_key.length > 0 && (
<div className="absolute right-4 top-1/2 z-10 -translate-y-1/2">
<div
className="cursor-pointer"
onClick={() => setShowApiKey(!showApiKey)}
>
{showApiKey ? (
<EyeOff
size={14}
className="text-[hsla(var(--text-seconday))]"
/>
) : (
<Eye
size={14}
className="text-[hsla(var(--text-seconday))]"
/>
)}
</div>
</div>
)}
<Input
placeholder="Enter API Key"
type={showApiKey ? 'text' : 'password'}
value={data?.api_key}
className="pr-10"
onChange={(e) => handleChange('api_key', e.target.value)}
/>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -252,6 +245,39 @@ const RemoteEngineSettings = ({

{isActiveAdvanceSetting && (
<div>
<div className="block w-full px-4">
<div className="mb-3 mt-4 border-b border-[hsla(var(--app-border))] pb-4">
<div className="flex w-full flex-col items-start justify-between sm:flex-row">
<div className="w-full flex-shrink-0 space-y-1.5">
<div className="flex items-start justify-between gap-x-2">
<div className="w-full sm:w-3/4">
<h6 className="line-clamp-1 font-semibold">
Chat Completion URL
</h6>
<p className="mt-1 text-[hsla(var(--text-secondary))]">
Enter your chat completion URL.
</p>
</div>
<div className="w-full">
<Input
placeholder="Enter Chat Completion URL"
value={
data?.metadata.transform_req.chat_completions.url
}
onChange={(e) =>
handleChange(
'metadata.transform_req.chat_completions.url',
e.target.value
)
}
/>
</div>
</div>
</div>
</div>
</div>
</div>

<div className="block w-full px-4">
<div className="mb-3 mt-4 border-b border-[hsla(var(--app-border))] pb-4">
<div className="flex w-full flex-col items-start justify-between sm:flex-row">
Expand Down
3 changes: 1 addition & 2 deletions web/screens/Settings/MyModels/MyModelList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const MyModelList = ({ model }: Props) => {
<h6
className={twMerge(
'font-medium lg:line-clamp-1 lg:min-w-[280px] lg:max-w-[280px]',
!isLocalEngine(engines, model.engine) &&
'max-w-none text-[hsla(var(--text-secondary))]'
!isLocalEngine(engines, model.engine) && 'max-w-none'
)}
title={model.name}
>
Expand Down
Loading