This project is not covered by Drupal’s security advisory policy.

Perform Drupal operations with fluent language commands.

Introduction

The 'OpenAI Function Call' module integrates OpenAI's function calling capabilities into Drupal, offering a bridge for AI-enhanced functionalities.

This module provides a plugin system where each plugin represents a callable OpenAI function. This enables users to do complex tasks in collaboration with AI.

This module is currently for demonstration purposes only!

Features

Currently the module has only a few features that demonstrate the endless options possible with this approact.
For example:
- Get specific configuration values from the site (for example Site name)
- Set specific config values by prompting the AI.

Roadmap

  • Dedicated service to handle API calls to OpenAI with the function definitions
  • Chainable function calling where responses sent to ChatGPT
  • Implement different sources that the user can prompt from.
  • Make the module extendable by other modules. (hooks, events, etc.)
  • Provide more examples of basic tasks or actions

Post-Installation

1. Make sure your OpenAI api token is set.
2. Navigate to /admin/config/openai/openai-function-call

Try it!

Ask the ChatGPT prompt to find a new name for your site and rename it!

Example prompt: find a new name for this site that refers to animals and rename it to that
When the prompt is finished successfully, navigate to /admin/config/system/site-information and check your site name: Animalia
Or, you could just simply prompt: what is the current name of the site?

Extending

Here is an example plugin definition that can be passed to the ChatGPT functions API:


/**
 * The GetSiteName plugin definition.
 *
 * Returns the site name from config when required.
 *
 * @OpenAiFunction(
 *  id = "get_site_name",
 *  description = "Get the name of the drupal site",
 *  parameters = {
 *    "type" = "object",
 *    "properties" = {}
 *  }
 * )
 */
class GetSiteName extends OpenAiFunctionPluginBase {

  public function call($parameters) {
    $config = \Drupal::config('system.site');
    return $config->get('name');
  }

}

How OpenAI functions work?

https://platform.openai.com/docs/guides/function-calling
https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models
https://cookbook.openai.com/examples/how_to_call_functions_for_knowledge...

Supporting organizations: 
Project context

Project information

Releases