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

feat(headless): improve Generate Answer documentation #4069

Closed
wants to merge 2 commits into from

Conversation

lbergeron
Copy link
Contributor

@lbergeron lbergeron commented Jun 10, 2024

SVCC-3877

This PR clarifies how to set the contentFormat attribute for the Generated Answer controller.

@developer-experience-bot
Copy link
Contributor

developer-experience-bot bot commented Jun 10, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 204.8 204.8 0
commerce 291.9 291.9 0
search 372.3 372.3 0
insight 352.4 352.4 0
product-listing 266.9 266.9 0
product-recommendation 170.8 170.8 0
recommendation 217.8 217.8 0
ssr 365.1 365.1 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
product-recommendation 0 10 0
product-listing 0 13 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
product-recommendation : missing SSR support
product-listing : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@@ -23,6 +23,8 @@ export interface GeneratedResponseFormat {
answerStyle: GeneratedAnswerStyle;
/**
* The content formats that are supported for rendering the answer. If no values are provided, `text/plain` is used.
* The answer is generated using the first format supported by the front-end component, from left to 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 seems a tad silly since there are only two supported formats at the moment, one of which will, if I understand correctly, always be supported 😅

In essence, you can/should either:

  1. leave this empty, or
  2. pass ['text/markdown', 'text/plain']

because:

  • passing ['text/plain', 'text/markdown'] is silly (text/plain will always be used)
  • passing ['text/markdown'] is not recommended (you should add the fallback)
  • passing ['text/plain'] is useless (it's the same as not passing anything)

Still, granted that we may eventually add support for additional formats, I understand why using an array makes sense.

That being said, this makes me wonder: instead of recommending to always include text/plain as the last value in the array as a fallback, should we just fallback to text/plain regardless?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still, granted that we may eventually add support for additional formats, I understand why using an array makes sense.

At some point new formats will have to be supported, but they are not yet known.

That being said, this makes me wonder: instead of recommending to always include text/plain as the last value in the array as a fallback, should we just fallback to text/plain regardless?

We can do that, but I feel it would be confusing to specify contentFormat: ['text/markdown'] and receive an answer in text/plain. The current behavior makes it pretty clear. If you specify ['text/markdown'] and the model can't generate an answer for that format, then the request fails. If you specify ['text/markdown', 'text/plain'], then you expect to receive text/markdown or text/plain.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also find it odd to have to specify the fallback format. It feels stranger to request one of the two formats than to request one format and have the default fallback used if the specified format is unavailable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The contentFormat attribute is not meant to request a specific format. It represents the capabilities of the front-end component. It is the platform that decides which format to return.

It was implemented that way so the feature rollout could be controlled from the platform.

Copy link
Contributor

Choose a reason for hiding this comment

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

It still seems to me like it would be less error-prone to fallback to text/plain even if it's not specified as the last value in the array.

As it is, contentFormat is optional, and yet, if I understand correctly, the requests will fail when no value is specified. Given that we have a strong opinion of what he fallback format should be (i.e., It is recommended to include text/plain as the last value in the array to act as a fallback format), I think we might as well just fallback to this value, and explain the behavior in the documentation.

Unless there is a reason why someone would actually want requests to fail... but this seem dubious to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, sorry for the delay.

As it is, contentFormat is optional, and yet, if I understand correctly, the requests will fail when no value is specified.

To be clear, the request will fail if contentFormat is explicitely set to an empty array.

Unless there is a reason why someone would actually want requests to fail... but this seem dubious to me.

Ok, I can modify it so we can always fallback to text/plain.

@@ -23,6 +23,8 @@ export interface GeneratedResponseFormat {
answerStyle: GeneratedAnswerStyle;
/**
* The content formats that are supported for rendering the answer. If no values are provided, `text/plain` is used.
* The answer is generated using the first format supported by the front-end component, from left to right.
* The request fails when no matching format is found. It is recommended to include `text/plain` as the last value in the array to act as a fallback format.
Copy link
Contributor

Choose a reason for hiding this comment

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

when no matching format is found

found by what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the first match between formats supported by the front-end component, and formats supported by the model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fbeaudoincoveo I was trying to keep it short, and I felt that adding too much would make it more confusing. Do you have a suggestion to make it clearer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the super late reply, @lbergeron !

How about:

The request fails when none of the specified formats are supported by the front-end component or by the model.

@lbergeron
Copy link
Contributor Author

Closing this PR and will open a new one to add the automatic fallback to text/plain and update the documentation.

@lbergeron lbergeron closed this Jul 23, 2024
@louis-bompart louis-bompart deleted the feat/SVCC-3877 branch August 26, 2024 16:36
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.

3 participants