GithubHelp home page GithubHelp logo

xgen's Introduction

XGen SDK PHP

Official PHP SDK of the XGen API.


API Documentation : https://thomas-15.gitbook.io/generator/

Requirements

  • PHP version 7.2 and later
  • XGen API Key, contact me

Installation

You can install the library via Composer. Run the following command:

composer require gmulti/xgen

To use the library, use Composer's autoload:

require_once __DIR__. '/vendor/autoload.php';

Example

Usage with data sample

<?php

require_once __DIR__ . '/vendor/autoload.php';

use XGen\Client;
use XGen\XGen;

try {
    $xgen = new XGen();
    $xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-1.json');
    $xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-2.json');
    $xgen->addSourceFromFile(__DIR__ . '/vendor/gmulti/xgen/data/source.json');

    $client = new Client('API_KEY');
    $result = $client->getResource('generate')->postGenerateWithXGen($xgen);
    var_dump($result);
    // array (size=1)
    //   'text' => string 'Dans le cadre de la 2ème journée, Angers SCO accueille Olympique Lyonnais' (length=75)
    
} catch (\Exception $e) {
}

Load source from URL

<?php

require_once __DIR__ . '/sdk/vendor/autoload.php';

use XGen\Client;
use XGen\XGen;

try {
    $xgen = new XGen();
    $xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-1.json');
    $xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-2.json');
    $xgen->addSourceFromUrlJson('https://apigenerator.gmulti.now.sh/v1/example-data/source');

    $client = new Client('API_KEY');
    $text = $client->getResource('generate')->postGenerateWithXGen($xgen);
    var_dump($result);
    // array (size=1)
    //   'text' => string 'Dans le cadre de la 2ème journée, Angers SCO accueille Olympique Lyonnais' (length=75)
} catch (\Exception $e) {
}

About

xgen is guided and supported by Thomas Deneulin.

xgen's People

Contributors

gmulti avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.