Skip to content

Add GenAi Models to AI Tutor Tester - #60278

Merged
Erin007 merged 6 commits into
stagingfrom
eb-add-gen-ai-base-model-to-ai-tutor-tester
Aug 13, 2024
Merged

Add GenAi Models to AI Tutor Tester #60278
Erin007 merged 6 commits into
stagingfrom
eb-add-gen-ai-base-model-to-ai-tutor-tester

Conversation

@Erin007

@Erin007 Erin007 commented Aug 8, 2024

Copy link
Copy Markdown
Contributor

This PR adds the GenAI Models as endpoint options for the AI Tutor Tester.

Screenshot 2024-08-09 at 1 19 22 PM

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:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

Base automatically changed from eb-bulk-test-llm-gaurd to staging August 8, 2024 19:30
@Erin007 Erin007 changed the title add Mistral base to options Add GenAi Models to AI Tutor Tester Aug 9, 2024
@Erin007

Erin007 commented Aug 9, 2024

Copy link
Copy Markdown
Contributor Author

for (let i = 0; i < data.length; i++) {
if (selectedEndpoint === 'llm-guard') {
getLLMGuardToxicity(data[i]);
} else if (genAIEndpointIds.includes(selectedEndpoint)) {

@ebeastlake ebeastlake Aug 9, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@ebeastlake ebeastlake Aug 10, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add optional chaining here?

id: 'gen-ai-mistral-pirate-7b',
name: 'Mistral Pirate + Webpurify',
},
];

@ebeastlake ebeastlake Aug 10, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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',
  },
];

...

@ebeastlake

Copy link
Copy Markdown
Contributor

Nice work! 🎉 Just a couple small comments.

@Erin007
Erin007 requested a review from ebeastlake August 13, 2024 00:43
@Erin007
Erin007 merged commit 02ba687 into staging Aug 13, 2024
@Erin007
Erin007 deleted the eb-add-gen-ai-base-model-to-ai-tutor-tester branch August 13, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants