Download the PHP package sourceability/portal without Composer

On this page you can find all versions of the php package sourceability/portal. 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 portal

sourceability/portal

A CLI and PHP Library that helps getting structured data out from GPT.

Given a JSON Schema, GPT is perfectly capable of outputting JSON that conforms to the schema. This approach enables GPT to be used programmatically for non-conversational use cases.

For example, before parsing a user uploaded CSV, you could ask GPT to map its headers to the ones your code supports:

⚠️ Note that this library is experimental, and the API will change.

You are welcome to contribute by submitting issues, ideas, PRs, etc 🙂.

Installation

Trying out

You can try out YAML spells with docker:

Symfony support

The library includes a Symfony bundle.

Add the bundle to config/bundles.php:

Then define the OPENAI_API_KEY=sk-XXX environment variable, for example in .env.local.

You can also configure the bundle:

You can invoke your service spells using their FQCN with the cast command (don't forget the quotes):

You can also define a short name with the #[AutoconfigureSpell] attribute:

And invoke the spell with bin/console portal:cast Categorize

Static YAML

You can invoke portal with the path to a .yaml with the following format:

Spell

The Spell interface is the main way to interact with this library.

You can think of a Spell as a way to create a function whose "implementation" is a GPT prompt:

A spell is defined by its Input/Output types TInput and TOutput. So for example, a spell that accepts a number and returns an array of string, would use Spell<int, string<string>>.

getSchema

With the getSchema you return a JSON Schema:

Make sure to leverage the description and examples properties to give GPT more context and instructions:

Note that you can also leverage libraries that define a DSL to build schemas:

getPrompt

The getPrompt method is where you describe the desired behaviour:

transcribe

Finally, you can transform the json decoded GPT output into your output type:

getExamples

The getExamples method returns 0 or many inputs examples. This is very useful when iterating on a prompt.

Casting

Once you've done all that, you can cast try your spell examples:

Or invoke your spell with the PHP Api:

$portal->transfer

If you don't need the Spell getExamples and transcribe, you can use transfer:

CLI

You can pass your own JSON example to the portal cli:

Use -v, -vv, -vvv to print more information like the prompts or the OpenAI API requests/responses.

ApiPlatformSpell

The ApiPlatformSpell uses API Platform's to generate the JSON Schema but also to deserialize the JSON result.

You must implement the following methods:

The following are optional:

You can then use the #[ApiProperty] attribute to add context to your schema:

Examples

See ./examples/.


All versions of portal with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
composer-runtime-api Version *
guzzlehttp/promises Version ^1.5
nyholm/psr7 Version ^1.5
php-http/cache-plugin Version ^1.0
php-http/logger-plugin Version ^1.0
sourceability/openai-client Version ^0.3.4
symfony/cache Version ^6.0
symfony/console Version ^6.0
symfony/http-client Version ^6.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 sourceability/portal contains the following files

Loading the files please wait ....