Integration of Chatbot Interface and Predictive Maintenance System in Autonomous Vehicles to Enhance User Experience and Ensure Vehicle Reliability
The project focuses on integrating a chatbot interface with a predictive maintenance system in autonomous vehicles. The goal is to enhance user experience and ensure vehicle reliability through advanced technologies.
The project is currently 83% efficient in implementing the machine learning model for predictive maintenance. This high level of efficiency ensures accurate fault prediction and prevention, significantly minimizing unexpected vehicle failures and optimizing performance.
@SubscribeMessage('user-message')
async handleMessage(@MessageBody() message: string) {
try {
// Check if the response is cached in Redis
const cachedResponse = await this.redis.get(cache_${message});
if (cachedResponse) {
this.server.emit('bot-message', cachedResponse);
} else {
const messages = [
{ role: 'system', content: 'This chatbot is your go-to expert on car details, always
ready with precise info.' },
{ role: 'user', content: message },
];
const response = await openai.chat.completions.create({
model: 'ft:gpt-3.5-turbo-0125:personal::9DEoLF03',
messages: messages,
max_tokens: 1024,
});
if (response && response.choices && response.choices.length > 0) {
const botResponse = response.choices[0].message.content;
// Cache the response in Redis
await this.redis.set(cache_${message}, botResponse); // Cache forever until we
manually delete the data
this.server.emit('bot-message', botResponse);
// Store the user question and bot response in Firebase
const chatRef = firestore.collection('Chats').doc(); // Use the 'Chats' collection
await chatRef.set({
userMessage: message,
} else {
console.error('GPT-3 response was empty:', response);
}
}
} catch (error) {
console.error('Error generating response from GPT-3:', error);
}
const firebaseConfig = {
credential: admin.credential.cert({
type: 'service_account',
project_id: 'talkbot-997f5',
private_key_id: 'd21f325d717e0936c35320dbbfa4d7f38bc88939',
private_key: '-----BEGIN PRIVATE KEY-----
\\nkSFimFzZHkuVxIotJRcRsIKEONg9GQFBDMyxcQKwy35EWHvIXMVXzLl8q7zZTLD
7/mr3CQ8DhjcvUfx55EWn40\\nz/Vvkp29IvLU\\nkHiN3p7tJwKBgQC0qGZMqqKIC7OarrrHM
W2NMuV2jAdB6CnBJ0aUAEcqASwWEHGi\\n2ibMcAH6XhIqDR81cglkByPwFtFgxD36g
B3AJADX3/1t6HPGuInyigFS7cKy9tRk\\njbWkLmlXGeSrw+Can7tPhDjid1EcKh2sGBqGH
cdjBVkSl+vbxeUoXvc1bwKBgAXa\\nPbm28Og//BYLq3Wsk+7Fjoqm50PfAelBxWy3ku9Vo
jP3Q0OBIOTZMaA\\n31MMRCDO2w3/J8KwRoblp0UK8XpJ4qd5WYf1IYtR/0tvxDPpgO
K/1cl+/cFodtUc\\nh/mInTee8kWXyQFXeFj+KQN0\\n-----END PRIVATE KEY-----\\n',
client_email: '[email protected]',
client_id: '115690868805996961450',
auth_uri: '<https://accounts.google.com/o/oauth2/auth>',
token_uri: '<https://oauth2.googleapis.com/token>',auth_provider_x509_cert_url:
'<https://www.googleapis.com/oauth2/v1/certs>',
client_x509_cert_url: '<https://www.googleapis.com/robot/v1/metadata/x509/>
firebase-
adminsdk-78rnf%40talkbot-997f5.iam.gserviceaccount.com',
universe_domain: 'googleapis.com',
} as admin.ServiceAccount),
databaseURL: '<https://console.firebase.google.com/project/talkbot->
997f5/firestore/data/~2FChats~2F1CxeW4Q08vtYX8adT1K2',
};
// Initialize Firebase Admin
firebaseAdmin.initializeApp(firebaseConfig);
@WebSocketGateway(8001, { cors: true })
export class AppGateway {
@WebSocketServer()
server: Server;
private redis: Redis = new Redis(); // Create a Redis client
{
"format": "layers-model",
"generatedBy": "keras v3.0.5",
"convertedBy": "TensorFlow.js Converter v4.17.0",
"modelTopology": {
"keras_version": "3.0.5",
"backend": "tensorflow",
"model_config": {
"class_name": "Sequential",
"config": {
"name": "sequential_3",
"trainable": true,
"dtype": "float32",
"layers": [
{
"class_name": "InputLayer",
"config": {
"batchInputShape": [null, 6],
"dtype": "float32",
"sparse": false,
"name": "input_layer_3"
}
}
}
}
}