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

Product Creation with AI: update prompt to generate 3 options #13258

Conversation

pmusolino
Copy link
Member

Closes: #13108

Description

This PR addresses issue #13108, which is part of the "Product Creation with AI: v2 - Milestone 1" (#13103). The goal is to refine the product creation prompt to yield three options for both the product name and description while ensuring compatibility with the existing product creation flow.

Changes include:

  • Defining a new prompt structure that can provide three variations of names and descriptions.
  • Validating that the new prompt structure does not disrupt other parts of the product creation process.
  • Allowed AIProduct model to work with the previous and new flow, to store multiple name and description options.
  • Max tokens limit now is 4000.

In the course of this update, I led to the decision to avoid duplicating the AIProduct model and related code as originally planned in the issue. Instead, I updated the existing AIProduct model to contain arrays for names and descriptions. This approach simplifies the transition and future code maintenance, and it will require just removing 3 lines of legacy code (marked with TODO) in the future.

Additionally, while working on the new prompt, I encountered token limitations in the ChatGPT responses, where the finish_reason was set to length. This indicated that the responses were being cut off due to the max_tokens limit. To resolve this, I have manually set the max_tokens parameter to 4000, which aligns with the capabilities of GPT-4o and ensures complete responses. This change will require a corresponding update on the Android client to accommodate the larger token count. More context here pe5sF9-2UY

Testing

  1. Test that the new flow works as expected.
  2. Open Wormholy, and make sure the JSON response contains 3 product titles and 3 product descriptions.
  3. Disable the productCreationAIv2M1 feature flag, and make sure the previous AI flow works as before.

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@pmusolino pmusolino added type: enhancement A request for an enhancement. type: task An internally driven task. feature: add/edit products Related to adding or editing products. labels Jul 5, 2024
@pmusolino pmusolino added this to the 19.5 milestone Jul 5, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 5, 2024

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr13258-26eb2c3
Version19.4
Bundle IDcom.automattic.alpha.woocommerce
Commit26eb2c3
App Center BuildWooCommerce - Prototype Builds #9920
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@selanthiraiyan selanthiraiyan self-assigned this Jul 8, 2024
Copy link
Contributor

@selanthiraiyan selanthiraiyan left a comment

Choose a reason for hiding this comment

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

The product generation works as described. The code changes look good to me. 🎉

I left a comment about the newly added requirement to generate three options for the short description field. I am preapproving the PR as this can worked in a separate PR.

return ["name": "The name of the product, written in the language with ISO code ```\(language)```",
"description": "Product description of around 100 words long in a ```\(tone)``` tone, "
return ["names": "An array of strings, containing three different names of the product, written in the language with ISO code ```\(language)```",
"descriptions": "An array of strings, each containing three different product descriptions of around 100 words long each in a ```\(tone)``` tone, "
+ "written in the language with ISO code ```\(language)```",
"short_description": "Product's short description, written in the language with ISO code ```\(language)```",
Copy link
Contributor

Choose a reason for hiding this comment

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

Internal - p1720090796407329-slack-C03L1NF1EA3

We decided to add the "Short description" field to the product preview screen. Hence, we need to ask the three options for the short_description field 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.

I logged a subtask here. I will work on this.

@@ -125,7 +125,7 @@ public extension Product {
tags: [ProductTag]) {
self.init(siteID: siteID,
productID: 0,
name: aiProduct.name,
name: aiProduct.names.first ?? "",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker, and we can add it in a future PR:

I think we should add another helper method to init a Product with a custom selected name, description and shortDescription. We can use the new custom init method to pass the user selected/typed name, description and shortDescription.

Networking/Networking/Remote/GenerativeContentRemote.swift Outdated Show resolved Hide resolved
@pmusolino pmusolino enabled auto-merge July 8, 2024 06:15
@pmusolino pmusolino merged commit 44d13b6 into trunk Jul 8, 2024
22 checks passed
@pmusolino pmusolino deleted the issue/13108-update-ai-prompt-to-generate-3-options-for-product-name-and-description branch July 8, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: add/edit products Related to adding or editing products. type: enhancement A request for an enhancement. type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update prompt to generate 3 options
3 participants