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

Relocate OpenAI model parameters to dotAI App params #29281

Closed
Tracked by #28813
victoralfaro-dotcms opened this issue Jul 18, 2024 · 7 comments · Fixed by #29420, #29236, #29517 or #29533
Closed
Tracked by #28813

Relocate OpenAI model parameters to dotAI App params #29281

victoralfaro-dotcms opened this issue Jul 18, 2024 · 7 comments · Fixed by #29420, #29236, #29517 or #29533

Comments

@victoralfaro-dotcms
Copy link
Contributor

victoralfaro-dotcms commented Jul 18, 2024

Parent Issue

#28813

User Story

As a Java developer, I want to be able to relocate the hardcoded OpenAI models in our code to the dotAI application, specifically as parameters for each field that conform a model: model names, tokens per minute, API per minute, max number of tokens, and if it's a completion model flag. The changes will include:

  • The removal of hardcoded models from the code
  • Adding necessary fields to dotAI.yml Application descriptor file
  • Making all the code adjustments for OpenAI client logic to take the model from this new source instead of code and specify it in the OpenAI request
  • Changes to dotAI App UI need to be added in order for the app form validates that the models are valid by looking them up in HTTP request to OpenAI models endpoint.

Consider that Model Names field is actually a comma delimited list of models.
This will need to happen for both text and image models and changes in the dotAI.yml file will result in having UI changes in the Apps portlet that QA will see when testing.

Acceptance Criteria

  • All hardcoded OpenAI models are removed from the code.
  • dotAI.yml Application descriptor file includes the fields: model names, tokens per minute, API per minute, max number of tokens, and completion model flag.
  • The OpenAI client logic retrieves model parameters from dotAI.yml instead of the code.
  • Adjustments are made for both text and image models.
  • Successful end-to-end testing confirming the application uses models defined in dotAI.yml.

dotCMS Version

master

Proposed Objective

Core Features

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

to_define

Assumptions & Initiation Needs

  • dotAI.yml format and structure are predefined and agreed upon.
  • Development environment is set up with access to the necessary OpenAI services.
  • All stakeholders are informed about the change and have agreed upon the migration plan.

Quality Assurance Notes & Workarounds

  • Comprehensive testing to ensure no regressions occur due to the removal of hardcoded models.
  • Validate the dotAI.yml configurations are correctly read and applied in various scenarios.
  • Start up a dotCMS instance with a starter that includes recent AI-generation changes to SEO for Blog content type
  • Make sure valid license is provided
  • Configure dotAI app with a valid API key and a model for text, image and embeddings: gpt-3.5-turbo-16k, dall-e-3 and text-embedding-ada-002 respectively. Add the following at the Auto Index Content Config field:
{
    "aiBlog": "blog"
}
  • Open a Blog content, go to the SEO tab and verify that AI content is generated by hitting the button for SEO metadata field
  • Go to Dev Tools -> dotAI, at Manage Embeddings/Indexes tab, at Index Name specify: aiBlog, at Content to Index by Query: field specify: +contentType:blog and build index based on that. Verify that there are index created/updated.
@dsilvam
Copy link
Contributor

dsilvam commented Aug 1, 2024

IQA: Failed
Updating the model at dotAI App level for the system host is not down streaming the changes to demo.dotcms.com, leaving an old config for the latter.

Last edit on dotAI App for SYSTEM_HOST
Image

Internal Models for demo.dotcms.com not updated with lasts updates to SYSTEM_HOST
Image

github-merge-queue bot pushed a commit that referenced this issue Aug 7, 2024
)

