@@ -13,7 +13,7 @@ import {
1313import { DocumentDuplicateIconOutline , ClipboardDocumentCheckIconOutline } from '@neo4j-ndl/react/icons' ;
1414import '../../styling/info.css' ;
1515import Neo4jRetrievalLogo from '../../assets/images/Neo4jRetrievalLogo.png' ;
16- import { ExtendedNode , UserCredentials , chatInfoMessage , multimodelmetric } from '../../types' ;
16+ import { ExtendedNode , UserCredentials , chatInfoMessage } from '../../types' ;
1717import { useContext , useEffect , useMemo , useState } from 'react' ;
1818import GraphViewButton from '../Graph/GraphViewButton' ;
1919import { chunkEntitiesAPI } from '../../services/ChunkEntitiesInfo' ;
@@ -57,6 +57,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
5757 metricsLoading,
5858 activeChatmodes,
5959 metricError,
60+ multiModelMetrics,
6061 saveNodes,
6162 saveChunks,
6263 saveChatRelationships,
@@ -65,6 +66,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
6566 saveMetrics,
6667 toggleInfoLoading,
6768 toggleMetricsLoading,
69+ saveMultimodemetrics,
6870} ) => {
6971 const { breakpoints } = tokens ;
7072 const isTablet = useMediaQuery ( `(min-width:${ breakpoints . xs } ) and (max-width: ${ breakpoints . lg } )` ) ;
@@ -76,11 +78,8 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
7678 const [ , copy ] = useCopyToClipboard ( ) ;
7779 const [ copiedText , setcopiedText ] = useState < boolean > ( false ) ;
7880 const [ showMetricsTable , setShowMetricsTable ] = useState < boolean > ( Boolean ( metricDetails ) ) ;
79- const [ multiModelMetrics , setMultiModelMetrics ] = useState < multimodelmetric [ ] > ( [ ] ) ;
8081 const [ multiModeError , setMultiModeError ] = useState < string > ( '' ) ;
8182
82- console . log ( 'node' , nodeDetails ) ;
83-
8483 const actions : CypherCodeBlockProps [ 'actions' ] = useMemo (
8584 ( ) => [
8685 {
@@ -170,7 +169,6 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
170169 if ( metricsLoading ) {
171170 toggleMetricsLoading ( ) ;
172171 }
173- setMultiModelMetrics ( [ ] ) ;
174172 } ;
175173 } , [ nodeDetails , mode , error , metricsLoading ] ) ;
176174
@@ -181,7 +179,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
181179 if ( activeChatmodes ) {
182180 if ( Object . keys ( activeChatmodes ) . length <= 1 ) {
183181 setShowMetricsTable ( true ) ;
184- const defaultMode = Object . keys ( activeChatmodes ) [ 0 ] ;
182+ const [ defaultMode ] = Object . keys ( activeChatmodes ) ;
185183 try {
186184 toggleMetricsLoading ( ) ;
187185 const response = await getChatMetrics ( metricquestion , [ metriccontexts ] , [ metricanswer ] , metricmodel , [
@@ -227,7 +225,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
227225 const metricsdata = Object . entries ( modewisedata ) . map ( ( [ mode , scores ] ) => {
228226 return { mode, answer_relevancy : scores . answer_relevancy , faithfulness : scores . faithfulness } ;
229227 } ) ;
230- setMultiModelMetrics ( metricsdata ) ;
228+ saveMultimodemetrics ( metricsdata ) ;
231229 } else {
232230 throw new Error ( responses . data . error ) ;
233231 }
@@ -346,7 +344,7 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
346344 { showMetricsTable && activeChatmodes != null && Object . keys ( activeChatmodes ) . length <= 1 && (
347345 < MetricsTab metricsLoading = { metricsLoading } error = { metricError } metricDetails = { metricDetails } />
348346 ) }
349- { ! metricDetails && (
347+ { ! metricDetails && activeChatmodes != undefined && Object . keys ( activeChatmodes ) . length <= 1 && (
350348 < Button
351349 label = 'Metrics Action Button'
352350 disabled = { metricsLoading || ! supportedLLmsForRagas . includes ( metricmodel ) }
@@ -356,14 +354,14 @@ const ChatInfoModal: React.FC<chatInfoMessage> = ({
356354 View Detailed Metrics
357355 </ Button >
358356 ) }
359- { ! multiModelMetrics && (
357+ { ! multiModelMetrics . length && activeChatmodes != undefined && Object . keys ( activeChatmodes ) . length > 1 && (
360358 < Button
361359 label = 'Metrics Action Button'
362360 disabled = { metricsLoading || ! supportedLLmsForRagas . includes ( metricmodel ) }
363361 className = 'w-max self-center mt-4'
364362 onClick = { loadMetrics }
365363 >
366- View Detailed For All Modes
364+ View Detailed Metrics For All Modes
367365 </ Button >
368366 ) }
369367 </ Stack >
0 commit comments