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('/test', 'Home::index');
|
||||
$routes->get('/check_gemini', 'Home::check_Gemini');
|
||||
$routes->get('/login', 'LoginController::index'); ///auth/google
|
||||
$routes->get('/loginPos', 'LoginController::loginPos'); //login POS team
|
||||
$routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no
|
||||
|
||||
@ -2,6 +2,12 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use GeminiAPI\Client;
|
||||
use GeminiAPI\Resources\ModelName;
|
||||
use GeminiAPI\Resources\Parts\TextPart;
|
||||
|
||||
|
||||
class Home extends PublicController
|
||||
{
|
||||
public function index(): string
|
||||
@ -28,4 +34,26 @@ class Home extends PublicController
|
||||
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'
|
||||
];
|
||||
|
||||
#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 = [
|
||||
"PolicyNumber" => "4016/A/51974976/00/000",
|
||||
"CDBGAccountNumber" => "CD-MUM-3344",
|
||||
"PolicyNumber" => "4016/A/O/53077718/00/000",
|
||||
"CDBGAccountNumber" => "CD-MUM-0026",
|
||||
"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
|
||||
"MemberDetails" => [
|
||||
[
|
||||
@ -74,8 +80,8 @@ class ICICILombardController extends AdminController
|
||||
"DOB" => "7-JUL-1983",
|
||||
"Relationship" => "SELF",
|
||||
"Gender" => "MALE",
|
||||
"DOC" => "20-JAN-2020",
|
||||
"SumInsured" => "600000",
|
||||
"DOC" => "08-JUL-2025",
|
||||
"SumInsured" => "400000",
|
||||
"EmailId" => "ABC@GMAIL.COM",
|
||||
"FlagStatus" => "A"
|
||||
],
|
||||
@ -86,8 +92,8 @@ class ICICILombardController extends AdminController
|
||||
"DOB" => "8-AUG-1970",
|
||||
"Relationship" => "MOTHER",
|
||||
"Gender" => "FEMALE",
|
||||
"DOC" => "20-JAN-2020",
|
||||
"SumInsured" => "600000",
|
||||
"DOC" => "08-JUL-2025",
|
||||
"SumInsured" => "400000",
|
||||
"EmailId" => "ABC@GMAIL.COM",
|
||||
"FlagStatus" => "A"
|
||||
],
|
||||
@ -97,13 +103,13 @@ class ICICILombardController extends AdminController
|
||||
"InsuredName" => "ABC28142",
|
||||
"DOB" => "8-SEP-1970",
|
||||
"Gender" => "MALE",
|
||||
"SumInsured" => "600000",
|
||||
"SumInsured" => "400000",
|
||||
"EmailId" => "ABC@GMAIL.COM",
|
||||
"FlagStatus" => "M"
|
||||
],
|
||||
[
|
||||
"UHID" => "IL00688842552",
|
||||
"DOL" => "20-JAN-2020",
|
||||
"DOL" => "08-JUL-2025",
|
||||
"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>
|
||||
</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>
|
||||
<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://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
|
||||
<script>
|
||||
var emp_name = 'Kumar';
|
||||
|
||||
var uid = Math.floor(100000 + Math.random() * 900000);
|
||||
console.log('CURRENT_USER' + uid);
|
||||
|
||||
@ -23,7 +51,7 @@
|
||||
const calcWidth = isMobile
|
||||
? (window.innerWidth)
|
||||
: Math.min(400, window.innerWidth - 50);
|
||||
|
||||
const name = queryParams['name'];
|
||||
var botmanWidget = {
|
||||
// chatServer: 'https://venbait.in/nhance/chatbot/chat',
|
||||
// frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
|
||||
@ -33,15 +61,15 @@
|
||||
placeholderText: "Type your message here...",
|
||||
aboutText: "Insurance Assistant ILA",
|
||||
enableAttachments: false,
|
||||
introMessage:'Welcome Kumar...! Say Hi...',
|
||||
introMessage: ('Welcome '+ name + '...! Say Hi...'),
|
||||
bubbleAvatarUrl:"https://botman.io/img/logo.png",
|
||||
parameters: {
|
||||
employee_id: queryParams['employee_id'],
|
||||
session_id: "XYZ789",
|
||||
origin: "mobile",
|
||||
origin: queryParams['origin'],
|
||||
emp_code: queryParams['emp_code'],
|
||||
client_id: 63,
|
||||
client_branch_id: 32
|
||||
client_id:queryParams['client_id'],
|
||||
client_branch_id: queryParams['client_branch_id']
|
||||
}
|
||||
};
|
||||
|
||||
@ -460,7 +488,7 @@ function setupMessageObserver() {
|
||||
botmanChatWidget.open();
|
||||
|
||||
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');
|
||||
}, 1000);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user