1. Go to this page and download the library: Download amohamed/jsconnector 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/ */
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Amohamed\JSConnector\Facades\JSConnector;
class LangChainController extends Controller
{
public function chat(Request $request)
{
$input = $request->input('message');
// We use the post method on the JSConnector facade
$response = JSConnector::post('chat', ['input' => $input]);
// Then we return the response from the langchainjs service
return response()->json(['response' => $response]);
}
}