OpenAI GPT

Introduction

GPT, the latest and largest language model developed by OpenAI, has received a lot of media attention for its remarkable capabilities in natural language processing. With its advanced algorithms and massive training capabilities, GPT has the ability to generate text that reads as if it had been created by a human. It can complete tasks and even create new content.

This plugin allows you to use OpenAI's GPT AI language model for advanced metadata processing by using GPT responses to populate one or more metadata fields, based on data stored in another field.

Requirements

To use the plugin you must have an account with OpenAI. For testing purposes free trial credentials may be used, but be aware that such accounts will have strict usage limits.

Initial configuration

  1. Enable the plugin by navigating to Admin->System->Plugins and clicking on 'Activate' next to 'OpenAI API GPT integration' - under the Asset Processing section
  2. Click on 'Options', add your OpenAI API key to the plugin setup page and click on 'Save configuration'

WARNING: It is strongly advised to not change any of the other plugin options here as it will affect the behaviour of all the metadata fields that have been configured.

Configuring metadata fields

To use the plugin you need to add a text prompt on the output metadata field and select an input field for the source data. ResourceSpace will then pass the prompt along with the data to GPT and populate the output field with the response. This will be updated whenever the value in the source field changes.

  1. Decide on the metadata field that you want to use to contain the output. Note that category tree and data fields cannot be configured.
  2. Navigate to the metadata field configuration page and click on the advanced section
  3. Scroll down and under the 'GPT Prompt' section, enter the prompt in natural language, describing what you want GPT to do e.g. 'List no more than 10 keywords for the purposes of metadata indexing and searching.'
  4. Under 'GPT Input Field', select the field that contains the source data
  5. Click the Save button

Example - summarising text

OpenAI gpt metadata field 2

Alternative example - using the same field for the source, but this time requesting keywords to be extracted

Using the plugin

Once the fields have been configured that's all there is to it. When data is entered into the source field ('document extract' in the example above), ResourceSpace will send this data to GPT, along with the prompt instructing it what to do. The response will then be saved into the configured field. Watch the video above to see this in action.

Possible uses of the plugin

The integration of GPT into ResourceSpace provides for many possible ways to help you improve and automate metadata processing tasks. A few examples include:

  • Automated title/summary generation: ResourceSpace can now be configured to generate concise and descriptive titles and summaries from large blocks of text, such as extracted from a PDF file, subtitles from a video file, or pulled in from a Collection Management System or Product Information Management system.
  • Keyword extraction: ResourceSpace can now automatically extract meaningful keywords from a block of text, providing a list of relevant keywords for searching, categorization, and more. The list of keywords can be made more specific based on the prompt provided.
  • Automatic categorization: GPT integration can be used to automatically categorize digital assets based on their content, saving time and ensuring consistent and accurate categorization. Automated categorization can also generate custom reports and statistics for valuable insights into the types and distribution of digital assets.

Populating existing resources

If you already have resources with data in the source field when you enable the plugin you can run the process_existing.php script to update the target field. These steps need to be performed on the ResourceSpace server by a system administrator.

  1. On the server, navigate to the ResourceSpace web root and then into 'plugins/openai_gpt/pages/'
  2. Run the process_existing.php script as below
    php process_existing.php [OPTIONS...]
    
    OPTIONS SUMMARY
    
    --help          Display help text and exit
    
    -c
    --collection    Collection ID. Only resources in the specified collections
                    will be updated
    
    -f
    --field         ID of metadata field to update
    
    -o
    --overwrite     Overwrite existing data in the field? Note that if overwrite 
                    is enabled and the input field contains no data the target 
                    field will be cleared. False by default
    
    EXAMPLES
    
    php process_existing.php --field=18 --collection=56
    php process_existing.php --field=18 --collection=56 --overwrite
    php process_existing.php -f 18 -c56 -c77
    php process_existing.php -f 18 -c56 -c77 -o
    

Tips and troubleshooting

  • Text fields being populated with JSON: If you have configured a text field to use the GPT response and the input field is of a fixed list type you may see the text output being formatted as JSON e.g. ["warship", "battle", "invasion"]. To fix this simply indicate in your prompt how you want the output to be returned - i.e. instead of 'Provide 3 keywords' you could write 'Provide 3 keywords, returned as a comma separated list'. This should mean your data gets returned in a more readable form i.e. 'warship, battle, invasion'