Skip to content

Commit aa8b620

Browse files
committed
OpenConceptLab/ocl_issues#2311 | using prompt invoke
1 parent 6f4b246 commit aa8b620

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/components/map-projects/MapProject.jsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ const MapProject = () => {
160160
const [candidatesScore, setCandidatesScore] = React.useState({recommended: 99, available: 70})
161161
const [filters, setFilters] = React.useState({})
162162
const [AIModel, setAIModel] = React.useState('')
163+
const [promptTemplate, setPromptTemplate] = React.useState(false)
163164

164165
const abortRef = React.useRef(false);
165166

@@ -2458,6 +2459,7 @@ const MapProject = () => {
24582459
setAIModel(defaultModel?.id)
24592460
return
24602461
}
2462+
setPromptTemplate(response.data)
24612463
setAIModel(find(_models, {id: response.data.default_model})?.id || defaultModel?.id)
24622464
})
24632465
}
@@ -2494,25 +2496,22 @@ const MapProject = () => {
24942496
console.error('AI ASSISTANT is not enabled for you.')
24952497
return false
24962498
}
2497-
let _candidates = flatten(map(filter(selectedAlgoIds, algoId => !['ocl-ciel-bridge', 'ocl-scispacy-loinc'].includes(algoId)), algoId => find(allCandidatesRef.current[algoId], c => c.row?.__index === __index)?.results || []))
2498-
let _bridgeCandidates = find(allCandidatesRef.current['ocl-ciel-bridge'], c => c.row?.__index === __index)?.results || []
2499-
let _scispacyCandidates = find(allCandidatesRef.current['ocl-scispacy-loinc'], c => c.row?.__index === __index)?.results || []
2500-
if(isNumber(__index) && repoVersion && !analysis[__index] && [..._candidates, ..._bridgeCandidates, ..._scispacyCandidates]?.length > 0) {
2499+
let _candidates = flatten(map(selectedAlgoIds, algoId => find(allCandidatesRef.current[algoId], c => c.row?.__index === __index)?.results || []))
2500+
if(isNumber(__index) && repoVersion && !analysis[__index] && _candidates?.length > 0) {
25012501
markAlgo(__index, 'recommend', 0)
25022502
let rowData = prepareRow(__row, true, true)
25032503
const payload = {
2504-
project: getProjectMetadata(),
2505-
row: rowData.row,
2506-
metadata: rowData.metadata,
2507-
candidates: _candidates,
2508-
bridgeCandidates: _bridgeCandidates,
2509-
scispacyCandidates: _scispacyCandidates,
2510-
model: AIModel,
2504+
variables: {
2505+
project: getProjectMetadata(),
2506+
row: rowData.row,
2507+
metadata: rowData.metadata,
2508+
candidates: [..._candidates.map(c => omit(c, '_source'))],
2509+
}
25112510
}
25122511
const service = APIService.new()
25132512
service.URL = AI_ASSISTANT_API_URL
25142513
try {
2515-
const response = await service.appendToUrl('/match/$recommend/').post(payload)
2514+
const response = await service.appendToUrl(`/prompts/${promptTemplate.key}/invoke/`).post(payload)
25162515
let timestamp = moment().toDate()
25172516
if(response?.detail) {
25182517
markAlgo(__index, 'recommend', -2)

0 commit comments

Comments
 (0)