Avoiding sending requests when there is no OpenAI API key to use.
Putting it in a centralized place.
Adjusting a couple of tests to reflect this logic change.
Also since from the provided logs there was an Jackson parsing error,
new fields were added to "DTO" class to consider the error field.
Initially when implementing IT for AI classes, I took the approach of
mocking or building an `AppConfig` class on the flight instead of
creating an `dotAI` app secrets so config classes can be created out of
them. Just as it happens at production code. I'm introducing some
changes to correct this as well.
victoralfaro-dotcms added a commit that referenced this issue Aug 13, 2024
@bryanboza bryanboza added LTS : Next Ticket that will be added to LTS Next LTS Release Shortlisted of issues that will be included in the upcoming LTS labels Aug 13, 2024
@erickgonzalez erickgonzalez removed LTS : Next Ticket that will be added to LTS Next LTS Release Shortlisted of issues that will be included in the upcoming LTS labels Aug 13, 2024
@josemejias11
Copy link
Contributor

josemejias11 commented Aug 13, 2024

QA Comment

List of test cases created for this card. #29567 (comment)

@bryanboza
Copy link
Member

bryanboza commented Aug 13, 2024

Note from QA:

These changes could affect part of the AI functionality, which is why we need to split the work for the QA regression.

Based on this, we estimate that a quick regression is needed in some key identified areas. @josemejias11 has already shared a CSV file with the tests that need to be covered by the team. Please coordinate the distribution, @dsilvam .
Anyways here is the direct link: https://shorturl.at/dov6V

Additionally, we will focus on the regression of the sub-actions to ensure everything continues working normally and that nothing was affected by the changes.

Once all the mentioned work is done, we'll be ready to release. Thanks for your help, team!

victoralfaro-dotcms added a commit that referenced this issue Aug 13, 2024
…reak the tests when any of AI API url or AI API key are missing. Clean the default values for model names and max tokens are now required.
victoralfaro-dotcms added a commit that referenced this issue Aug 13, 2024
victoralfaro-dotcms added a commit that referenced this issue Aug 13, 2024
…reak the tests when any of AI API url or AI API key are missing. Clean the default values for model names and max tokens are now required.
victoralfaro-dotcms added a commit that referenced this issue Aug 13, 2024
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
…reak the tests when any of AI API url or AI API key are missing. Clean the default values for model names and max tokens are now required.
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
…d 'type' instead of just a list os strings. Throwing exceptions when AppConfig.isEnabled() is false to break the tests when any of AI API url or AI API key are missing. Clean the default values for model names. Added better logging at key places when interacting with OpenAI provider. Tests were added/updated.

noop
victoralfaro-dotcms added a commit that referenced this issue Aug 14, 2024
…d 'type' instead of just a list os strings. Throwing exceptions when AppConfig.isEnabled() is false to break the tests when any of AI API url or AI API key are missing. Clean the default values for model names. Added better logging at key places when interacting with OpenAI provider. Tests were added/updated.
github-merge-queue bot pushed a commit that referenced this issue Aug 15, 2024
Returning available models as object that includes 'name' and 'type'
instead of just a list os strings. Throwing exceptions when
AppConfig.isEnabled() is false to break the tests when any of AI API url
or AI API key are missing. Clean the default values for model names.
Added better logging at key places when interacting with OpenAI
provider. Tests were added/updated.
@hmoreras hmoreras self-assigned this Aug 16, 2024
@hmoreras
Copy link
Contributor

hmoreras commented Aug 16, 2024

IQA Findings:

  • The properties model name, tokens per minute, API per minute, max number of tokens, and completion model flag are being taken from the config fields and sent in the request with the new values.
  • I enabled the property com.dotcms.ai.debug.logging with true to see the requests in the server log.
  • The configurations are being respected. The demo.dotcms.com is taking precedence over the system host when configured.
Screenshare.-.2024-08-16.3_35_54.PM.mp4
  • Same precedence is happening with the Image Model Names.

@josemejias11
Copy link
Contributor

Approved: Tested on trunk_bffd903, Docker, macOS 14.5, FF v126.0.1

@josemejias11 josemejias11 added QA : Approved and removed Blocker This issue is blocking the release labels Aug 20, 2024
@dsilvam dsilvam closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment