FEAT_INTRO_CHAT&GEMINI
This commit is contained in:
parent
fd56103835
commit
3a1e3752b1
@ -46,6 +46,7 @@ $routes->get("frontend_content", "AppContentManagementController::frontend_conte
|
|||||||
|
|
||||||
// $routes->get('/', 'LoginController::index');
|
// $routes->get('/', 'LoginController::index');
|
||||||
$routes->get('/test', 'Home::index');
|
$routes->get('/test', 'Home::index');
|
||||||
|
$routes->get('/check_gemini', 'Home::check_Gemini');
|
||||||
$routes->get('/login', 'LoginController::index'); ///auth/google
|
$routes->get('/login', 'LoginController::index'); ///auth/google
|
||||||
$routes->get('/loginPos', 'LoginController::loginPos'); //login POS team
|
$routes->get('/loginPos', 'LoginController::loginPos'); //login POS team
|
||||||
$routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no
|
$routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no
|
||||||
|
|||||||
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use GeminiAPI\Client;
|
||||||
|
use GeminiAPI\Resources\ModelName;
|
||||||
|
use GeminiAPI\Resources\Parts\TextPart;
|
||||||
|
|
||||||
|
|
||||||
class Home extends PublicController
|
class Home extends PublicController
|
||||||
{
|
{
|
||||||
public function index(): string
|
public function index(): string
|
||||||
@ -28,4 +34,26 @@ class Home extends PublicController
|
|||||||
return $payload['a'] + $payload['b'];
|
return $payload['a'] + $payload['b'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function check_Gemini()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8';
|
||||||
|
// Initialize the Gemini client
|
||||||
|
$client = new Client($apiKey);
|
||||||
|
|
||||||
|
// Send a prompt to the Gemini Pro model
|
||||||
|
$response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent(
|
||||||
|
new TextPart('Write a short, creative story about a knight and a dragon.')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Display the generated text
|
||||||
|
$data['gemini_response'] = $response->text();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Handle any errors that occur during the API call
|
||||||
|
$data['gemini_response'] = 'An error occurred: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
print_rr($data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,9 +62,15 @@ class ICICILombardController extends AdminController
|
|||||||
//'Scope: esbgpabatchcreation'
|
//'Scope: esbgpabatchcreation'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#old policy info start
|
||||||
|
#"PolicyNumber" => "4016/A/51974976/00/000",
|
||||||
|
# "CDBGAccountNumber" => "CD-MUM-3344",
|
||||||
|
#"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
|
||||||
|
#old policy inf end
|
||||||
|
|
||||||
$body = [
|
$body = [
|
||||||
"PolicyNumber" => "4016/A/51974976/00/000",
|
"PolicyNumber" => "4016/A/O/53077718/00/000",
|
||||||
"CDBGAccountNumber" => "CD-MUM-3344",
|
"CDBGAccountNumber" => "CD-MUM-0026",
|
||||||
"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
|
"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
|
||||||
"MemberDetails" => [
|
"MemberDetails" => [
|
||||||
[
|
[
|
||||||
@ -74,8 +80,8 @@ class ICICILombardController extends AdminController
|
|||||||
"DOB" => "7-JUL-1983",
|
"DOB" => "7-JUL-1983",
|
||||||
"Relationship" => "SELF",
|
"Relationship" => "SELF",
|
||||||
"Gender" => "MALE",
|
"Gender" => "MALE",
|
||||||
"DOC" => "20-JAN-2020",
|
"DOC" => "08-JUL-2025",
|
||||||
"SumInsured" => "600000",
|
"SumInsured" => "400000",
|
||||||
"EmailId" => "ABC@GMAIL.COM",
|
"EmailId" => "ABC@GMAIL.COM",
|
||||||
"FlagStatus" => "A"
|
"FlagStatus" => "A"
|
||||||
],
|
],
|
||||||
@ -86,8 +92,8 @@ class ICICILombardController extends AdminController
|
|||||||
"DOB" => "8-AUG-1970",
|
"DOB" => "8-AUG-1970",
|
||||||
"Relationship" => "MOTHER",
|
"Relationship" => "MOTHER",
|
||||||
"Gender" => "FEMALE",
|
"Gender" => "FEMALE",
|
||||||
"DOC" => "20-JAN-2020",
|
"DOC" => "08-JUL-2025",
|
||||||
"SumInsured" => "600000",
|
"SumInsured" => "400000",
|
||||||
"EmailId" => "ABC@GMAIL.COM",
|
"EmailId" => "ABC@GMAIL.COM",
|
||||||
"FlagStatus" => "A"
|
"FlagStatus" => "A"
|
||||||
],
|
],
|
||||||
@ -97,13 +103,13 @@ class ICICILombardController extends AdminController
|
|||||||
"InsuredName" => "ABC28142",
|
"InsuredName" => "ABC28142",
|
||||||
"DOB" => "8-SEP-1970",
|
"DOB" => "8-SEP-1970",
|
||||||
"Gender" => "MALE",
|
"Gender" => "MALE",
|
||||||
"SumInsured" => "600000",
|
"SumInsured" => "400000",
|
||||||
"EmailId" => "ABC@GMAIL.COM",
|
"EmailId" => "ABC@GMAIL.COM",
|
||||||
"FlagStatus" => "M"
|
"FlagStatus" => "M"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"UHID" => "IL00688842552",
|
"UHID" => "IL00688842552",
|
||||||
"DOL" => "20-JAN-2020",
|
"DOL" => "08-JUL-2025",
|
||||||
"FlagStatus" => "D"
|
"FlagStatus" => "D"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
46
app/Libraries/Gemini.php
Normal file
46
app/Libraries/Gemini.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Libraries;
|
||||||
|
|
||||||
|
|
||||||
|
use GeminiAPI\Client;
|
||||||
|
use GeminiAPI\Resources\ModelName;
|
||||||
|
use GeminiAPI\Resources\Parts\TextPart;
|
||||||
|
|
||||||
|
class Gemini
|
||||||
|
{
|
||||||
|
|
||||||
|
private $client;
|
||||||
|
private $myLogger;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// $this->myLogger = \Config\Services::mylogger();
|
||||||
|
// $this->client = new Google_Client();
|
||||||
|
// $this->client->setAuthConfig(ROOTPATH . 'nhance-app-google-drive.json'); // App credentials
|
||||||
|
// // putenv('GOOGLE_APPLICATION_CREDENTIALS=' . ROOTPATH . 'nhance-app-google-drive.json');
|
||||||
|
// $this->client->useApplicationDefaultCredentials();
|
||||||
|
|
||||||
|
// $this->client->addScope(Google_Service_Drive::DRIVE); // Full access to Google Drive
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Initialize the Gemini client
|
||||||
|
$client = new Client($apiKey);
|
||||||
|
|
||||||
|
// Send a prompt to the Gemini Pro model
|
||||||
|
$response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent(
|
||||||
|
new TextPart('Write a short, creative story about a knight and a dragon.')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Display the generated text
|
||||||
|
$data['gemini_response'] = $response->text();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Handle any errors that occur during the API call
|
||||||
|
$data['gemini_response'] = 'An error occurred: ' . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -6,12 +6,40 @@
|
|||||||
<title>Insurance ChatBot</title>
|
<title>Insurance ChatBot</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: rgba(0, 0, 0, 0.3); /* 30% transparent black */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 3rem;
|
||||||
|
font-weight: bold;
|
||||||
|
animation: colorShift 2s infinite linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes colorShift {
|
||||||
|
0% { color: red; }
|
||||||
|
25% { color: orange; }
|
||||||
|
50% { color: green; }
|
||||||
|
75% { color: blue; }
|
||||||
|
100% { color: violet; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Loading...Please wait </h1>
|
<h1>Loading...</h1>
|
||||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
|
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
|
||||||
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
|
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
|
||||||
<script>
|
<script>
|
||||||
var emp_name = 'Kumar';
|
|
||||||
var uid = Math.floor(100000 + Math.random() * 900000);
|
var uid = Math.floor(100000 + Math.random() * 900000);
|
||||||
console.log('CURRENT_USER' + uid);
|
console.log('CURRENT_USER' + uid);
|
||||||
|
|
||||||
@ -23,7 +51,7 @@
|
|||||||
const calcWidth = isMobile
|
const calcWidth = isMobile
|
||||||
? (window.innerWidth)
|
? (window.innerWidth)
|
||||||
: Math.min(400, window.innerWidth - 50);
|
: Math.min(400, window.innerWidth - 50);
|
||||||
|
const name = queryParams['name'];
|
||||||
var botmanWidget = {
|
var botmanWidget = {
|
||||||
// chatServer: 'https://venbait.in/nhance/chatbot/chat',
|
// chatServer: 'https://venbait.in/nhance/chatbot/chat',
|
||||||
// frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
|
// frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
|
||||||
@ -33,15 +61,15 @@
|
|||||||
placeholderText: "Type your message here...",
|
placeholderText: "Type your message here...",
|
||||||
aboutText: "Insurance Assistant ILA",
|
aboutText: "Insurance Assistant ILA",
|
||||||
enableAttachments: false,
|
enableAttachments: false,
|
||||||
introMessage:'Welcome Kumar...! Say Hi...',
|
introMessage: ('Welcome '+ name + '...! Say Hi...'),
|
||||||
bubbleAvatarUrl:"https://botman.io/img/logo.png",
|
bubbleAvatarUrl:"https://botman.io/img/logo.png",
|
||||||
parameters: {
|
parameters: {
|
||||||
employee_id: queryParams['employee_id'],
|
employee_id: queryParams['employee_id'],
|
||||||
session_id: "XYZ789",
|
session_id: "XYZ789",
|
||||||
origin: "mobile",
|
origin: queryParams['origin'],
|
||||||
emp_code: queryParams['emp_code'],
|
emp_code: queryParams['emp_code'],
|
||||||
client_id: 63,
|
client_id:queryParams['client_id'],
|
||||||
client_branch_id: 32
|
client_branch_id: queryParams['client_branch_id']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -460,7 +488,7 @@ function setupMessageObserver() {
|
|||||||
botmanChatWidget.open();
|
botmanChatWidget.open();
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
botmanChatWidget.sayAsBot('Hi ' + (typeof emp_name !== "undefined" && emp_name !== null && emp_name !== "" ? emp_name : "Guest User") + ', This is ILA your Insurance Assistant, plz choose the following options');
|
botmanChatWidget.sayAsBot('Hi ' + (typeof name !== "undefined" && name !== null && name !== "" ? name : "Guest User") + ', This is ILA your Insurance Assistant, plz choose the following options');
|
||||||
botmanChatWidget.whisper('Hi');
|
botmanChatWidget.whisper('Hi');
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user