import { Fragment, useCallback } from 'react' import { Tooltip, Switch, Input } from '@janhq/joi' import { useAtomValue } from 'jotai' import { InfoIcon } from 'lucide-react' import AssistantSetting from '@/screens/Thread/ThreadCenterPanel/AssistantSetting' import { getConfigurationsData } from '@/utils/componentSettings' import { experimentalFeatureEnabledAtom } from '@/helpers/atoms/AppConfig.atom' import { getSelectedModelAtom } from '@/helpers/atoms/Model.atom' import { activeThreadAtom } from '@/helpers/atoms/Thread.atom' const Tools = () => { const experimentalFeature = useAtomValue(experimentalFeatureEnabledAtom) const activeThread = useAtomValue(activeThreadAtom) const selectedModel = useAtomValue(getSelectedModelAtom) const componentDataAssistantSetting = getConfigurationsData( // (activeThread?.assistants[0]?.tools && // activeThread?.assistants[0]?.tools[0]?.settings) ?? {} ) const onRetrievalSwitchUpdate = useCallback( (enabled: boolean) => { console.log('onRetrievalSwitchUpdate enabled', enabled) if (!activeThread) return // updateThreadMetadata({ // ...activeThread, // assistants: [ // { // ...activeThread.assistants[0], // tools: [ // { // type: 'retrieval', // enabled: enabled, // settings: // (activeThread.assistants[0].tools && // activeThread.assistants[0].tools[0]?.settings) ?? // {}, // }, // ], // }, // ], // }) }, [activeThread] ) // const onTimeWeightedRetrieverSwitchUpdate = useCallback( // (enabled: boolean) => { // if (!activeThread) return // updateThreadMetadata({ // ...activeThread, // assistants: [ // { // ...activeThread.assistants[0], // tools: [ // { // type: 'retrieval', // enabled: true, // useTimeWeightedRetriever: enabled, // settings: // (activeThread.assistants[0].tools && // activeThread.assistants[0].tools[0]?.settings) ?? // {}, // }, // ], // }, // ], // }) // }, // [activeThread] // ) if (!experimentalFeature) return null return ( {activeThread?.assistants[0]?.tools && componentDataAssistantSetting.length > 0 && (
onRetrievalSwitchUpdate(e.target.checked)} />
{activeThread?.assistants[0]?.tools[0].enabled && (
} content="Embedding model is crucial for understanding and processing the input text effectively by converting text to numerical representations. Align the model choice with your task, evaluate its performance, and consider factors like resource availability. Experiment to find the best fit for your specific use case." />
{/*
onTimeWeightedRetrieverSwitchUpdate(e.target.checked) } />
*/}
} content="Time-Weighted Retriever looks at how similar they are and how new they are. It compares documents based on their meaning like usual, but also considers when they were added to give newer ones more importance." />
)}
)}
) } export default Tools