This commit is contained in:
hailin 2025-04-19 21:38:00 +08:00
parent 05a8685504
commit ce1b44ac79
10 changed files with 76 additions and 36 deletions

View File

@ -6,11 +6,15 @@ import { IconSparkles } from "@tabler/icons-react"
import { FC, useState } from "react" import { FC, useState } from "react"
import { SidebarItem } from "../all/sidebar-display-item" import { SidebarItem } from "../all/sidebar-display-item"
import { useTranslation } from 'react-i18next'
interface ModelItemProps { interface ModelItemProps {
model: Tables<"models"> model: Tables<"models">
} }
export const ModelItem: FC<ModelItemProps> = ({ model }) => { export const ModelItem: FC<ModelItemProps> = ({ model }) => {
const { t } = useTranslation()
const [isTyping, setIsTyping] = useState(false) const [isTyping, setIsTyping] = useState(false)
const [apiKey, setApiKey] = useState(model.api_key) const [apiKey, setApiKey] = useState(model.api_key)
@ -39,10 +43,10 @@ export const ModelItem: FC<ModelItemProps> = ({ model }) => {
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Model name..." placeholder={t("side.modelNamePlaceholder")}
value={name} value={name}
onChange={e => setName(e.target.value)} onChange={e => setName(e.target.value)}
maxLength={MODEL_NAME_MAX} maxLength={MODEL_NAME_MAX}
@ -50,42 +54,42 @@ export const ModelItem: FC<ModelItemProps> = ({ model }) => {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Model ID</Label> <Label>{t("side.modelId")}</Label>
<Input <Input
placeholder="Model ID..." placeholder={t("side.modelIdPlaceholder")}
value={modelId} value={modelId}
onChange={e => setModelId(e.target.value)} onChange={e => setModelId(e.target.value)}
/> />
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Base URL</Label> <Label>{t("side.baseUrl")}</Label>
<Input <Input
placeholder="Base URL..." placeholder={t("side.baseUrlPlaceholder")}
value={baseUrl} value={baseUrl}
onChange={e => setBaseUrl(e.target.value)} onChange={e => setBaseUrl(e.target.value)}
/> />
<div className="pt-1 text-xs italic"> <div className="pt-1 text-xs italic">
Your API must be compatible with the OpenAI SDK. {t("side.apiCompatibilityNotice")}
</div> </div>
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>API Key</Label> <Label>{t("side.apiKey")}</Label>
<Input <Input
type="password" type="password"
placeholder="API Key..." placeholder={t("side.apiKeyPlaceholder")}
value={apiKey} value={apiKey}
onChange={e => setApiKey(e.target.value)} onChange={e => setApiKey(e.target.value)}
/> />
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Max Context Length</Label> <Label>{t("side.maxContextLength")}</Label>
<Input <Input
type="number" type="number"

View File

@ -7,6 +7,8 @@ import { PRESET_NAME_MAX } from "@/db/limits"
import { TablesInsert } from "@/supabase/types" import { TablesInsert } from "@/supabase/types"
import { FC, useContext, useState } from "react" import { FC, useContext, useState } from "react"
import { useTranslation } from 'react-i18next'
interface CreatePresetProps { interface CreatePresetProps {
isOpen: boolean isOpen: boolean
onOpenChange: (isOpen: boolean) => void onOpenChange: (isOpen: boolean) => void
@ -16,6 +18,7 @@ export const CreatePreset: FC<CreatePresetProps> = ({
isOpen, isOpen,
onOpenChange onOpenChange
}) => { }) => {
const { t } = useTranslation()
const { profile, selectedWorkspace } = useContext(ChatbotUIContext) const { profile, selectedWorkspace } = useContext(ChatbotUIContext)
const [name, setName] = useState("") const [name, setName] = useState("")
@ -59,10 +62,10 @@ export const CreatePreset: FC<CreatePresetProps> = ({
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Preset name..." placeholder={t("side.presetNamePlaceholder")}
value={name} value={name}
onChange={e => setName(e.target.value)} onChange={e => setName(e.target.value)}
maxLength={PRESET_NAME_MAX} maxLength={PRESET_NAME_MAX}

View File

@ -8,11 +8,14 @@ import { Tables } from "@/supabase/types"
import { FC, useState } from "react" import { FC, useState } from "react"
import { SidebarItem } from "../all/sidebar-display-item" import { SidebarItem } from "../all/sidebar-display-item"
import { useTranslation } from 'react-i18next'
interface PresetItemProps { interface PresetItemProps {
preset: Tables<"presets"> preset: Tables<"presets">
} }
export const PresetItem: FC<PresetItemProps> = ({ preset }) => { export const PresetItem: FC<PresetItemProps> = ({ preset }) => {
const { t } = useTranslation()
const [name, setName] = useState(preset.name) const [name, setName] = useState(preset.name)
const [isTyping, setIsTyping] = useState(false) const [isTyping, setIsTyping] = useState(false)
const [description, setDescription] = useState(preset.description) const [description, setDescription] = useState(preset.description)
@ -53,10 +56,10 @@ export const PresetItem: FC<PresetItemProps> = ({ preset }) => {
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Preset name..." placeholder={t("side.presetNamePlaceholder")}
value={name} value={name}
onChange={e => setName(e.target.value)} onChange={e => setName(e.target.value)}
maxLength={PRESET_NAME_MAX} maxLength={PRESET_NAME_MAX}

View File

@ -6,6 +6,7 @@ import { ChatbotUIContext } from "@/context/context"
import { PROMPT_NAME_MAX } from "@/db/limits" import { PROMPT_NAME_MAX } from "@/db/limits"
import { TablesInsert } from "@/supabase/types" import { TablesInsert } from "@/supabase/types"
import { FC, useContext, useState } from "react" import { FC, useContext, useState } from "react"
import { useTranslation } from 'react-i18next'
interface CreatePromptProps { interface CreatePromptProps {
isOpen: boolean isOpen: boolean
@ -16,6 +17,7 @@ export const CreatePrompt: FC<CreatePromptProps> = ({
isOpen, isOpen,
onOpenChange onOpenChange
}) => { }) => {
const { t } = useTranslation()
const { profile, selectedWorkspace } = useContext(ChatbotUIContext) const { profile, selectedWorkspace } = useContext(ChatbotUIContext)
const [isTyping, setIsTyping] = useState(false) const [isTyping, setIsTyping] = useState(false)
const [name, setName] = useState("") const [name, setName] = useState("")
@ -40,10 +42,10 @@ export const CreatePrompt: FC<CreatePromptProps> = ({
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Prompt name..." placeholder={t("side.promptNamePlaceholder")}
value={name} value={name}
onChange={e => setName(e.target.value)} onChange={e => setName(e.target.value)}
maxLength={PROMPT_NAME_MAX} maxLength={PROMPT_NAME_MAX}
@ -53,10 +55,10 @@ export const CreatePrompt: FC<CreatePromptProps> = ({
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Prompt</Label> <Label>{t("side.promptLabel")}</Label>
<TextareaAutosize <TextareaAutosize
placeholder="Prompt content..." placeholder={t("side.promptContentPlaceholder")}
value={content} value={content}
onValueChange={setContent} onValueChange={setContent}
minRows={6} minRows={6}

View File

@ -25,10 +25,10 @@ export const PromptItem: FC<PromptItemProps> = ({ prompt }) => {
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Prompt name..." placeholder={t("side.promptNamePlaceholder")}
value={name} value={name}
onChange={e => setName(e.target.value)} onChange={e => setName(e.target.value)}
maxLength={PROMPT_NAME_MAX} maxLength={PROMPT_NAME_MAX}
@ -38,10 +38,10 @@ export const PromptItem: FC<PromptItemProps> = ({ prompt }) => {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Prompt</Label> <Label>{t("side.promptLabel")}</Label>
<TextareaAutosize <TextareaAutosize
placeholder="Prompt..." placeholder={t("side.promptPlaceholderShort")}
value={content} value={content}
onValueChange={setContent} onValueChange={setContent}
minRows={6} minRows={6}

View File

@ -44,10 +44,10 @@ export const CreateTool: FC<CreateToolProps> = ({ isOpen, onOpenChange }) => {
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Tool name..." placeholder={t("side.toolNamePlaceholder")}
value={name} value={name}
onChange={e => setName(e.target.value)} onChange={e => setName(e.target.value)}
maxLength={TOOL_NAME_MAX} maxLength={TOOL_NAME_MAX}
@ -55,10 +55,10 @@ export const CreateTool: FC<CreateToolProps> = ({ isOpen, onOpenChange }) => {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Description</Label> <Label>{t("side.description")}</Label>
<Input <Input
placeholder="Tool description..." placeholder={t("side.toolDescriptionPlaceholder")}
value={description} value={description}
onChange={e => setDescription(e.target.value)} onChange={e => setDescription(e.target.value)}
maxLength={TOOL_DESCRIPTION_MAX} maxLength={TOOL_DESCRIPTION_MAX}
@ -96,7 +96,7 @@ export const CreateTool: FC<CreateToolProps> = ({ isOpen, onOpenChange }) => {
</div> */} </div> */}
<div className="space-y-1"> <div className="space-y-1">
<Label>Custom Headers</Label> <Label>{t("side.customHeadersLabel")}</Label>
<TextareaAutosize <TextareaAutosize
placeholder={`{"X-api-key": "1234567890"}`} placeholder={`{"X-api-key": "1234567890"}`}
@ -107,7 +107,7 @@ export const CreateTool: FC<CreateToolProps> = ({ isOpen, onOpenChange }) => {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Schema</Label> <Label>{t("side.schemaLabel")}</Label>
<TextareaAutosize <TextareaAutosize
placeholder={`{ placeholder={`{

View File

@ -39,7 +39,7 @@ export const ToolItem: FC<ToolItemProps> = ({ tool }) => {
renderInputs={() => ( renderInputs={() => (
<> <>
<div className="space-y-1"> <div className="space-y-1">
<Label>Name</Label> <Label>{t("side.name")}</Label>
<Input <Input
placeholder="Tool name..." placeholder="Tool name..."
@ -50,10 +50,10 @@ export const ToolItem: FC<ToolItemProps> = ({ tool }) => {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Description</Label> <Label>{t("side.description")}</Label>
<Input <Input
placeholder="Tool description..." placeholder={t("side.toolDescriptionPlaceholder")}
value={description} value={description}
onChange={e => setDescription(e.target.value)} onChange={e => setDescription(e.target.value)}
maxLength={TOOL_DESCRIPTION_MAX} maxLength={TOOL_DESCRIPTION_MAX}
@ -91,7 +91,7 @@ export const ToolItem: FC<ToolItemProps> = ({ tool }) => {
</div> */} </div> */}
<div className="space-y-1"> <div className="space-y-1">
<Label>Custom Headers</Label> <Label>{t("side.customHeadersLabel")}</Label>
<TextareaAutosize <TextareaAutosize
placeholder={`{"X-api-key": "1234567890"}`} placeholder={`{"X-api-key": "1234567890"}`}
@ -102,7 +102,7 @@ export const ToolItem: FC<ToolItemProps> = ({ tool }) => {
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
<Label>Schema</Label> <Label>{t("side.schemaLabel")}</Label>
<TextareaAutosize <TextareaAutosize
placeholder={`{ placeholder={`{

View File

@ -192,7 +192,16 @@
"baseUrlPlaceholder": "Base URL...", "baseUrlPlaceholder": "Base URL...",
"apiKey": "API Key", "apiKey": "API Key",
"apiKeyPlaceholder": "API Key...", "apiKeyPlaceholder": "API Key...",
"maxContextLength": "Max Context Length" "maxContextLength": "Max Context Length",
"presetNamePlaceholder": "Preset name...",
"promptLabel": "Prompt",
"promptNamePlaceholder": "Prompt name...",
"promptContentPlaceholder": "Prompt content...",
"promptPlaceholderShort": "Prompt...",
"toolNamePlaceholder": "Tool name...",
"toolDescriptionPlaceholder": "Tool description...",
"customHeadersLabel": "Custom Headers",
"schemaLabel": "Schema"
}, },
"contentType": { "contentType": {

View File

@ -191,7 +191,17 @@
"baseUrlPlaceholder": "ベース URL...", "baseUrlPlaceholder": "ベース URL...",
"apiKey": "API キー", "apiKey": "API キー",
"apiKeyPlaceholder": "API キー...", "apiKeyPlaceholder": "API キー...",
"maxContextLength": "最大コンテキスト長" "maxContextLength": "最大コンテキスト長",
"presetNamePlaceholder": "プリセット名...",
"promptLabel": "プロンプト",
"promptNamePlaceholder": "プロンプト名...",
"promptContentPlaceholder": "プロンプトの内容...",
"promptPlaceholderShort": "プロンプト...",
"toolNamePlaceholder": "ツール名...",
"toolDescriptionPlaceholder": "ツールの説明...",
"customHeadersLabel": "カスタムヘッダー",
"schemaLabel": "スキーマ"
}, },
"contentType": { "contentType": {

View File

@ -191,7 +191,16 @@
"baseUrlPlaceholder": "基础地址...", "baseUrlPlaceholder": "基础地址...",
"apiKey": "API 密钥", "apiKey": "API 密钥",
"apiKeyPlaceholder": "API 密钥...", "apiKeyPlaceholder": "API 密钥...",
"maxContextLength": "最大上下文长度" "maxContextLength": "最大上下文长度",
"presetNamePlaceholder": "预设名称...",
"promptLabel": "提示词",
"promptNamePlaceholder": "提示词名称...",
"promptContentPlaceholder": "提示词内容...",
"promptPlaceholderShort": "提示词...",
"toolNamePlaceholder": "工具名称...",
"toolDescriptionPlaceholder": "工具描述...",
"customHeadersLabel": "自定义请求头",
"schemaLabel": "Schema"
}, },
"contentType": { "contentType": {