[INCUBATOR-37] magnolia-openai-automations: Request to "Generate SEO Metadata" Returns 401 Created: 07/Jul/23  Updated: 18/Jul/23  Resolved: 18/Jul/23

Status: Closed
Project: Incubator
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Brian Schweigler Assignee: Sebastian Geschke
Resolution: Resolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Magnolia 6.2.35 (Java 11)


Attachments: PNG File image-2023-07-07-16-50-52-650.png     PNG File image-2023-07-07-16-56-47-599.png     File open-ai-generate-title.webm     HTML File request-openai    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Date of First Response:
Work Started:

 Description   

Steps to reproduce

  1. OPENAI saved under Module Version 1.0.1 with valid apiKey saved under `/modules/openai-automations@apiKey` according to https://docs.magnolia-cms.com/openai-automations/index.html#_ai_powered_seo_metadata_field
  2. Button is displayed and clickable:
  3. a
  4. Upon clicking it a 401 response is returned, with the payload sent as follows: request-openai, a POST Request to /.rest/openai-completions with referer (your.mgnl.environment)/author/.resources/openai-automations/webresources/openai-seo-metadata/field.html
  1. This then result in a continous looping "loading icon".

 

 

Expected results

Upon clicking the button, the request should fill in the specified fields.

Actual results

401 Response and no content returned (or call outgoing)

 

Is there a step that we missed in the setup of this incubator module?

We assumed that since have the dependency in the pom (following the documentation), a valid api key and the field in the dialog, that it should work.

 

Thanks for your help in this manner!

  • Brian from fastforward websolutions


 Comments   
Comment by Sebastian Geschke [ 17/Jul/23 ]

Hi bschweigler could you please update to the latest version 1.0.2 of magnolia-openai-automations. The base config.yaml was missing in prior versions so the decoration was not used. Also note that the key must reside on the config node and not on the node of the module in config workspace (in case the configuration was done in JCR) - The correct path in this case would be `/modules/openai-automations/config@apiKey`.

Comment by Brian Schweigler [ 17/Jul/23 ]

Hey @sgeschke, thanks for your response.

The api key is now set correctly as you specified, we are also using the latest version 1.0.2.

 

I have a dialog as follows for page properties:

form: 
  implementationClass: info.magnolia.ui.javascript.form.FormViewWithChangeListener
  properties: 
    title: 
      $type: textField
      i18n: true
    navigationTitle: 
      $type: textField
      i18n: true
    windowTitle: 
      $type: textField
      i18n: true
    keywords: 
      $type: textField
      i18n: true
      rows: 3
    aiSeoMetadata: 
      $type: aiSeoMetadataGenerator
      label: AI SEO Metadata
      parameters: 
        titleField: title
        metaDescriptionField: description
        ogDescriptionField: ogDescription
        metaKeywordsField: keywords
    description: 
      $type: textField
      i18n: true
      rows: 5

  layout: 
    $type: tabbedLayout
    tabs: 
      tabMain: 
        fields: 
          - name: title
          - name: navigationTitle
          - name: windowTitle
      tabMeta: 
        fields: 
          - name: keywords
          - name: description
          - name: aiSeoMetadata
 

I then tried to generate something for the titleField, but it seems to always transmit `undefined`. Here's a video to better show what I mean: 

open-ai-generate-title.webm

 

Is there another step we are missing?
So far, it's also not popping up under https://platform.openai.com/account/usage, so it could be that the request is still not reaching OpenAI.

 

Thanks for your help so far und e schöne Tag!

  • Brian Schweigler from fastforward websolutions

 

Comment by Sebastian Geschke [ 18/Jul/23 ]

Good Morning bschweigler
please note also the updated settings for 1.0.2 (https://git.magnolia-cms.com/projects/INCUBATOR/repos/openai-integrations/browse/samples/openai-automations-dev-samples/dialogs/pages/home.yaml#28).

Your configuration should look like that:

    aiSeoMetadata:       
      $type: aiSeoMetadataGenerator
      label: AI SEO Metadata
      parameters:         titleField: title
        metaDescriptionField: description
        metaKeywordsField: keywords
        metaDataFields:           title: Title
          metaDescription: Description
          metaKeywords: Meta keywords

You could also try and test the OpenAI rest client in the rest client app.

 

Comment by Brian Schweigler [ 18/Jul/23 ]

Had another look at the logs and can see that the tokens did arrive at OpenAi (they charged for it), so it is safe to assume that the API key and module itself is set up correctly.

 

Since it returned undefined though, there must be a problem in how I passed the data for the `titleField` or the dialog configuration itself.

 

Edit: Saw that your response came at the same time I was writing mine, will have a look!

Comment by Brian Schweigler [ 18/Jul/23 ]

Okay, can confirm that it works now.

Likely because the updated settings were missed.

 

 

Thanks for your time Sebastian and have a lovely day.
(Issue can be resolved / closed for now, solution was module update once new version released and correcting dialog structure).

Comment by Sebastian Geschke [ 18/Jul/23 ]

Resolution:

  • Module updated to newest version
  • Corrected dialog structure
Generated at Mon Feb 12 02:15:21 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.