import gradio as gr import random FAQS = { "AIoT": { "What is AIoT?": "AIoT (Artificial Intelligence of Things) combines AI with IoT to enable intelligent decision-making at the edge. Anktechsol specializes in AIoT implementations for industrial applications.", "Benefits of AIoT?": "Real-time processing, reduced latency, lower bandwidth costs, enhanced privacy, offline capability, scalable intelligence, and predictive analytics.", "AIoT use cases?": "Smart manufacturing, predictive maintenance, autonomous vehicles, smart cities, healthcare monitoring, retail analytics, energy management, and industrial automation.", "AIoT vs traditional IoT?": "Traditional IoT collects and transmits data. AIoT adds intelligence at the edge, enabling autonomous decisions without cloud dependency.", "How to start with AIoT?": "Identify use case, assess edge hardware, select appropriate ML models, implement edge inference, test with real data. Anktechsol provides end-to-end AIoT consulting." }, "Edge AI": { "What is Edge AI?": "Edge AI runs machine learning models directly on IoT devices rather than in the cloud, enabling faster responses and reduced dependency on connectivity.", "Best Edge AI models?": "MobileNet, EfficientNet, SqueezeNet, TinyML models, YOLO variants, and quantized neural networks optimized for resource-constrained devices.", "Edge AI vs Cloud AI?": "Edge: Low latency, privacy, offline operation. Cloud: More compute power, easier updates, centralized management. Hybrid approaches often work best.", "Edge AI hardware?": "Raspberry Pi, NVIDIA Jetson, Google Coral, Arduino, ESP32, specialized AI accelerators like Intel Movidius and Edge TPU.", "Model optimization for edge?": "Quantization, pruning, knowledge distillation, architecture search, and converting to TensorFlow Lite or ONNX Runtime formats." }, "IoT": { "IoT sensors explained?": "IoT sensors collect real-world data (temperature, pressure, motion, humidity, etc.) and transmit it for analysis, monitoring, and automated action.", "IoT protocols?": "MQTT (messaging), CoAP (constrained devices), HTTP/HTTPS (web), LoRaWAN (long-range), Zigbee (mesh), BLE (Bluetooth Low Energy).", "IoT security best practices?": "End-to-end encryption, device authentication, secure boot, regular OTA updates, network segmentation, and zero-trust architecture.", "Industrial IoT (IIoT)?": "IIoT applies IoT to manufacturing and industrial environments for predictive maintenance, quality control, asset tracking, and process optimization.", "IoT data analytics?": "Collect sensor data, preprocess and clean, apply analytics (descriptive, predictive, prescriptive), visualize insights, and trigger automated actions." }, "Implementation": { "How to deploy Edge AI models?": "Export model to edge format (TFLite/ONNX), optimize for target hardware, integrate with application code, test performance, and deploy with monitoring.", "Edge AI latency optimization?": "Use hardware acceleration, optimize model architecture, apply quantization, batch requests, and cache frequently used predictions.", "AIoT project challenges?": "Hardware constraints, model accuracy vs size tradeoffs, power management, connectivity issues, security concerns, and scalability. Anktechsol helps navigate these.", "Cost of AIoT implementation?": "Varies by scale: Pilot projects $10K-50K, production deployments $50K-500K+. ROI typically achieved in 6-18 months through efficiency gains.", "AIoT maintenance?": "Monitor device health, push OTA updates, retrain models with new data, replace aging hardware, and continuously optimize performance." } } def search_faq(query, category="All"): if not query or len(query) < 3: return "šŸ’” Please enter at least 3 characters to search." query = query.lower() results = [] search_cats = FAQS.keys() if category == "All" else [category] for cat in search_cats: if cat in FAQS: for question, answer in FAQS[cat].items(): if query in question.lower() or query in answer.lower(): results.append(f"**Category: {cat}**\n\n**Q: {question}**\n\n{answer}\n\n---\n") if results: return "\n".join(results[:5]) + "\n\nšŸ’” **Need custom AIoT solutions?** [Contact Anktechsol](https://anktechsol.com)" else: return f"āŒ No results found for '{query}'.\n\nšŸ’” Try: 'edge ai', 'sensors', 'protocols', 'security', 'implementation'" def get_random_faq(): cat = random.choice(list(FAQS.keys())) question = random.choice(list(FAQS[cat].keys())) answer = FAQS[cat][question] return f"**Category: {cat}**\n\n**Q: {question}**\n\n{answer}\n\n---\n\nšŸ’” Ask your own question or search by category!" def browse_category(category): if category not in FAQS: return "Category not found." result = f"# šŸ“š {category} FAQs\n\n" for question, answer in FAQS[category].items(): result += f"**Q: {question}**\n\n{answer}\n\n---\n\n" result += "\nšŸ’” **Need expert guidance?** [Visit Anktechsol](https://anktechsol.com)" return result with gr.Blocks(title="AIoT FAQ Chatbot - Anktechsol", theme=gr.themes.Soft()) as demo: gr.Markdown(""" # šŸ’¬ AIoT & Edge AI FAQ Chatbot ### by **Anktechsol** - AI + IoT Experts Get instant answers about AIoT, Edge AI, IoT protocols, sensors, and industrial implementations. Ask questions, search topics, or browse by category! """) with gr.Tabs(): with gr.Tab("šŸ” Search"): with gr.Row(): with gr.Column(scale=2): query_input = gr.Textbox(label="Ask your question", placeholder="e.g., What is Edge AI?") category_select = gr.Dropdown(choices=["All", "AIoT", "Edge AI", "IoT", "Implementation"], value="All", label="Filter by Category") search_btn = gr.Button("šŸ” Search", variant="primary", size="lg") random_btn = gr.Button("šŸŽ² Random FAQ", size="lg") with gr.Column(scale=3): output = gr.Markdown() search_btn.click(fn=search_faq, inputs=[query_input, category_select], outputs=output) random_btn.click(fn=get_random_faq, outputs=output) with gr.Tab("šŸ“š Browse Categories"): gr.Markdown("### Select a category to view all FAQs") cat_buttons = gr.Radio(choices=list(FAQS.keys()), label="Categories", value="AIoT") browse_output = gr.Markdown() cat_buttons.change(fn=browse_category, inputs=cat_buttons, outputs=browse_output) gr.Markdown(""" --- ### šŸ”— Resources - [**Anktechsol Website**](https://anktechsol.com) - Enterprise AIoT solutions - [**More Tools**](https://huggingface.co/anktechsol) - Free AI + IoT tools - **Contact us** for custom implementations and consulting ### šŸ“Š Topics Covered **AIoT** | **Edge AI** | **IoT Protocols** | **Security** | **Implementation** """) demo.load(fn=get_random_faq, outputs=output) demo.load(fn=lambda: browse_category("AIoT"), outputs=browse_output) if __name__ == "__main__": demo.launch()