Skip to content

Commit 81ca08c

Browse files
authored
Fix role labels (#21)
* fix: Fix role labels * Add extra lines between operations * update confirm terms
1 parent 23b7aec commit 81ca08c

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

DEVELOP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@
7070
**Solution:** Either fine-tunning the content reading prompt to tell LLMs use correct tool params or
7171
include all content of any wikilinks along with the user query.
7272
- [x] The systemPrompts in the User-Defined command currently load content from wikilinks only one level (Need 2 levels to resolve content of wikilinks in the system prompt)
73+
- [ ] Double user messages in the actual generate.

src/lib/modelfusion/classifiers/intent.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,8 @@ export const intentClassifier = new PersistentEmbeddingSimilarityClassifier({
176176
'proceed',
177177
'cancel',
178178
'go ahead',
179-
'stop',
180179
'i agree',
181180
'i disagree',
182-
"that's correct",
183-
"that's incorrect",
184181
],
185182
},
186183
{

src/lib/modelfusion/extractions/contentReadingExtraction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const contentReadingSchema = z.object({
3232
.string()
3333
.nullable()
3434
.describe(
35-
`A short text to indicate that the content was found. Use {{number}} as a placeholder that will be replaced with an actual number later.
35+
`A short text to indicate that the content was found. MUST include the term {{number}} as a placeholder, for example: "I found {{number}}..."
3636
If the readType is "entire", leave it null.`
3737
),
3838
confidence: z.number().min(0).max(1).describe(confidenceFragment),

src/services/ConversationRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export class ConversationRenderer {
2626
/**
2727
* Formats role text based on the showPronouns setting
2828
*/
29-
private formatRoleText(role?: string, showLabel = false): string {
30-
if (!role || !showLabel || !this.plugin.settings.showPronouns) {
29+
private formatRoleText(role?: string, showLabel = this.plugin.settings.showPronouns): string {
30+
if (!role || !showLabel) {
3131
return '';
3232
}
3333

src/solutions/commands/handlers/ConfirmCommandHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ export class ConfirmCommandHandler extends CommandHandler {
174174
'create',
175175
'confirm',
176176
'proceed',
177+
'go ahead',
178+
'approve',
179+
'agree',
177180
// Vietnamese affirmative terms
178181
'có',
179182
'có nha',
@@ -193,6 +196,8 @@ export class ConfirmCommandHandler extends CommandHandler {
193196
'dont',
194197
'cancel',
195198
'stop',
199+
'reject',
200+
'disagree',
196201
// Vietnamese negative terms
197202
'không',
198203
'không nha',

src/solutions/commands/handlers/CreateCommandHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export class CreateCommandHandler extends CommandHandler {
171171
})}*`,
172172
artifactContent: createdNotes.join('\n\n'),
173173
command: 'create',
174-
role: 'System',
175174
lang,
176175
});
177176
}

src/solutions/commands/handlers/GenerateCommandHandler.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,24 @@ The response should be in natural language and not include the selection(s) {{st
151151
};
152152
}
153153

154-
await this.renderer.addGeneratingIndicator(title, t('conversation.generating'));
155-
156154
try {
155+
const messageId = await this.renderer.updateConversationNote({
156+
path: title,
157+
newContent: extraction.explanation,
158+
includeHistory: false,
159+
role: 'Steward',
160+
lang,
161+
});
162+
163+
await this.renderer.addGeneratingIndicator(title, t('conversation.generating'));
164+
157165
if ('updates' in extraction) {
158166
if (extraction.updates.length === 0) {
159167
return {
160168
status: CommandResultStatus.SUCCESS,
161169
};
162170
}
163171

164-
const messageId = await this.renderer.updateConversationNote({
165-
path: title,
166-
newContent: extraction.explanation,
167-
includeHistory: false,
168-
lang,
169-
});
170-
171172
if (messageId) {
172173
this.artifactManager.storeArtifact(title, messageId, {
173174
type: ArtifactType.CONTENT_UPDATE,
@@ -181,7 +182,6 @@ The response should be in natural language and not include the selection(s) {{st
181182
type: ArtifactType.CONTENT_UPDATE,
182183
})}*`,
183184
command: 'generate',
184-
role: 'System',
185185
lang,
186186
});
187187
}
@@ -220,13 +220,14 @@ The response should be in natural language and not include the selection(s) {{st
220220
...command,
221221
systemPrompts,
222222
},
223-
conversationHistory,
223+
conversationHistory: conversationHistory.slice(0, -1),
224224
errorCallback: async error => {
225+
logger.error('Error in contentGenerationStream', error);
226+
225227
if (error instanceof APICallError && error.statusCode === 422) {
226228
await this.renderer.updateConversationNote({
227229
path: title,
228230
newContent: `*Error: Unprocessable Content*`,
229-
role: 'System',
230231
});
231232
}
232233
},
@@ -269,9 +270,6 @@ The response should be in natural language and not include the selection(s) {{st
269270
}
270271
}
271272

272-
// We no longer generate summaries after every generate command
273-
// Summaries are now generated when users send follow-up queries in GeneralCommandHandler
274-
275273
return {
276274
status: CommandResultStatus.SUCCESS,
277275
};

src/solutions/commands/handlers/ImageCommandHandler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,11 @@ export class ImageCommandHandler extends CommandHandler {
8484
mediaType: 'image',
8585
});
8686

87-
// Add a System message with the artifact content
8887
const t = getTranslation(lang);
8988
await this.renderer.updateConversationNote({
9089
path: title,
9190
newContent: `*${t('common.artifactCreated', { type: ArtifactType.MEDIA_RESULTS })}*`,
9291
artifactContent: result.filePath,
93-
role: 'System',
9492
command: 'image',
9593
});
9694
}

src/solutions/commands/handlers/ReadCommandHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ export class ReadCommandHandler extends CommandHandler {
211211
path: title,
212212
newContent: `*${t('common.artifactCreated', { type: ArtifactType.READ_CONTENT })}*`,
213213
artifactContent: readingResults[0].blocks.map(block => block.content).join('\n\n'),
214-
role: 'System',
215214
command: 'read',
216215
});
217216
}

src/solutions/commands/handlers/SearchCommandHandler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,19 @@ export class SearchCommandHandler extends CommandHandler {
107107
.getText();
108108
message += `- ${t('search.folders')}: ${escapedFolders}\n`;
109109
}
110+
111+
// Add an extra newline between operations except for the last one
112+
if (index < queryExtraction.operations.length - 1) {
113+
message += '\n';
114+
}
110115
}
111116

112117
await this.renderer.updateConversationNote({
113118
path: title,
114119
newContent: message,
115120
command: 'search',
116121
includeHistory: false,
122+
role: 'Steward',
117123
});
118124

119125
// Check if the next command will operate on the search results
@@ -183,7 +189,6 @@ export class SearchCommandHandler extends CommandHandler {
183189
})}*`,
184190
artifactContent,
185191
command: 'search',
186-
role: 'System',
187192
});
188193
}
189194

0 commit comments

Comments
 (0)