Download the PHP package assistant-engine/open-functions-core without Composer

On this page you can find all versions of the php package assistant-engine/open-functions-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package open-functions-core

Open Functions Core

Open Functions provide a standardized way to implement and invoke functions for tool calling with large language models (LLMs). They encapsulate both the generation of structured function definitions and the actual function execution within a unified interface. At the heart of this framework is the AbstractOpenFunction class, which standardizes:

Together, these components simplify the process of integrating tool calling capabilities into your application, reducing boilerplate and ensuring that both the function definitions and their invocations follow a clear, predictable standard.

Table of Contents

Features

Installation

Install the package via Composer:

Basic Concepts

AbstractOpenFunction

The AbstractOpenFunction class is the foundation for all Open Functions. Extend this class to implement your functions. It:

Example: HelloWorld Open Function Using FunctionDefinition and Parameter

In this example:

FunctionDefinition & Parameter

These classes help build a JSON schema definition for your function:

OpenFunctionRegistry

The OpenFunctionRegistry is a centralized place to:

  1. Register one or more AbstractOpenFunction instances under a specific namespace (e.g., delivery, weather).
  2. Retrieve all aggregated function definitions.
  3. Execute a namespaced function call by name (e.g., delivery_orderProduct).

The registry also implements MessageListExtensionInterface, meaning it can automatically prepend a developer message about the registered namespaces if you add it as an extension in your MessageList.

Messages & MessageList

All conversation elements (user input, system instructions, developer instructions, tool/assistant responses) are represented by:

These are stored and managed in a MessageList, which can be converted to an array suitable for the OpenAI Chat API.

Usage Examples

Registering and Calling Functions

Below is a minimal example using the DeliveryOpenFunction and WeatherOpenFunction from the repository’s Examples folder. We will:

  1. Instantiate our Open Functions.
  2. Register them with a namespace in the OpenFunctionRegistry.
  3. Fetch their combined function definitions.
  4. Execute a test call locally using the executeFunctionCall method.

Using OpenAI PHP SDK to Call a Function

Suppose you have a conversation with a user, and you suspect that the user’s prompt will trigger a function call. With the OpenAI PHP SDK (or a similar library), you can provide function definitions and messages.

Below is an example (pseudo-code) of how you might call the OpenAI Chat Completions endpoint and let it auto-call a function:

Utilizing the Function Registry with OpenAI

In the above example, we manually provided the function definitions. Another approach is to let the OpenFunctionRegistry automatically insert a developer message about the namespaces. You do this by adding the registry as a MessageList extension:

When the toArray() method is called, the registry’s extension will run and prepend a developer message enumerating the available tool namespaces. That helps the model know which functions exist and are available.

Working with Responses

All function calls return a Response object, which contains:

A ResponseItem can be:

Example

If you call:

You might get:

Example Open Functions

DeliveryOpenFunction

See DeliveryOpenFunction.php for a real-world example. It demonstrates how to:

WeatherOpenFunction

See WeatherOpenFunction.php for an example that:

Contributing

We welcome contributions from the community! Feel free to submit pull requests, open issues, and help us improve the package.

License

This project is licensed under the MIT License. Please see License File for more information.


All versions of open-functions-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package assistant-engine/open-functions-core contains the following files

Loading the files please wait ....