Add GenAi Models to AI Tutor Tester - #60278
Conversation
| for (let i = 0; i < data.length; i++) { | ||
| if (selectedEndpoint === 'llm-guard') { | ||
| getLLMGuardToxicity(data[i]); | ||
| } else if (genAIEndpointIds.includes(selectedEndpoint)) { |
There was a problem hiding this comment.
If you use a concurrency method like Promise.allSettled, you can do something like:
const getAIResponses = async () => {
setResponsesPending(true);
const responsePromises = data.map(async (row) => {
if (selectedEndpoint === 'llm-guard') {
return getLLMGuardToxicity(row);
} else if (genAIEndpointIds.includes(selectedEndpoint)) {
return getGenAIResponses(row);
} else {
return askAITutor(row);
}
});
const results = await Promise.allSettled(responsePromises);
setResponsesPending(false);
};
I think it makes how you're handling the asynchronicity a little more explicit 🤷♀️
It also allows you to easily filter for successes and failures, if desired.
// Count successful responses
const successfulResponses = results.filter(result => result.status === 'fulfilled').length;
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled
| status: 'ok', | ||
| timestamp: new Date().getTime(), | ||
| }; | ||
| const temperature = row.temperature ? row.temperature : 0.8; |
There was a problem hiding this comment.
Nit: Could we make this a constant and add a comment that it's the default temperature used in levelbuilder?
| aiCustomizations, | ||
| aichatContext | ||
| ); | ||
| row.aiResponse = genAIResponse.messages[1].chatMessageText; |
There was a problem hiding this comment.
Should we add optional chaining here?
| id: 'gen-ai-mistral-pirate-7b', | ||
| name: 'Mistral Pirate + Webpurify', | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
Non-blocking nit: I'd consider making this a little more "constant-y" (is that a word? 🙃), a la...
// Non-Gen AI endpoint constants
const AI_TUTOR_ENDPOINT = 'ai-tutor';
const LLM_GUARD_ENDPOINT = 'llm-guard';
// Gen AI endpoint constants
const GEN_AI_MISTRAL_BASE = 'gen-ai-mistral-7b-inst-v01';
const GEN_AI_ARITHMO = 'gen-ai-arithmo2-mistral-7b';
const GEN_AI_BIOMISTRAL = 'gen-ai-biomistral-7b';
const GEN_AI_KAREN_CREATIVE = 'gen-ai-karen-creative-mistral-7b';
const GEN_AI_PIRATE = 'gen-ai-mistral-pirate-7b';
const endpoints = [
{
id: AI_TUTOR_ENDPOINT,
name: 'AI Tutor + Webpurify',
},
{
id: LLM_GUARD_ENDPOINT,
name: 'LLM Guard',
},
];
const genAIEndpoints = [
{
id: GEN_AI_MISTRAL_BASE,
name: 'Mistral Base + Webpurify',
},
{
id: GEN_AI_ARITHMO,
name: 'Mistral Arithmo + Webpurify',
},
{
id: GEN_AI_BIOMISTRAL,
name: 'Mistral Biomistral + Webpurify',
},
{
id: GEN_AI_KAREN_CREATIVE,
name: 'Mistral Karen + Webpurify',
},
{
id: GEN_AI_PIRATE,
name: 'Mistral Pirate + Webpurify',
},
];
...
|
Nice work! 🎉 Just a couple small comments. |
This PR adds the GenAI Models as endpoint options for the AI Tutor Tester.
Supported columns now update based on the endpoint selected.
Links
CT-964 partial
Similar to #60224
Testing story
I played around with a few combinations of uploaded columns + the GenAi models with small datasets and things seem to be working. Given that this is in an internal tool, I'm going to be relying on @samantha-code to let me know if things aren't working as expected for her 😁
Here's an example with the Pirate 🏴☠️ model:
tester_genai_models.mov
Deployment strategy
You need to be a levelbuilder with ai tutor access permission to access the Tester. Additionally, you need to be in the gen ai pilot to be able to hit the GenAi endpoints so this feels well protected from the public; no concerns about when/how it's deployed.
Follow-up work
There are more details in the linked Jira ticket. The next tasks are to get call LLMGuard in Python rather then the EC2 instance and then then get LLMGuard working with the GenAi models.
PR Checklist: