Download the PHP package noah-medra/prompt-builder without Composer

On this page you can find all versions of the php package noah-medra/prompt-builder. 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?
noah-medra/prompt-builder
Rate from 1 - 5
Rated 1.00 based on 1 reviews

Informations about the package prompt-builder

PromptBuilder

PromptBuilder is a Laravel package that allows you to create and execute AI prompts in a flexible and structured way. This package enables you to generate dynamic queries, customize parameters, and manage conversation history to improve the relevance of responses.

Installation

Composer

To install PromptBuilder via Composer, run the following command:

Usage

Creating a PromptBuilder object

Start by instantiating a PromptBuilder object:

Defining the Driver (Processing Engine)

By default, PromptBuilder uses the OllamaDriver. If you want to use another driver, you can specify it using the driver() method.

Adding instructions (with Sub-Instructions and Conditions)

Instructions are rules or constraints you want to apply to the AI's generated response. These instructions can have sub-instructions or be condition-dependent. You can chain instructions infinitely and even create nested conditions.

Here is an example where instructions can contain sub-instructions, and conditional logic can be applied using the when() method.

Example with Instructions and Sub-Instructions:

In this example:

  1. Main instructions: The first two instructions introduce the financial history topic and explain the review process.
  2. Conditional instructions: The when() method checks a condition (in this case, true), and if true, additional sub-instructions are added (e.g., a summary of the financial history).

Adding dynamic parameters

You can pass custom parameters to your prompt with the withParams() method:

Defining a context

You can add additional context to guide the AI in generating the response.

Asking a question

You can ask a question that will be included in the final prompt.

Managing history

If you want the AI to use previous conversation history to provide more contextual responses, enable the useHistory() option.

Generating and retrieving the response

Once all instructions and parameters are defined, you can generate the prompt and obtain the AI's response by calling the getOutput() method:

Handling JSON responses

If you want the AI's response to be formatted as JSON, use the expectResponseFormat() method.

Driver: How It Works (Input/Output)

The Driver is responsible for handling the input (your prompt) and generating the output (the AI's response). Each driver implements the DriverInterface and provides a process() method that takes a BuilderInput object, processes the prompt, and returns a BuilderOutput.

For example, the OllamaDriver sends the prompt to a local Ollama service and receives the AI's response.

Here is an example of the OllamaDriver:

In this example:

  1. The process() method receives a BuilderInput object which contains the prompt text.
  2. The executePrompt() method sends the prompt to a remote API (Ollama) and receives the AI response.
  3. The response is returned as a BuilderOutput object.

Complete Example

Here is a complete example of how to use PromptBuilder:

Features

Customization

You can easily extend PromptBuilder by creating your own drivers or by customizing the PromptDriverInterface. To do this, simply create a class that implements the PromptDriverInterface and pass it to the driver() method.

Contributions

Contributions are welcome! If you have ideas to improve the package, feel free to submit an issue or a pull request.


All versions of prompt-builder with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version >=8.0
guzzlehttp/guzzle Version ^7.0
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 noah-medra/prompt-builder contains the following files

Loading the files please wait ...