Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.
Prev Previous commit
Add prompt template to make it simple for user
Now user's prompt is used only to add details to main prompt,
respecting labels in the config and constraining format from model.
  • Loading branch information
hlomzik committed Dec 18, 2023
commit d3b5fd37ecbbf9a0ca6012db5a85b351854ed57d
10 changes: 9 additions & 1 deletion src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,15 @@ export default types
async function onAssistantPrompt(prompt) {
self.setFlags({ awaitingSuggestions: true });

const result = await self.events.invoke('assistantPrompt', self, prompt);
const tags = [...self.annotationStore.selected.names.values()];
const labels = tags.find(t => t.type === 'labels').children.map(l => l._value);

const fullPrompt = `Provide json containing list for each of the following entities:
${labels.join(', ')} mentioned in the text. No explanations and assumptions, please.
Provide empty lists in the json for the entities that are not required.
Respect this constraint and request: ${prompt}`;

const result = await self.events.invoke('assistantPrompt', self, fullPrompt);

self.annotationStore.selected.deserializeResults(result[0]);
self.annotationStore.selected.updateObjects();
Expand Down