Skip to content
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

prompt activation frontend #12626

Open
wants to merge 76 commits into
base: develop
Choose a base branch
from
Open

Conversation

emilia-friedberg
Copy link
Member

@emilia-friedberg emilia-friedberg commented Dec 4, 2024

WHAT

Build out the frontend and controller endpoints to make it possible to activate a prompt.

WHY

This is what will allow the curriculum team to pick which LLM Prompt actually gets used to serve feedback.

HOW

Pretty straightforward React and Rails code! We also changed the styling of some other components to make room for the new columns.

Screenshots

Screenshot 2024-12-04 at 12 55 18 PM Screenshot 2024-12-04 at 12 55 13 PM Screenshot 2024-12-04 at 12 55 04 PM Screenshot 2024-12-04 at 12 54 53 PM

Notion Card Links

https://www.notion.so/quill/Activate-A-Winning-Prompt-146d42e6f941806dabc3e98fae6fadf2?pvs=4

What have you done to QA this feature?

Tested locally and on staging; Jamie will also be QAing on staging.

PR Checklist Your Answer
Have you added and/or updated tests? (The answer should mostly be 'YES'. If you answer 'NO', please justify.)
Have you deployed to Staging? (Possible answers: YES, Not yet - deploying now!, NO - non-app change, NO - tiny change)
Self-Review: Have you done an initial self-review of the code below on Github?

@emilia-friedberg emilia-friedberg marked this pull request as ready for review December 4, 2024 20:21
Copy link
Contributor

@anathomical anathomical left a comment

Choose a reason for hiding this comment

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

This looks good to me. I've got a couple of style suggestions, but they're all take-or-leave items, so you could ship this as-is.

@@ -61,7 +61,7 @@ export const Checkbox = ({ label, mode=LIGHT, onClick, state, selected, id, }: c
return (
<div className="checkbox-container">
{renderCheckbox()}
<label className={labelClass} htmlFor={checkboxId}>{label}</label>
{label ? <label className={labelClass} htmlFor={checkboxId}>{label}</label> : null}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is purely stylistic, and I don't even know if it's better, but thoughts on using

{label && <label className={labelClass} htmlFor={checkboxId}>{label}</label>}

instead of a ternary? That may not actually do exactly the same thing, but I feel like I've seen us use that pattern in a couple of places, and I personally find it slightly more readable. But, again, it's just a style thing, so not a big deal either way.

Comment on lines 82 to 83
expect(screen.getByText(/Prompt Name/i)).toBeInTheDocument();
expect(screen.getByText(/Dataset 1.0/i)).toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these values hard-coded into the template, or are they based on some of the data defined in activated_llm_prompts? If they're hard-coded, leaving this as-is makes sense, but if they're based on values in the input object, I think it would be clearer to have them referenced by variable name. Such as

expect(screen.getByText(/${activatedPromptsResponse. activated_llm_prompts[0]. trial.llm_prompt.name}/i)).toBeInTheDocument();

Or maybe something more readable, but something that makes it clear that the input should impact the output.

@@ -84,6 +84,12 @@ def active_llm_prompt
.first
end

def active_activated_llm_prompt
activated_llm_prompts
.merge(Evidence::ActivatedLLMPrompt.active)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the use of merge here to apply a scope.

end

it 'includes associated trial data' do
trial = create(:evidence_research_gen_ai_trial, llm_prompt:)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is purely stylistic, so take or leave it. I prefer to use let or let! whenever a create is called, but you can't call let inside an it block, so I'd structure this with a context wrapper.

context 'with associated trial data' do
  let!(:trial) { create(:evidence_research_gen_ai_trial, llm_prompt:) }

  it 'includes associated trial data' do
    ... # same code
  end
end


it 'includes associated trial data' do
trial = create(:evidence_research_gen_ai_trial, llm_prompt:)
activated_llm_prompt.update!(llm_prompt:)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this doe anything? The create call on line 24 looks like it already sets llm_prompt to the same value as this.

end

it 'sets other prompts to inactive if active is true' do
existing_prompt = create(:evidence_activated_llm_prompt, llm_prompt:, prompt:, active: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, take or leave style thing, but I like create calls in let which means you'd need a context wrapper.

Base automatically changed from feat/update-evidence-cms-to-support-activity-types to develop December 5, 2024 13:42
Copy link
Member

@brendanshean brendanshean left a comment

Choose a reason for hiding this comment

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

So exciting to see some of these final pieces! Awesome work

end
end

def prompt
Copy link
Member

Choose a reason for hiding this comment

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

I would make this method private since I don't think we need it exposed outside the controller.. In general, I try to make the only public methods in a controller correspond to specified routes.

Copy link
Member

@eadams17 eadams17 left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks for putting this together

attribute: 'llmPromptName',
width: '72px',
headerClassName: 'center-content',
rowSectionClassName: 'center-content allow-wrap',
Copy link
Member

Choose a reason for hiding this comment

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

Just an idea... I think at some point down the road, we should probably update Backpack to include these different class instances so we have them all documented somewhere

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.

4 participants