-
Notifications
You must be signed in to change notification settings - Fork 74
(EAI-995): add guardrail #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 - few small things but nothing blocking
packages/chatbot-server-mongodb-public/src/processors/makeMongoDbReferences.test.ts
Outdated
Show resolved
Hide resolved
packages/chatbot-server-mongodb-public/src/processors/makeMongoDbReferences.test.ts
Outdated
Show resolved
Hide resolved
test("should return guardrail results", async () => { | ||
expect(await userMessageMongoDbGuardrail(mockInput)).toMatchObject({ | ||
metadata: { type: "valid" }, | ||
rejected: false, | ||
reason: mockGuardrailResult.reasoning, | ||
} satisfies InputGuardrailResult); | ||
}); |
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.
Just making sure you only intended for there to be one test case in this file
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.
yea, just a smoke test
const name = "extract_mongodb_metadata"; | ||
const description = "Extract MongoDB-related metadata from a user message"; |
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.
nit: Is there a reason to have these as separate/top level variables? We only use them in once spot and they're pretty generic names. It isn't super clear unless you scroll down that they're the name & description of the specific guardrail.
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.
doubt it. can adjust
@@ -192,18 +200,44 @@ export function makeGenerateResponseWithSearchTool< | |||
} | |||
try { | |||
// Transform filtered references to include the required title property |
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.
Not sure if this comment is actually meant for the streamed references on the next line?
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.
i think was vestige. no longer needed
* (EAI-988): Refactor `GenerateResponse` for tool call support (#687) * refactor GenerateRespose * Clean up imports * consolidate generate user prompt to the legacy file * update test config imports * Fix broken tests * (EAI-989): Refactor verified answers to wrap `GenerateResponse` (#688) verified answer generate response Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * handle streaming * separate generateresponse * typo fix --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * (EAI-990): Refactor search as a tool (#705) * refactor GenerateRespose * Clean up imports * consolidate generate user prompt to the legacy file * update test config imports * Fix broken tests * get started * nominally working generate res w/ search * small refactors * aint pretty but fully functional * hacky if more functional * more hack * tools * functional if not pretty * Add processing * working tool calling * making progress * keepin on * Clean config * working e2e * update model version * Remove no longer used stuff * decouple search results for references and whats shown to model * fix scripts build errs * fix broken tests * update default ref links * fix broken tests * Apply suggestions from code review Co-authored-by: Nick Larew <nick.larew@mongodb.com> * revert default reference links * adding missing test --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> Co-authored-by: Nick Larew <nick.larew@mongodb.com> * (EAI-992): Remove `ChatLlm` (#751) * refactor GenerateRespose * Clean up imports * consolidate generate user prompt to the legacy file * update test config imports * Fix broken tests * get started * nominally working generate res w/ search * small refactors * aint pretty but fully functional * hacky if more functional * more hack * tools * functional if not pretty * Add processing * working tool calling * making progress * keepin on * Clean config * working e2e * update model version * Remove no longer used stuff * decouple search results for references and whats shown to model * fix scripts build errs * remove ChatLlm * lite fixes * Remove stub --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * (EAI-993): deprecate framework (#752) * refactor GenerateRespose * Clean up imports * consolidate generate user prompt to the legacy file * update test config imports * Fix broken tests * get started * nominally working generate res w/ search * small refactors * aint pretty but fully functional * hacky if more functional * more hack * tools * functional if not pretty * Add processing * working tool calling * making progress * keepin on * Clean config * working e2e * update model version * Remove no longer used stuff * decouple search results for references and whats shown to model * fix scripts build errs * fix broken tests * deprecation * build out docs following last week convo * clean up spec + contact * fix merge funk * docs updates --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * (EAI-1071): Fix broken Atlas OpenAPI ingest (#765) * update to fix broken test * Update packages/ingest-mongodb-public/src/sources/snooty/snootyAstToOpenApiSpec.ts --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * (EAI-995): add guardrail (#755) * refactor GenerateRespose * Clean up imports * consolidate generate user prompt to the legacy file * update test config imports * Fix broken tests * get started * nominally working generate res w/ search * small refactors * aint pretty but fully functional * hacky if more functional * more hack * tools * functional if not pretty * Add processing * working tool calling * making progress * keepin on * Clean config * working e2e * update model version * Remove no longer used stuff * decouple search results for references and whats shown to model * fix scripts build errs * fix broken tests * update default ref links * fix broken tests * input guardrail refactor * guardrail works well * simpler validity metric * add guardrail to server * add next step todo * llm refusal msg * remove TODO comment * merge fix * fix unnec changes * NL feedback --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * fix type in text * (EAI-991 & EAI-1050): Evaluate and clean up retrieval as a tool (#757) * refactor GenerateRespose * Clean up imports * consolidate generate user prompt to the legacy file * update test config imports * Fix broken tests * get started * nominally working generate res w/ search * small refactors * aint pretty but fully functional * hacky if more functional * more hack * tools * functional if not pretty * Add processing * working tool calling * making progress * keepin on * Clean config * working e2e * update model version * Remove no longer used stuff * decouple search results for references and whats shown to model * fix scripts build errs * fix broken tests * update default ref links * fix broken tests * input guardrail refactor * guardrail works well * simpler validity metric * add guardrail to server * add next step todo * llm refusal msg * remove TODO comment * evals on new architecture * Get urls in a way that supports verified answers * dont eval on retrieved elems if no context * Cleaner handling * update trace handling * update trace handling * undo git funk * handle undefined case * Fix tracing test --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> * remove console logs + redunancies --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com> Co-authored-by: Nick Larew <nick.larew@mongodb.com>
Jira: https://jira.mongodb.org/browse/EAI-995
Changes
InputGuardrail
formatNotes