Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -6,11 +6,11 @@ import json
|
|
| 6 |
|
| 7 |
# Demo responses for HR testing
|
| 8 |
DEMO_RESPONSES = {
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
}
|
| 15 |
|
| 16 |
SAMPLES = list(DEMO_RESPONSES.keys())
|
|
@@ -22,24 +22,45 @@ def generate_response(prompt, max_new_tokens=128, temperature=0.2):
|
|
| 22 |
if prompt in DEMO_RESPONSES:
|
| 23 |
reply = DEMO_RESPONSES[prompt]
|
| 24 |
else:
|
| 25 |
-
# Generate
|
| 26 |
prompt_lower = prompt.lower()
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
elif any(word in prompt_lower for word in ['rml', 'resonant', 'memory', 'learning']):
|
| 33 |
-
reply = "RML
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
elif any(word in prompt_lower for word in ['science', 'research', 'study']):
|
| 37 |
-
reply = "Scientific research is a key strength of the RML-AI system. For your question '" + prompt + "', it would search through its 100GB knowledge base of scientific literature to provide evidence-based, source-attributed responses."
|
| 38 |
else:
|
| 39 |
-
reply = "
|
| 40 |
|
| 41 |
elapsed = int((time.time() - start) * 1000)
|
| 42 |
-
return reply + "\n\n(⏱️ " + str(elapsed) + " ms)\n\n💡 This is a demo. The full
|
| 43 |
|
| 44 |
with gr.Blocks(title="RML-AI Demo") as demo:
|
| 45 |
gr.Markdown('''
|
|
|
|
| 6 |
|
| 7 |
# Demo responses for HR testing
|
| 8 |
DEMO_RESPONSES = {
|
| 9 |
+
"Hi there!": "Hi there! 👋 I'm the RML-AI demo, and I'd love to answer any questions you have about AI, technology, science, or anything else!",
|
| 10 |
+
"What can you do?": "Great question! I'm a demo of RML-AI, which is pretty amazing. I can chat about AI, technology, science, business, health - you name it! The full system has access to 100GB of knowledge and can answer complex questions with sources. What interests you?",
|
| 11 |
+
"Tell me about AI": "Oh, AI! That's a fascinating topic. AI and machine learning are changing the world, and RML-AI is actually a revolutionary new approach to AI. The full system would give you detailed, accurate answers with sources from its massive knowledge base. What specifically about AI interests you?",
|
| 12 |
+
"How are you?": "I'm doing great, thanks for asking! 😊 I'm excited to be chatting with you and showing off what RML-AI can do. What's on your mind today?",
|
| 13 |
+
"What is RML?": "RML is what makes this system special! It's Resonant Memory Learning - a completely new way of doing AI that's 100x more efficient and 10x faster than traditional systems. It's exactly the kind of technology that's changing the future of AI!"
|
| 14 |
}
|
| 15 |
|
| 16 |
SAMPLES = list(DEMO_RESPONSES.keys())
|
|
|
|
| 22 |
if prompt in DEMO_RESPONSES:
|
| 23 |
reply = DEMO_RESPONSES[prompt]
|
| 24 |
else:
|
| 25 |
+
# Generate conversational response based on question content
|
| 26 |
prompt_lower = prompt.lower()
|
| 27 |
|
| 28 |
+
# Greetings and casual conversation
|
| 29 |
+
if any(word in prompt_lower for word in ['hi', 'hello', 'hey', 'good morning', 'good afternoon', 'good evening']):
|
| 30 |
+
greetings = ["Hi there! 👋", "Hello! Nice to meet you!", "Hey! How can I help you today?", "Hi! I'm excited to chat with you!", "Hello! What would you like to know?"]
|
| 31 |
+
import random
|
| 32 |
+
reply = random.choice(greetings) + " I'm the RML-AI demo, and I'd love to answer any questions you have about AI, technology, science, or anything else!"
|
| 33 |
+
|
| 34 |
+
# How are you / personal questions
|
| 35 |
+
elif any(word in prompt_lower for word in ['how are you', 'how do you do', 'are you ok', 'feeling']):
|
| 36 |
+
reply = "I'm doing great, thanks for asking! 😊 I'm excited to be chatting with you and showing off what RML-AI can do. What's on your mind today?"
|
| 37 |
+
|
| 38 |
+
# What can you do / capabilities
|
| 39 |
+
elif any(word in prompt_lower for word in ['what can you do', 'help', 'capabilities', 'features']):
|
| 40 |
+
reply = "Great question! I'm a demo of RML-AI, which is pretty amazing. I can chat about AI, technology, science, business, health - you name it! The full system has access to 100GB of knowledge and can answer complex questions with sources. What interests you?"
|
| 41 |
+
|
| 42 |
+
# AI/ML topics
|
| 43 |
+
elif any(word in prompt_lower for word in ['ai', 'artificial intelligence', 'machine learning', 'ml', 'neural', 'deep learning']):
|
| 44 |
+
reply = "Oh, " + prompt + "! That's a fascinating topic. AI and machine learning are changing the world, and RML-AI is actually a revolutionary new approach to AI. The full system would give you detailed, accurate answers with sources from its massive knowledge base. What specifically about AI interests you?"
|
| 45 |
+
|
| 46 |
+
# Technology topics
|
| 47 |
+
elif any(word in prompt_lower for word in ['technology', 'tech', 'computer', 'software', 'programming', 'code']):
|
| 48 |
+
reply = "Technology is incredible, isn't it? " + prompt + " is such an interesting area. The RML-AI system has tons of knowledge about the latest tech developments and can explain complex concepts in simple terms. What aspect of technology would you like to explore?"
|
| 49 |
+
|
| 50 |
+
# Science topics
|
| 51 |
+
elif any(word in prompt_lower for word in ['science', 'research', 'study', 'physics', 'chemistry', 'biology']):
|
| 52 |
+
reply = "Science is amazing! " + prompt + " is a great topic to dive into. The RML-AI system has access to scientific literature and research papers, so it can give you evidence-based answers with proper citations. What scientific topic catches your interest?"
|
| 53 |
+
|
| 54 |
+
# RML-specific questions
|
| 55 |
elif any(word in prompt_lower for word in ['rml', 'resonant', 'memory', 'learning']):
|
| 56 |
+
reply = "RML is what makes this system special! It's Resonant Memory Learning - a completely new way of doing AI that's 100x more efficient and 10x faster than traditional systems. " + prompt + " is exactly the kind of question RML-AI excels at answering with its revolutionary frequency-based approach."
|
| 57 |
+
|
| 58 |
+
# General questions
|
|
|
|
|
|
|
| 59 |
else:
|
| 60 |
+
reply = "That's an interesting question about '" + prompt + "'! I'd love to help you with that. The full RML-AI system would search through its 100GB knowledge base to give you a comprehensive, well-sourced answer. What would you like to know more about?"
|
| 61 |
|
| 62 |
elapsed = int((time.time() - start) * 1000)
|
| 63 |
+
return reply + "\n\n(⏱️ " + str(elapsed) + " ms)\n\n💡 This is a demo. The full RML-AI provides detailed, source-attributed responses!"
|
| 64 |
|
| 65 |
with gr.Blocks(title="RML-AI Demo") as demo:
|
| 66 |
gr.Markdown('''
|