-
Notifications
You must be signed in to change notification settings - Fork 74
(EAI-1149, EAI-1259) Updates to user message front matter #892
Conversation
packages/mongodb-chatbot-server/src/processors/addCustomData.ts
Outdated
Show resolved
Hide resolved
| const originToLabelRules = ORIGIN_RULES.filter( | ||
| (rule) => rule.label !== undefined | ||
| ); | ||
| originToLabelRules.forEach((rule) => { | ||
| if (parsedCustomData.originCode === rule.code) { | ||
| frontMatter.client = rule.label as string; | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logically this seems correct, but i suspect there's a more efficient way to do this without the filter, forEach, and casting with as string.
for instance, i think you could precompute a map of originCodeLabels, where it's like:
interface OriginCodeLabels {
[code: string]: string // the label
}
// ex:
const originCodeLabels = {
GEMINI_CODE_ASSIST: "Gemini Code Assist",
VSCODE: "MongoDB VS Code extension"
}
// you can compute the above with `ORIGIN_RULES.reduce(...)`
then, in this location update your code to be:
const maybeOriginLabel = originCodeLabels[parsedCustomData.originCode]
if (maybeOriginLabel) {
frontMatter.client = maybeOriginLabel
}| } | ||
|
|
||
| // Some origin codes have a label to add to the front matter | ||
| const originToLabelRules = ORIGIN_RULES.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add test(s) for this new behavior
mongodben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good, small back 2 u
Co-authored-by: Ben Perlmutter <90647379+mongodben@users.noreply.github.com>
packages/chatbot-server-mongodb-public/src/processors/formatUserMessageForGeneration.ts
Outdated
Show resolved
Hide resolved
mongodben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm w/ small suggestion
Co-authored-by: Ben Perlmutter <90647379+mongodben@users.noreply.github.com>
Jira:
Changes