1
- import { ArrowDownward , ChevronLeft , MenuBookTwoTone , Tune } from '@mui/icons-material'
1
+ import { ArrowDownward , ChevronLeft , MenuBookTwoTone , Tune , WidthFull } from '@mui/icons-material'
2
2
import HelpIcon from '@mui/icons-material/Help'
3
3
import RestartAltIcon from '@mui/icons-material/RestartAlt'
4
+
4
5
import { Alert , Box , Drawer , Fab , FormControlLabel , Paper , Switch , Typography , useMediaQuery , useTheme } from '@mui/material'
5
6
import type { TFunction } from 'i18next'
6
7
import { enqueueSnackbar } from 'notistack'
@@ -32,9 +33,13 @@ import ToolResult from './ToolResult'
32
33
import { OutlineButtonBlack } from './general/Buttons'
33
34
import { ChatInfo } from './general/ChatInfo'
34
35
import RagSelector from './RagSelector'
35
- import { SettingsModal } from './SettingsModal'
36
+ import { SettingsModal , useUrlPromptId } from './SettingsModal'
36
37
import { useChatStream } from './useChatStream'
37
38
import { getCompletionStreamV3 } from './util'
39
+ import PromptSelector from './PromptSelector'
40
+ import { useQuery } from '@tanstack/react-query'
41
+ import { useMutation } from '@tanstack/react-query'
42
+ import apiClient from '../../util/apiClient'
38
43
39
44
function useLocalStorageStateWithURLDefault ( key : string , defaultValue : string , urlKey : string ) {
40
45
const [ value , setValue ] = useLocalStorageState ( key , defaultValue )
@@ -384,6 +389,8 @@ export const ChatV2 = () => {
384
389
setRagIndexId = { setRagIndexId }
385
390
ragIndices = { ragIndices }
386
391
messages = { messages }
392
+ activePrompt = { activePrompt }
393
+ setActivePrompt = { setActivePrompt }
387
394
/>
388
395
</ Drawer >
389
396
) : (
@@ -403,6 +410,8 @@ export const ChatV2 = () => {
403
410
setRagIndexId = { setRagIndexId }
404
411
ragIndices = { ragIndices }
405
412
messages = { messages }
413
+ activePrompt = { activePrompt }
414
+ setActivePrompt = { setActivePrompt }
406
415
/>
407
416
) ) }
408
417
@@ -594,6 +603,8 @@ const LeftMenu = ({
594
603
setRagIndexId,
595
604
ragIndices,
596
605
messages,
606
+ activePrompt,
607
+ setActivePrompt,
597
608
} : {
598
609
sx ?: object
599
610
course ?: Course
@@ -607,7 +618,15 @@ const LeftMenu = ({
607
618
setRagIndexId : React . Dispatch < React . SetStateAction < number | undefined > >
608
619
ragIndices ?: RagIndexAttributes [ ]
609
620
messages : Message [ ]
621
+ activePrompt : Prompt | undefined
622
+ setActivePrompt : ( prompt : Prompt | undefined ) => void
610
623
} ) => {
624
+ const urlPromptId = useUrlPromptId ( )
625
+ const { data : myPrompts , refetch } = useQuery < Prompt [ ] > ( {
626
+ queryKey : [ '/prompts/my-prompts' ] ,
627
+ initialData : [ ] ,
628
+ } )
629
+
611
630
return (
612
631
< Box
613
632
sx = { [
@@ -637,6 +656,15 @@ const LeftMenu = ({
637
656
< OutlineButtonBlack startIcon = { < HelpIcon /> } onClick = { ( ) => setDisclaimerStatus ( true ) } data-testid = "help-button" >
638
657
{ t ( 'info:title' ) }
639
658
</ OutlineButtonBlack >
659
+ < PromptSelector
660
+ sx = { { width : '100%' } }
661
+ coursePrompts = { course ?. prompts ?? [ ] }
662
+ myPrompts = { myPrompts }
663
+ activePrompt = { activePrompt }
664
+ setActivePrompt = { setActivePrompt }
665
+ mandatoryPrompt = { course ?. prompts . find ( ( p ) => p . mandatory ) }
666
+ urlPrompt = { course ?. prompts . find ( ( p ) => p . id === urlPromptId ) }
667
+ />
640
668
{ course && showRagSelector && (
641
669
< >
642
670
< Typography variant = "h6" sx = { { mb : 1 , display : 'flex' , gap : 1 , alignItems : 'center' } } fontWeight = "bold" >
0 commit comments