KnowledgeGPT / app.py
Tralalabs's picture
Update app.py
b6c8d1b verified
Raw
History Blame Contribute Delete
5.56 kB
import gradio as gr
# Import knowledge base from a local file
# Example structure in knowledge.py:
KNOWLEDGE = {
"hello": "Hello ๐Ÿ‘‹ Welcome to KnowledgeGPT!",
"hi": "Hi there ๐Ÿ˜Ž ready to learn something cool?",
"hey": "Heyyy โšก whatโ€™s up?",
"good morning": "Good morning ๐ŸŒ… start your day with curiosity!",
"good night": "Good night ๐ŸŒ™ rest + recharge your brain!",
"what is ai": "AI is Artificial Intelligence ๐Ÿค– systems that simulate human thinking.",
"what is ml": "ML is Machine Learning ๐Ÿ“Š where systems learn from data.",
"what is dl": "DL is Deep Learning ๐Ÿง  using neural networks with many layers.",
"python": "Python ๐Ÿ is a powerful, easy-to-read programming language.",
"javascript": "JavaScript ๐ŸŒ powers interactive websites.",
"html": "HTML ๐Ÿงฑ is the structure of web pages.",
"css": "CSS ๐ŸŽจ styles web pages visually.",
"java": "Java โ˜• is a widely used object-oriented language.",
"c++": "C++ โš™๏ธ is a high-performance programming language.",
"rust": "Rust ๐Ÿฆ€ is a safe and fast systems language.",
"go": "Go ๐Ÿš€ is a simple language made by Google.",
"sql": "SQL ๐Ÿ—„๏ธ is used to manage databases.",
"git": "Git ๐Ÿ“ฆ tracks code changes.",
"github": "GitHub ๐Ÿ’ป hosts and shares code online.",
"linux": "Linux ๐Ÿง is an open-source operating system.",
"windows": "Windows ๐ŸชŸ is a popular OS by Microsoft.",
"macos": "macOS ๐ŸŽ is Appleโ€™s desktop OS.",
"cpu": "CPU ๐Ÿง  is the brain of the computer.",
"gpu": "GPU ๐ŸŽฎ handles graphics and parallel computing.",
"ram": "RAM โšก is short-term memory for fast processing.",
"ssd": "SSD ๐Ÿš€ is fast storage drive.",
"hdd": "HDD ๐Ÿ’ฝ is traditional storage drive.",
"cloud computing": "Cloud โ˜๏ธ means computing over the internet.",
"docker": "Docker ๐Ÿณ runs apps in containers.",
"kubernetes": "Kubernetes โš™๏ธ manages containers at scale.",
"api": "API ๐Ÿ”Œ lets software talk to each other.",
"rest api": "REST API ๐ŸŒ is a web API style using HTTP.",
"json": "JSON ๐Ÿ“„ is a lightweight data format.",
"xml": "XML ๐Ÿงพ stores structured data.",
"http": "HTTP ๐ŸŒ is the web communication protocol.",
"https": "HTTPS ๐Ÿ” is secure HTTP.",
"dns": "DNS ๐ŸŒ translates domain names to IPs.",
"ip address": "IP address ๐Ÿ“ identifies devices on a network.",
"cybersecurity": "Cybersecurity ๐Ÿ›ก๏ธ protects systems from attacks.",
"encryption": "Encryption ๐Ÿ” secures data using algorithms.",
"machine learning": "Machine Learning ๐Ÿ“Š helps computers learn from data.",
"neural network": "Neural networks ๐Ÿง  mimic the human brain.",
"transformer": "Transformer โšก is a model architecture used in LLMs.",
"hugging face": "Hugging Face ๐Ÿค— is a hub for AI models.",
"llm": "LLM ๐Ÿง  is a Large Language Model like ChatGPT.",
"chatbot": "Chatbot ๐Ÿค– is an AI that talks with users.",
"data science": "Data Science ๐Ÿ“ˆ extracts insights from data.",
"statistics": "Statistics ๐Ÿ“Š is the study of data.",
"probability": "Probability ๐ŸŽฒ measures chance of events.",
"calculus": "Calculus โˆซ studies change and motion.",
"algebra": "Algebra ๐Ÿ”ข uses symbols and equations.",
"physics": "Physics โš›๏ธ studies matter and energy.",
"chemistry": "Chemistry ๐Ÿงช studies substances and reactions.",
"biology": "Biology ๐Ÿงฌ studies living organisms.",
"astronomy": "Astronomy ๐ŸŒŒ studies space and stars.",
"earth": "Earth ๐ŸŒ is our home planet.",
"space": "Space ๐Ÿš€ is the universe beyond Earth.",
"math": "Math โž— is the language of logic and numbers.",
"history": "History ๐Ÿ“œ studies past events.",
"geography": "Geography ๐Ÿ—บ๏ธ studies Earthโ€™s surface.",
"philosophy": "Philosophy ๐Ÿ’ญ studies knowledge and existence.",
"logic": "Logic ๐Ÿง  is structured reasoning.",
"art": "Art ๐ŸŽจ expresses creativity visually.",
"music": "Music ๐ŸŽต is organized sound and rhythm.",
"gaming": "Gaming ๐ŸŽฎ is interactive digital entertainment.",
"minecraft": "Minecraft โ›๏ธ is a sandbox building game.",
"stumble guys": "Stumble Guys ๐Ÿƒ is a chaotic multiplayer game.",
"memes": "Memes ๐Ÿ˜‚ are viral internet jokes.",
"internet": "Internet ๐ŸŒ connects the world digitally.",
"browser": "Browser ๐ŸŒ lets you access the web.",
"chrome": "Chrome ๐ŸŸข is a popular Google browser.",
"firefox": "Firefox ๐ŸฆŠ is a privacy-focused browser.",
"edge": "Edge ๐ŸŒŠ is Microsoftโ€™s modern browser.",
"safari": "Safari ๐Ÿงญ is Appleโ€™s browser.",
"android": "Android ๐Ÿค– is a mobile OS by Google.",
"ios": "iOS ๐Ÿ“ฑ is Appleโ€™s mobile OS.",
"smartphone": "Smartphone ๐Ÿ“ฑ is a pocket computer.",
"laptop": "Laptop ๐Ÿ’ป is a portable computer.",
"robotics": "Robotics ๐Ÿค– combines machines and intelligence.",
"automation": "Automation โš™๏ธ runs tasks automatically."
}
try:
from knowledge import KNOWLEDGE
except Exception:
KNOWLEDGE = {}
def get_response(prompt: str):
prompt = prompt.strip().lower()
if prompt in KNOWLEDGE:
return KNOWLEDGE[prompt]
return "Prompt not found! Adding more in the future."
demo = gr.Interface(
fn=get_response,
inputs=gr.Textbox(label="Enter your prompt"),
outputs=gr.Textbox(label="Response"),
title="KnowledgeGPT",
description="A simple prompt โ†’ response knowledge engine."
)
if __name__ == "__main__":
demo.launch()