1. Go to this page and download the library: Download tallesairan/oobapi-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tallesairan / oobapi-php example snippets
use Airan\OobApi\ApiClient;
$baseUrl = 'http://example.com'; // Replace with your API base URL
$apiClient = new ApiClient($baseUrl);
/**
* Generate text based on a given prompt and optional parameters.
*
* @param string $prompt The input prompt for text generation.
* @param array $params Optional parameters to customize text generation.
* @return array An array containing the generated text and additional data.
*/
public function generate($prompt, $params = []) {
// Implementation details...
}
/**
* Chat with the API to generate interactive text based on user input and history.
*
* @param string $userInput The user's input text.
* @param string $history The conversation history.
* @param array $params Optional parameters to customize the chat.
* @return array An array containing the generated response and additional data.
*/
public function chat($userInput, $history, $params = []) {
// Implementation details...
}
/**
* Stop the text generation stream.
*
* @return array An array containing the response data.
*/
public function stopStream() {
// Implementation details...
}
use Airan\OobApi\StreamClient;
$webSocketBaseUrl = 'ws://example.com'; // Replace with your WebSocket base URL
$streamClient = new StreamClient($webSocketBaseUrl);
/**
* Generate text using WebSocket streaming based on a given prompt and optional parameters.
*
* @param string $prompt The input prompt for text generation.
* @param array $params Optional parameters to customize text generation.
* @return array An array containing the generated text and additional data.
*/
public function stream($prompt, $params = []) {
// Implementation details...
}
/**
* Chat using WebSocket streaming to generate interactive text based on user input and history.
*
* @param string $userInput The user's input text.
* @param string $history The conversation history.
* @param array $params Optional parameters to customize the chat.
* @return array An array containing the generated response and additional data.
*/
public function chatStream($userInput, $history, $params = []) {
// Implementation details...
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.