Open stprasst opened 1 year ago
Hi,
i try the usage example and got
foreach() argument must be of type array|object, null given
in this line :
$answer = $bard->getAnswer('Hello');
Idk what is the problem from your code, I send you this code.
<?php
require './vendor/autoload.php';
use KhaiPhan\Google\Bard;
header("Content-Type: text/plain");
session_start();
$message = 'images of cat';
$cookie = 'WghOI**********-*******.';
$i = array();
if (isset($_SESSION['i'])) {
$i = $_SESSION['i'];
}
$ai = new Bard($cookie, $i);
$response = $ai->getAnswer($message);
$session = array (
'conversation_id' => $response['conversation_id'],
'response_id' => $response['response_id'],
'choice_id' => $response['choice_id'],
'request_id' => $response['request_id'],
'session_id' => $response['session_id']
);
$_SESSION['i'] = $session;
var_dump($response);
Hi how to make it conversational?
Hi how to make it conversational?
according to the code i sent above, i used PHP session to save the conversation data, bard will continue the conversation after each new question to create new conversation just remove $i or set session_id, conversation_id,... value to null
$ai = new Bard($cookie);
$i = array (
'conversation_id' => null,
'response_id' => null,
'choice_id' => null,
'request_id' => null,
'session_id' => null
);
Im using it as an api for facebook chatbot, each thread is different conversation
Im using it as an api for facebook chatbot, each thread is different conversation
you can use cache or database to save conversation
Hi, i try the usage example and got foreach() argument must be of type array|object, null given
in this line : $answer = $bard->getAnswer('Hello');