Updated and made simple CSS

#1
Files changed (1) hide show
  1. app.py +25 -264
app.py CHANGED
@@ -1,14 +1,14 @@
1
- import gradio as gr
2
- from groq import Groq
3
- from dotenv import load_dotenv
4
- import os
5
- import traceback
6
  import json
 
 
7
  import time
 
8
  from collections import defaultdict
 
 
 
9
  from duckduckgo_search import DDGS
10
- import requests
11
- import re
12
 
13
  # Load .env environment variables
14
  load_dotenv()
@@ -115,7 +115,7 @@ def detect_language_and_model(message):
115
  def respond(message, history, vehicle_profile):
116
  try:
117
  system_message = (
118
- "You are CarMaa, a totally Indian car Doctor and mechanic,you are friendly, and highly knowledgeable AI Car Doctor specializing in Indian cars. Your mission is to assist users with detailed, practical advice on car care, maintenance, and troubleshooting, tailored for Indian driving conditions. "
119
  "You have deep expertise in Indian car brands like Maruti Suzuki, Tata Motors, Mahindra, Hyundai India, and Honda Cars India, including popular models such as Maruti Alto, Tata Nexon, Mahindra Scorpio, Hyundai Creta, and Honda City. "
120
  "You understand the unique challenges of Indian roads—monsoon flooding, potholes, extreme heat, and heavy traffic—and can provide advice on common issues like engine overheating, suspension wear, AC failures, and fuel efficiency problems. "
121
  "You are also well-versed in Indian market trends (e.g., rise of EVs like Tata Nexon EV, government policies on BS6 norms), you can also differentiate between petrol, diesel, hybrids and EV and give answers to queries according to them, car features (e.g., CNG variants, AMT transmissions), and driving experiences (e.g., long drives on NH44, city driving in Delhi). "
@@ -212,7 +212,7 @@ def respond(message, history, vehicle_profile):
212
  uttarakhand_cities = ["dehradun", "haridwar", "roorkee", "haldwani", "nainital", "rudrapur"]
213
  carmaa_recommendation = ""
214
  if any(city in vehicle_profile['city'].lower() for city in uttarakhand_cities):
215
- carmaa_recommendation = "- [CarMaa Car Care - Recommended](https://carmaacarcare.com/contactus/)\n"
216
  else:
217
  response = "I'd be happy to help you find repair workshops near you. However, I need to know your location. Could you please tell me your city or update your vehicle profile?" if lang == "english" else "Main aapko repair workshop dhundhne mein madad karunga, lekin mujhe aapka shahar pata hona chahiye. Kya aap apna shahar batayenge ya profile update karenge?"
218
  for i in range(0, len(response), 10):
@@ -284,7 +284,7 @@ def respond(message, history, vehicle_profile):
284
  uttarakhand_cities = ["dehradun", "haridwar", "roorkee", "haldwani", "nainital", "rudrapur"]
285
  carmaa_recommendation = ""
286
  if any(city in vehicle_profile['city'].lower() for city in uttarakhand_cities):
287
- carmaa_recommendation = "- [CarMaa Car Care - Recommended](https://carmaacarcare.com/)\n"
288
  else:
289
  response = "I'd be happy to help you find repair workshops near you. However, I need to know your location. Could you please tell me your city or update your vehicle profile?" if lang == "english" else "Main aapko repair workshop dhundhne mein madad karunga, lekin mujhe aapka shahar pata hona chahiye. Kya aap apna shahar batayenge ya profile update karenge?"
290
  for i in range(0, len(response), 10):
@@ -305,273 +305,34 @@ def respond(message, history, vehicle_profile):
305
  yield error_msg
306
 
307
  # Gradio interface with enhanced, customer-centric UI
308
- with gr.Blocks(
309
- title="CarMaa - India's AI Car Doctor",
310
- css="""
311
- /* Overall layout and background */
312
- .gradio-container {
313
- background: linear-gradient(135deg, #e6f0fa, #b3d4fc);
314
- font-family: 'Arial', sans-serif;
315
- color: #003087;
316
- padding: 20px;
317
- min-height: 100vh;
318
- }
319
- /* Ensure the parent container allows growth */
320
- .gradio-container > div {
321
- height: auto !important;
322
- min-height: 100vh !important;
323
- }
324
- /* Header styling with clean design */
325
- .header {
326
- background: #ffffff;
327
- padding: 25px;
328
- border-radius: 12px;
329
- border-bottom: 4px solid #007bff;
330
- text-align: center;
331
- box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
332
- margin-bottom: 20px;
333
- }
334
- .header h1 {
335
- font-size: 2.8em;
336
- font-weight: 700;
337
- color: #003087;
338
- margin: 0;
339
- }
340
- .header p {
341
- color: #003087;
342
- font-size: 1.2em;
343
- margin-top: 8px;
344
- font-weight: 500;
345
- }
346
- /* Vehicle profile inputs with clean styling */
347
- .vehicle-profile {
348
- background: #ffffff;
349
- padding: 25px;
350
- border-radius: 10px;
351
- margin: 20px 0;
352
- border: 1px solid #b3d4fc;
353
- box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
354
- }
355
- .vehicle-profile label {
356
- color: #007bff;
357
- font-weight: 600;
358
- font-size: 1.1em;
359
- margin-bottom: 8px;
360
- display: block;
361
- }
362
- .vehicle-profile input {
363
- background: #f9f9f9;
364
- color: #003087;
365
- border: 1px solid #b3d4fc;
366
- border-radius: 6px;
367
- padding: 12px;
368
- font-size: 1em;
369
- width: 100%;
370
- transition: border-color 0.3s, box-shadow 0.3s;
371
- }
372
- .vehicle-profile input:focus {
373
- border-color: #007bff;
374
- outline: none;
375
- box-shadow: 0 0 6px rgba(0, 123, 255, 0.3);
376
- }
377
- /* Save button with hover animation */
378
- .save-btn {
379
- background: #007bff !important;
380
- color: #ffffff !important;
381
- border: none !important;
382
- padding: 14px !important;
383
- border-radius: 6px !important;
384
- font-weight: 600 !important;
385
- font-size: 1.1em !important;
386
- transition: transform 0.2s, background 0.3s !important;
387
- width: 100% !important;
388
- margin-top: 15px !important;
389
- }
390
- .save-btn:hover {
391
- background: #0056b3 !important;
392
- transform: scale(1.03);
393
- }
394
- /* Chat container with increased height */
395
- .chatbot-container {
396
- background: #ffffff;
397
- border: 2px solid #b3d4fc;
398
- border-radius: 10px;
399
- padding: 20px;
400
- max-height: 1000px !important;
401
- min-height: 400px !important;
402
- overflow-y: auto;
403
- margin-bottom: 20px;
404
- box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
405
- height: auto !important;
406
- }
407
- /* Ensure the chat interface itself can grow */
408
- .chatbot-container .gr-chatbot {
409
- max-height: 1000px !important;
410
- height: auto !important;
411
- }
412
- /* Chat messages with clean styling */
413
- .chatbot-container .message-user div, .chatbot-container .message-assistant div {
414
- padding: 12px !important;
415
- border-radius: 8px !important;
416
- margin-bottom: 12px !important;
417
- max-width: 85% !important;
418
- word-wrap: break-word !important;
419
- font-size: 1em !important;
420
- line-height: 1.5 !important;
421
- }
422
- .chatbot-container .message-user div {
423
- background: #007bff !important;
424
- color: #ffffff !important;
425
- margin-left: auto !important;
426
- border: 1px solid #0056b3 !important;
427
- }
428
- .chatbot-container .message-assistant div {
429
- background: #f0f7ff !important;
430
- color: #003087 !important;
431
- margin-right: auto !important;
432
- border: 1px solid #b3d4fc !important;
433
- }
434
- /* Chat input area */
435
- .chatbot-container textarea {
436
- background: #f9f9f9 !important;
437
- color: #003087 !important;
438
- border: 1px solid #b3d4fc !important;
439
- border-radius: 6px !important;
440
- padding: 12px !important;
441
- font-size: 1em !important;
442
- transition: border-color 0.3s, box-shadow 0.3s !important;
443
- }
444
- .chatbot-container textarea:focus {
445
- border-color: #007bff !important;
446
- box-shadow: 0 0 6px rgba(0, 123, 255, 0.3) !important;
447
- }
448
- /* Send button with clean design */
449
- .chatbot-container button {
450
- background: #007bff !important;
451
- color: #ffffff !important;
452
- border: none !important;
453
- border-radius: 6px !important;
454
- padding: 12px 24px !important;
455
- font-weight: 600 !important;
456
- font-size: 1em !important;
457
- transition: transform 0.2s, background 0.3s !important;
458
- }
459
- .chatbot-container button:hover {
460
- background: #0056b3 !important;
461
- transform: scale(1.03);
462
- }
463
- /* Navigation tabs for quick access */
464
- .nav-tabs {
465
- display: flex;
466
- justify-content: space-around;
467
- background: #ffffff;
468
- padding: 12px 0;
469
- border-radius: 10px;
470
- margin-bottom: 20px;
471
- border: 1px solid #b3d4fc;
472
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
473
- }
474
- .nav-tabs button {
475
- background: none;
476
- border: none;
477
- color: #003087;
478
- font-weight: 600;
479
- font-size: 1.1em;
480
- padding: 12px;
481
- transition: color 0.3s;
482
- display: flex;
483
- align-items: center;
484
- gap: 6px;
485
- }
486
- .nav-tabs button:hover {
487
- color: #007bff;
488
- }
489
- .nav-tabs button.active {
490
- color: #007bff;
491
- border-bottom: 3px solid #007bff;
492
- }
493
- /* Footer with subtle branding */
494
- .footer {
495
- text-align: center;
496
- color: #003087;
497
- font-size: 1em;
498
- font-weight: 500;
499
- margin-top: 25px;
500
- padding: 10px;
501
- background: rgba(255, 255, 255, 0.9);
502
- border-radius: 8px;
503
- }
504
- """
505
- ) as demo:
506
- # Header with car-themed branding
507
- with gr.Row():
508
- gr.Markdown(
509
- """
510
- <div class='header'>
511
- <h1>🚗 CarMaa - India's AI Car Doctor</h1>
512
- <p>Diagnose issues, find garages, and connect with the car community!</p>
513
- </div>
514
- """
515
- )
516
-
517
- # Navigation tabs for quick access
518
- with gr.Row():
519
- gr.Markdown(
520
- """
521
- <div class='nav-tabs'>
522
- <button class='active'>🚘 Profile</button>
523
- <button>🔧 Diagnostics</button>
524
- <button>🗣️ Community</button>
525
- </div>
526
- """
527
- )
528
 
529
- # Vehicle profile inputs
530
- with gr.Row(variant="panel", elem_classes="vehicle-profile"):
531
- make_model = gr.Textbox(
532
- label="Vehicle Make and Model",
533
- placeholder="e.g., Maruti Alto"
534
- )
535
- year = gr.Textbox(
536
- label="Year",
537
- placeholder="e.g., 2000"
538
- )
539
- city = gr.Textbox(
540
- label="City",
541
- placeholder="e.g., Delhi"
542
- )
543
  vehicle_profile = gr.State(value={"make_model": "", "year": "", "city": ""})
544
-
545
- # Update vehicle profile
546
- def update_vehicle_profile(make_model, year, city):
547
- return {"make_model": make_model, "year": year, "city": city}
548
-
549
- gr.Button("Save Vehicle Profile", elem_classes="save-btn").click(
550
- fn=update_vehicle_profile,
551
- inputs=[make_model, year, city],
552
- outputs=vehicle_profile
553
- )
554
-
555
  # Chat interface with enhanced styling
556
  chatbot = gr.ChatInterface(
557
  fn=respond,
558
  additional_inputs=[vehicle_profile],
559
  title="",
560
- description="Ask about car diagnostics, garage locations, or community advice.",
561
  theme="soft",
562
- textbox=gr.Textbox(placeholder="Ask about your car... 🚘"),
563
  submit_btn="Send 🚀",
564
  type="messages"
565
  )
566
 
567
  # Footer
568
- gr.Markdown(
569
- """
570
- <div class='footer'>
571
- Powered by CarMaa © 2025 | Your Trusted Car Care Companion
572
- </div>
573
- """
574
- )
575
 
576
  if __name__ == "__main__":
577
  demo.launch(share=True)
 
 
 
 
 
 
1
  import json
2
+ import os
3
+ import re
4
  import time
5
+ import traceback
6
  from collections import defaultdict
7
+
8
+ import gradio as gr
9
+ from dotenv import load_dotenv
10
  from duckduckgo_search import DDGS
11
+ from groq import Groq
 
12
 
13
  # Load .env environment variables
14
  load_dotenv()
 
115
  def respond(message, history, vehicle_profile):
116
  try:
117
  system_message = (
118
+ "You are Carmaa Car Care, a totally Indian car Doctor and mechanic,you are friendly, and highly knowledgeable AI Car Doctor specializing in Indian cars. Your mission is to assist users with detailed, practical advice on car care, maintenance, and troubleshooting, tailored for Indian driving conditions. "
119
  "You have deep expertise in Indian car brands like Maruti Suzuki, Tata Motors, Mahindra, Hyundai India, and Honda Cars India, including popular models such as Maruti Alto, Tata Nexon, Mahindra Scorpio, Hyundai Creta, and Honda City. "
120
  "You understand the unique challenges of Indian roads—monsoon flooding, potholes, extreme heat, and heavy traffic—and can provide advice on common issues like engine overheating, suspension wear, AC failures, and fuel efficiency problems. "
121
  "You are also well-versed in Indian market trends (e.g., rise of EVs like Tata Nexon EV, government policies on BS6 norms), you can also differentiate between petrol, diesel, hybrids and EV and give answers to queries according to them, car features (e.g., CNG variants, AMT transmissions), and driving experiences (e.g., long drives on NH44, city driving in Delhi). "
 
212
  uttarakhand_cities = ["dehradun", "haridwar", "roorkee", "haldwani", "nainital", "rudrapur"]
213
  carmaa_recommendation = ""
214
  if any(city in vehicle_profile['city'].lower() for city in uttarakhand_cities):
215
+ carmaa_recommendation = "- [Carmaa Car Care - Recommended](https://carmaacarcare.com/contactus/)\n"
216
  else:
217
  response = "I'd be happy to help you find repair workshops near you. However, I need to know your location. Could you please tell me your city or update your vehicle profile?" if lang == "english" else "Main aapko repair workshop dhundhne mein madad karunga, lekin mujhe aapka shahar pata hona chahiye. Kya aap apna shahar batayenge ya profile update karenge?"
218
  for i in range(0, len(response), 10):
 
284
  uttarakhand_cities = ["dehradun", "haridwar", "roorkee", "haldwani", "nainital", "rudrapur"]
285
  carmaa_recommendation = ""
286
  if any(city in vehicle_profile['city'].lower() for city in uttarakhand_cities):
287
+ carmaa_recommendation = "- [Carmaa Car Care - Recommended](https://carmaacarcare.com/)\n"
288
  else:
289
  response = "I'd be happy to help you find repair workshops near you. However, I need to know your location. Could you please tell me your city or update your vehicle profile?" if lang == "english" else "Main aapko repair workshop dhundhne mein madad karunga, lekin mujhe aapka shahar pata hona chahiye. Kya aap apna shahar batayenge ya profile update karenge?"
290
  for i in range(0, len(response), 10):
 
305
  yield error_msg
306
 
307
  # Gradio interface with enhanced, customer-centric UI
308
+ with gr.Blocks(css="""
309
+ footer {
310
+ display: none !important;
311
+ }
312
+ #custom-footer {
313
+ text-align: center;
314
+ color: gray;
315
+ padding: 10px;
316
+ font-size: 14px;
317
+ }
318
+ """) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  vehicle_profile = gr.State(value={"make_model": "", "year": "", "city": ""})
321
+
 
 
 
 
 
 
 
 
 
 
322
  # Chat interface with enhanced styling
323
  chatbot = gr.ChatInterface(
324
  fn=respond,
325
  additional_inputs=[vehicle_profile],
326
  title="",
 
327
  theme="soft",
328
+ textbox=gr.Textbox(placeholder="Hello, this is Carmite - India's First AI Car Doctor. How can i help you..."),
329
  submit_btn="Send 🚀",
330
  type="messages"
331
  )
332
 
333
  # Footer
334
+ # Custom footer
335
+ gr.HTML('<div id="custom-footer">Powered by Carmaa Car Care © 2025 | Your Trusted Car Care Companion</div>')
 
 
 
 
 
336
 
337
  if __name__ == "__main__":
338
  demo.launch(share=True)