Add SelectedKnowledge component to OptionLayout and KnowledgeSelect
This commit is contained in:
parent
dd496b7b98
commit
82abbf5bad
@ -19,6 +19,7 @@ import { getAllPrompts } from "@/db"
|
|||||||
import { ShareBtn } from "~/components/Common/ShareBtn"
|
import { ShareBtn } from "~/components/Common/ShareBtn"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import { OllamaIcon } from "../Icons/Ollama"
|
import { OllamaIcon } from "../Icons/Ollama"
|
||||||
|
import { SelectedKnowledge } from "../Option/Knowledge/SelectedKnwledge"
|
||||||
|
|
||||||
export default function OptionLayout({
|
export default function OptionLayout({
|
||||||
children
|
children
|
||||||
@ -166,6 +167,7 @@ export default function OptionLayout({
|
|||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<SelectedKnowledge />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-1 justify-end px-4">
|
<div className="flex flex-1 justify-end px-4">
|
||||||
<div className="ml-4 flex items-center md:ml-6">
|
<div className="ml-4 flex items-center md:ml-6">
|
||||||
|
@ -19,6 +19,8 @@ export const KnowledgeSelect: React.FC = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
{data && data.length > 0 && (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
menu={{
|
menu={{
|
||||||
items:
|
items:
|
||||||
@ -56,5 +58,7 @@ export const KnowledgeSelect: React.FC = () => {
|
|||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,32 @@
|
|||||||
import { Knowledge } from "@/db/knowledge"
|
import { Blocks, XIcon } from "lucide-react"
|
||||||
import { XIcon } from "lucide-react"
|
import { useMessageOption } from "@/hooks/useMessageOption"
|
||||||
import { KnowledgeIcon } from "./KnowledgeIcon"
|
|
||||||
|
|
||||||
type Props = {
|
export const SelectedKnowledge = () => {
|
||||||
knowledge: Knowledge
|
const { selectedKnowledge: knowledge, setSelectedKnowledge } =
|
||||||
onClose: () => void
|
useMessageOption()
|
||||||
}
|
|
||||||
|
if (!knowledge) return <></>
|
||||||
|
|
||||||
export const SelectedKnowledge = ({ knowledge, onClose }: Props) => {
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-3 border flex justify-between items-center rounded-md p-2 dark:border-gray-600">
|
<div className="flex flex-row items-center gap-3">
|
||||||
<div className="flex flex-col gap-2">
|
<span className="text-lg font-thin text-zinc-300 dark:text-zinc-600">
|
||||||
<div>
|
{"/"}
|
||||||
<h3 className="text-sm font-semibold dark:text-gray-100">
|
</span>
|
||||||
|
<div className="border flex justify-between items-center rounded-md p-1 gap-2 bg-gray-100 dark:bg-gray-800 dark:border-gray-700">
|
||||||
|
<div className="inline-flex items-center gap-2">
|
||||||
|
<Blocks className="h-6 w-6 text-gray-400" />
|
||||||
|
<span className="text-xs font-semibold dark:text-gray-100">
|
||||||
{knowledge.title}
|
{knowledge.title}
|
||||||
</h3>
|
</span>
|
||||||
</div>
|
|
||||||
<div className="flex flex-row overflow-x-auto gap-2 w-full">
|
|
||||||
{knowledge.source.map((source, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="inline-flex gap-2 text-xs border rounded-md p-1 dark:border-gray-600 dark:text-gray-100">
|
|
||||||
<KnowledgeIcon type={source.type} className="w-4 h-4" />
|
|
||||||
{source.filename}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
onClick={onClose}
|
onClick={() => setSelectedKnowledge(null)}
|
||||||
className="flex items-center justify-center bg-white dark:bg-[#262626] p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 text-black dark:text-gray-100">
|
className="flex items-center justify-center bg-white dark:bg-[#262626] p-1 rounded-full hover:bg-gray-100 dark:hover:bg-gray-600 text-black dark:text-gray-100">
|
||||||
<XIcon className="h-5 w-5" />
|
<XIcon className="h-3 w-3" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
|||||||
selectedQuickPrompt,
|
selectedQuickPrompt,
|
||||||
textareaRef,
|
textareaRef,
|
||||||
setSelectedQuickPrompt,
|
setSelectedQuickPrompt,
|
||||||
selectedKnowledge,
|
selectedKnowledge
|
||||||
setSelectedKnowledge
|
|
||||||
} = useMessageOption()
|
} = useMessageOption()
|
||||||
|
|
||||||
const textAreaFocus = () => {
|
const textAreaFocus = () => {
|
||||||
@ -158,7 +157,6 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="px-3 pt-3 md:px-6 md:pt-6 bg-gray-50 dark:bg-[#262626] border rounded-t-xl dark:border-gray-600">
|
<div className="px-3 pt-3 md:px-6 md:pt-6 bg-gray-50 dark:bg-[#262626] border rounded-t-xl dark:border-gray-600">
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={`h-full rounded-md shadow relative ${
|
className={`h-full rounded-md shadow relative ${
|
||||||
form.values.image.length === 0 ? "hidden" : "block"
|
form.values.image.length === 0 ? "hidden" : "block"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user