Skip to content

Commit c51fdc6

Browse files
committed
OpenConceptLab/ocl_issues#2311 | using new output
1 parent aa8b620 commit c51fdc6

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/components/map-projects/AICandidatesAnalysis.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import get from 'lodash/get'
2121
const AICandidatesAnalysis = ({ analysis, onClose, sx, isCoreUser }) => {
2222
const { t } = useTranslation();
2323
const [openDetails, setOpenDetails] = React.useState(false)
24+
let output = analysis?.output || analysis
2425

2526
const getModelName = () => {
2627
let model = analysis?.model || 'AI Model'
@@ -30,9 +31,9 @@ const AICandidatesAnalysis = ({ analysis, onClose, sx, isCoreUser }) => {
3031
}
3132

3233
const getRecommendationTitle = () => {
33-
let recommendation = analysis?.recommendation
34-
if(recommendation && analysis?.primary_candidate?.match_strength){
35-
recommendation += ` (${analysis.primary_candidate.match_strength})`
34+
let recommendation = output?.recommendation
35+
if(recommendation && output?.primary_candidate?.match_strength){
36+
recommendation += ` (${output.primary_candidate.match_strength})`
3637
}
3738
return recommendation
3839
}
@@ -55,10 +56,10 @@ const AICandidatesAnalysis = ({ analysis, onClose, sx, isCoreUser }) => {
5556
<>
5657
<Typography gutterBottom component='p' sx={{mb: 0, fontSize: 12, marginTop: '-2px'}}>
5758
{
58-
get(analysis, 'recommendation') &&
59+
get(output, 'recommendation') &&
5960
<span style={{fontWeight: 'bold', marginRight: '8px'}}>{getRecommendationTitle()}:</span>
6061
}
61-
{get(analysis, 'rationale.narrative') || get(analysis, 'rationale')}
62+
{get(output, 'rationale.narrative') || get(output, 'rationale')}
6263
</Typography>
6364
<Typography gutterBottom sx={{ color: 'text.secondary', fontSize: 13, mb: 0, textAlign: 'right' }}>
6465
{getModelName()}

src/components/map-projects/Candidates.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import SortIcon from '@mui/icons-material/Sort';
2727
import GroupIcon from '@mui/icons-material/Layers';
2828

2929
import find from 'lodash/find'
30-
import get from 'lodash/get'
3130
import isEmpty from 'lodash/isEmpty'
3231
import flatten from 'lodash/flatten'
3332
import values from 'lodash/values'
@@ -307,7 +306,7 @@ const Candidates = ({rowIndex, alert, setAlert, candidates, setShowItem, showIte
307306
let allCandidates = compact(rawResults)
308307
const isNoneLoaded = every(rawResults, r => r === null)
309308
const canFetchMore = allCandidates?.length > 0
310-
let AIRecommendedCandidateId = get(analysis, 'primary_candidate.concept_id')
309+
let AIRecommendedCandidateId = analysis?.output?.primary_candidate?.concept_id || analysis?.primary_candidate?.concept_id
311310
const algoStagesValue = values(omit(rowStage, 'recommend'))
312311
const areAlgoRun = uniq(algoStagesValue).length === 1 && algoStagesValue[0] === 1
313312
const { label } = getRowProgressLabel(rowStage, algosSelected);

src/components/map-projects/MapProject.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ const MapProject = () => {
17231723
const rowStateLabel = VIEWS[rowState].label
17241724
let concept = mapSelected[index]
17251725
let _repo = concept?.repo
1726-
const aiRecommendation = get(analysis, index)
1726+
const aiRecommendation = get(analysis, index)?.output || get(analysis, index)
17271727
const aiCandidate = get(aiRecommendation, 'primary_candidate')
17281728
const aiCandidateID = aiCandidate?.concept_id
17291729
const aiScore = compact([aiCandidate?.confidence_level, aiCandidate?.match_strength]).join(':')
@@ -2521,7 +2521,7 @@ const MapProject = () => {
25212521
}
25222522

25232523
markAlgo(__index, 'recommend', 1)
2524-
log({created_at: timestamp, action: 'AIRecommendation', description: get(response.data, 'rationale'), extras: {...response.data, model: find(AIModels, {id: AIModel})}}, __index)
2524+
log({created_at: timestamp, action: 'AIRecommendation', description: get(response.data, 'output.rationale') || get(response.data, 'rationale'), extras: {...response.data, model: find(AIModels, {id: AIModel})}}, __index)
25252525
setAnalysis(prev => ({...prev, [__index]: {...response.data, model: AIModel, timestamp: timestamp, user: user.username || user.id}}))
25262526
return true
25272527
} catch (err) {

0 commit comments

Comments
 (0)