diff --git a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx index 78d8d9aea..d145fed18 100644 --- a/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx +++ b/application/frontend/src/pages/GapAnalysis/GapAnalysis.tsx @@ -48,6 +48,70 @@ function useQuery() { return React.useMemo(() => new URLSearchParams(search), [search]); } +const GetStrength = (score) => { + if (score < 5) return 'Strong'; + if (score > 20) return 'Weak'; + return 'Average'; +}; + +const GetStrengthColor = (score) => { + if (score < 5) return 'Green'; + if (score > 20) return 'Red'; + return 'Orange'; +}; + +const GetResultLine = (path, gapAnalysis, key) => { + let segmentID = gapAnalysis[key].start.id; + return ( + + {getDocumentDisplayName(path.end, true)} } + > + + {getDocumentDisplayName(gapAnalysis[key].start, true)} + {path.path.map((segment) => { + const { text, nextID } = GetSegmentText(segment, segmentID); + segmentID = nextID; + return text; + })} + + + + ({GetStrength(path.score)}:{path.score}) + + } + > + + Generally: lower is better + + {GetStrength(0)}: Closely connected likely to have + majority overlap + + {GetStrength(6)}: Connected likely to have partial + overlap + + {GetStrength(22)}: Weakly connected likely to have + small or no overlap + + + + + + + + ); +}; + export const GapAnalysis = () => { const standardOptionsDefault = [{ key: '', text: '', value: undefined }]; const searchParams = useQuery(); @@ -64,18 +128,6 @@ export const GapAnalysis = () => { const [error, setError] = useState(null); const { apiUrl } = useEnvironment(); - const GetStrength = (score) => { - if (score < 5) return 'Strong'; - if (score > 20) return 'Weak'; - return 'Average'; - }; - - const GetStrengthColor = (score) => { - if (score < 5) return 'Green'; - if (score > 20) return 'Red'; - return 'Orange'; - }; - const GetStrongPathsCount = (paths) => Math.max(Object.values(paths).filter((x) => GetStrength(x.score) === 'Strong').length, 3); @@ -120,12 +172,13 @@ export const GapAnalysis = () => { }; return ( - - - - - - Base Sandard{' '} + + + + + + {' '} + Base:{' '} { onChange={(e, { value }) => setBaseStandard(value?.toString())} value={BaseStandard} /> - - - - - Compare Sandard{' '} + + + Compare:{' '} { onChange={(e, { value }) => setCompareStandard(value?.toString())} value={CompareStandard} /> - - - - {gapAnalysis && ( - <> - - Generally: lower is better - - {GetStrength(0)}: Closely connected likely to have - majority overlap - - {GetStrength(6)}: Connected likely to have partial - overlap - - {GetStrength(22)}: Weakly connected likely to - have small or no overlap - - - - { - navigator.clipboard.writeText( - `${window.location.origin}/gap_analysis?base=${BaseStandard}&compare=${CompareStandard}` - ); - }} - target="_blank" - > - Share this anyalysis - - - > - )} - - - {gapAnalysis && ( - - - - {BaseStandard} - {CompareStandard} - - - - - {Object.keys(gapAnalysis).map((key) => ( - - - - {getDocumentDisplayName(gapAnalysis[key].start, true)}{' '} - - - - - - - {Object.values(gapAnalysis[key].paths) - .sort((a, b) => a.score - b.score) - .slice(0, GetStrongPathsCount(gapAnalysis[key].paths)) - .map((path) => { - let segmentID = gapAnalysis[key].start.id; - return ( - - - {getDocumentDisplayName(path.end, true)} ( - - {GetStrength(path.score)}:{path.score} - - ){' '} - - - - - } - > - - {getDocumentDisplayName(gapAnalysis[key].start, true)} - {path.path.map((segment) => { - const { text, nextID } = GetSegmentText(segment, segmentID); - segmentID = nextID; - return text; - })} - - - - + {gapAnalysis && ( + + { + navigator.clipboard.writeText( + `${window.location.origin}/gap_analysis?base=${BaseStandard}&compare=${CompareStandard}` ); - })} - {Object.keys(gapAnalysis[key].paths).length > 3 && ( - - + Share this anyalysis + + + )} + + + + + + {gapAnalysis && ( + <> + {Object.keys(gapAnalysis).map((key) => ( + + + + {getDocumentDisplayName(gapAnalysis[key].start, true)}{' '} + - More Links (Total: {Object.keys(gapAnalysis[key].paths).length}) - - - {Object.values(gapAnalysis[key].paths) - .sort((a, b) => a.score - b.score) - .slice( - GetStrongPathsCount(gapAnalysis[key].paths), - Object.keys(gapAnalysis[key].paths).length - ) - .map((path) => { - let segmentID = gapAnalysis[key].start.id; - return ( - - - {getDocumentDisplayName(path.end, true)} ( - - {GetStrength(path.score)}:{path.score} - - ){' '} - - - - - } - > - - {getDocumentDisplayName(gapAnalysis[key].start, true)} - {path.path.map((segment) => { - const { text, nextID } = GetSegmentText(segment, segmentID); - segmentID = nextID; - return text; - })} - - - - - ); - })} - - - )} - {Object.keys(gapAnalysis[key].paths).length === 0 && No links Found} - - - ))} - - - )} + + + + + + {Object.values(gapAnalysis[key].paths) + .sort((a, b) => a.score - b.score) + .slice(0, GetStrongPathsCount(gapAnalysis[key].paths)) + .map((path) => GetResultLine(path, gapAnalysis, key))} + {Object.keys(gapAnalysis[key].paths).length > 3 && ( + + + More Links (Total: {Object.keys(gapAnalysis[key].paths).length}) + + + {Object.values(gapAnalysis[key].paths) + .sort((a, b) => a.score - b.score) + .slice( + GetStrongPathsCount(gapAnalysis[key].paths), + Object.keys(gapAnalysis[key].paths).length + ) + .map((path) => GetResultLine(path, gapAnalysis, key))} + + + )} + {Object.keys(gapAnalysis[key].paths).length === 0 && No links Found} + + + ))} + > + )} + + ); }; diff --git a/application/prompt_client/prompt_client.py b/application/prompt_client/prompt_client.py index 86fe6ea6a..f7de7bc82 100644 --- a/application/prompt_client/prompt_client.py +++ b/application/prompt_client/prompt_client.py @@ -175,6 +175,7 @@ def generate_embeddings( ) # cls.cre_embeddings[id] = embedding + class PromptHandler: def __init__(self, database: db.Node_collection) -> None: self.ai_client = None
- {getDocumentDisplayName(gapAnalysis[key].start, true)}{' '} - - - -
+ {getDocumentDisplayName(gapAnalysis[key].start, true)}{' '} + - More Links (Total: {Object.keys(gapAnalysis[key].paths).length}) - - - {Object.values(gapAnalysis[key].paths) - .sort((a, b) => a.score - b.score) - .slice( - GetStrongPathsCount(gapAnalysis[key].paths), - Object.keys(gapAnalysis[key].paths).length - ) - .map((path) => { - let segmentID = gapAnalysis[key].start.id; - return ( - - - {getDocumentDisplayName(path.end, true)} ( - - {GetStrength(path.score)}:{path.score} - - ){' '} - - - - - } - > - - {getDocumentDisplayName(gapAnalysis[key].start, true)} - {path.path.map((segment) => { - const { text, nextID } = GetSegmentText(segment, segmentID); - segmentID = nextID; - return text; - })} - - - - - ); - })} - - - )} - {Object.keys(gapAnalysis[key].paths).length === 0 && No links Found} -