PHP code example of ianrothmann / langserve-php-client
1. Go to this page and download the library: Download ianrothmann/langserve-php-client 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/ */
ianrothmann / langserve-php-client example snippets
use IanRothmann\LangServePhpClient\RemoteRunnable;
$runnable = new RemoteRunnable('http://localhost:8100/summarize/');
$runnable = new RemoteRunnable('http://localhost:8100/summarize/');
$runnable->authenticateWithBearerToken('your-token'); //Add a Bearer token header with the token
$runnable->authenticateWithXToken('your-token'); //Add the X-Token header, if you implemented it according to the LangServe Examples with X-Token
$runnable->addHeader('Key', 'Value'); //Add any other header
$input = ['text' => 'Hello, this is something for you to summarize'];
$response = $runnable->invoke($inputs);
dd($response->getRunId(), $response->getContent(), $response->getTokenUsage(), $response->getData(), $response->toJson());
$input = [['text' => 'Hello, this is something for you to summarize'],['text' => 'Hello, this is more text for you to summarize']];
$batchResponse = $runnable->batch($inputs);
foreach ($batchResponse->getResponses() as $response) {
//$response->getRunId(),
//$response->getContent(),
//$response->getTokenUsage());
}
$result = $runnable->stream($input, function($response) {
//Do something with the content here
$response->getContent();
});
// Finally, this gives you the full content after everything has been streamed:
$result->getContent();
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.