Creating Views via ChatGPT and natural language

Created on 12 April 2023, about 2 years ago
Updated 4 May 2023, almost 2 years ago

Problem/Motivation

Microsoft released a video of copilot in excel. https://www.youtube.com/watch?v=I-waFp6rLc0

Can we build something similar in Drupal so that someone can type a prompt in natural language asking for a report or view and ChatGPT will write the YAML and import it directly into Drupal giving someone a view.

Proposed resolution

I think we can build a module that allows someone to write a prompt of the view that they would like. Drupal would automatically send ChatGPT the field structure and perhaps an existing view and ChatGPT would provide a YAML file back.

Below is a video I've done of my current research trying to solve this problem but in summary:

TODO (I'll post it on slack but its unlisted for now so ask me directly if you want it but need to double check before I post it publically)

  • A basic view costs about $0.024 to create through the API
  • An extra field costs about $0.08 to add and therefore whole views might costs between $1-10. Not cheap but if this works not terrible either.
  • ChatGPT produces ok YAML. I created a basic view of a list of articles with just a title and wanted it to add the body field. ChatGPT4 called the field name "body_view" instead of "body" and ChatGPT 3 got the field correct but called the table for the field "node_field_data" instead of "node__body". So its close.
  • I've started a simple module to handle the import
  • I don't know how we'd get Drupal the structure

Remaining tasks

  • Create a module that can send a prompt to openai and import YAML
  • Test and optimise the ideal prompt to send around the user submitted stuff
  • Find out how and what information we send to chat gpt so that is knows the structure of the site it is building a view for
  • Handle splitting the messages into section and combining it given that the yaml will be well over the 2048 token limit
  • Explore training ChatGPT to make it provide more useful views
  • Ability to edit an existing view instead of creating a new one

User interface changes

  • Button to import view from chat gpt
  • Prompt for user to tell chatgpt what kind of view it wants and then directs them to the view

API changes

Data model changes

🌱 Plan
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom yautja_cetanu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024