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

TAN-3812 Authoring assistance prototype #10341

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open

Conversation

EdwinKato
Copy link
Contributor

No description provided.

@cl-dev-bot
Copy link
Collaborator

cl-dev-bot commented Feb 13, 2025

Warnings
⚠️

The changelog is empty. What should I put in the changelog?

⚠️ The branch name contains no Jira issue key (case-sensitive)
Messages
📖 Notion issue: TAN-3812
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 8f245c0

@sebastienhoorens sebastienhoorens changed the title Frontend authoring prototype TAN-3812 Authoring assistance prototype Feb 19, 2025
Copy link

def duplicate_inputs_response(authoring_assistance_response)
service = SimilarIdeasService.new(authoring_assistance_response.idea)
service.upsert_embedding!
threshold = 0.4
Copy link
Contributor

Choose a reason for hiding this comment

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

We will try to find a way to return only ideas that are "sufficiently" similar next week.

return false if body_description.blank?

html = multiloc_service.t(body_description)
Nokogiri::HTML(html).text
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to compare if the results are better when stripping HTML or when keeping HTML.

def execute(phase, **options)
super.merge(
'Project title' => @multiloc_service.t(phase.project.title_multiloc),
'Project description' => Nokogiri::HTML(@multiloc_service.t(phase.project.description_multiloc)).text, # TODO: Deal with content builder layouts
Copy link
Contributor

Choose a reason for hiding this comment

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

Keeping this as TODO as Simon is currently working on a solution for this (see https://go-vocal.slack.com/archives/C016C2EHURY/p1740047548222469).


let(:user) { create(:super_admin) }

post 'web_api/v1/ideas/:idea_id/authoring_assistance_responses' do
Copy link
Contributor

Choose a reason for hiding this comment

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

As agreed, I didn't spend time on testing all cases for the prototype. What could have been tested still otherwise:

  • Non-super-admins are not authorized.
  • Case when regenerate is true.
  • Case when creating the first response.
  • Check if created activity is logged.
  • CustomFreePromptService.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think for sanity I think you should just add one other test to ensure that non-super-admins cannot access this endpoint. It's quite important that while it is experimental that there is no back door to it IMO

@sebastienhoorens sebastienhoorens marked this pull request as ready for review February 21, 2025 13:09
end

def analyze!
duplicate_inputs_thread = start_thread { duplicate_inputs_response(_1) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I had a chat with Koen around this today. We agreed that this is fine for the prototype, but for the feature we'll expose to the users we need to be careful and should probably consider a polling or pushing mechanism instead of a simple POST request.

Copy link
Contributor

@sebastienhoorens sebastienhoorens left a comment

Choose a reason for hiding this comment

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

All looks good to me on the frontend side. I'm just wondering if we need to add translations to Crowdin.


import fetcher from 'utils/cl-react-query/fetcher';

import areaKeys from './keys';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, this has nothing to do with areas right?

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 just the name you've given here to the default export from keys.ts - maybe cut and paste from somewhere else? Should just be able to rename this to authoringAssistanceKeys - it'll make more sense then!

@@ -0,0 +1,30 @@
// This code is a prototype for input authoring. Clean-up will follow after the prototype phase.

import { defineMessages } from 'react-intl';
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is a prototype that is only exposed to super admins, I wonder if we should bother translators with this? Could it make sense to just always use this in English? Or is this a very bad idea? 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, think we can merge without getting translations done - once it's on master then the strings will appear in crowdin and will likely get translated anyway. But they don't need to be done before merging. The prompt only works in english anyway - is that right?

Copy link
Contributor

@sebastienhoorens sebastienhoorens Feb 26, 2025

Choose a reason for hiding this comment

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

It should still return responses if you write the custom free prompt in another language, but perhaps it won't work that well, and the language of the response would be less predictable.

isLoading,
} = useAddAuthoringAssistance();
const promptData = authoringResponse?.data;
const similarIdeaIds =
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't fully understand how you can already access this data if the request didn't happen yet?

<%= input_text %>
</content>

<%= custom_free_prompt %>
Copy link
Contributor

Choose a reason for hiding this comment

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

@kogre It would probably be valuable to have your feedback on the prompt as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to be able to tweak the top prompt A human user...etc through the browser too to see what difference that makes. Maybe later if we're not seeing good results

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 this idea! If we need to do more experimenting, it could be interesting to try this.

Copy link
Contributor

@jamesspeake jamesspeake left a comment

Choose a reason for hiding this comment

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

Generally looks good (as a prototype) and is well separated from any impact on the rest of the application so I think we can merge and start trying on production. A few little comments - main one is to add one more test for non-super-admins.

Looking through this generally though, I stand by my comments about trying to bring more of this functionality together centrally for future releases - particularly some of the core methods that currently sits in Analysis and gets pulled into multiple other engines. That'll probably take a bit of co-ordinating with Koen and others though

<%= input_text %>
</content>

<%= custom_free_prompt %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to be able to tweak the top prompt A human user...etc through the browser too to see what difference that makes. Maybe later if we're not seeing good results

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you updating a single use rake file? Maybe this file is not single use and should be moved?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. At first, it was indeed intended to be used just once. But now we need it again for the prototype, and perhaps we'll need it again for i1: similar ideas. I'll move it out of single_use and added this as a discussion point for the next weekly meeting.


let(:user) { create(:super_admin) }

post 'web_api/v1/ideas/:idea_id/authoring_assistance_responses' do
Copy link
Contributor

Choose a reason for hiding this comment

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

I think for sanity I think you should just add one other test to ensure that non-super-admins cannot access this endpoint. It's quite important that while it is experimental that there is no back door to it IMO


import fetcher from 'utils/cl-react-query/fetcher';

import areaKeys from './keys';
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 just the name you've given here to the default export from keys.ts - maybe cut and paste from somewhere else? Should just be able to rename this to authoringAssistanceKeys - it'll make more sense then!


import messages from './messages';

const AIInsights = ({ ideaId }: { ideaId: string }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be tempted to name this AuthoringAssistanePrototype instead so it's quite clear for now

@@ -0,0 +1,30 @@
// This code is a prototype for input authoring. Clean-up will follow after the prototype phase.

import { defineMessages } from 'react-intl';
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, think we can merge without getting translations done - once it's on master then the strings will appear in crowdin and will likely get translated anyway. But they don't need to be done before merging. The prompt only works in english anyway - is that right?

@@ -0,0 +1,5 @@
class AuthoringAssistanceResponsePolicy < ApplicationPolicy
def create?
user&.active? && user.super_admin?
Copy link
Contributor

Choose a reason for hiding this comment

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

As a prototype is it also worth checking the feature flag here on the backend, so we know it's only ever invoked on platforms we want it to be? Too much maybe?

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