Spaces:
Sleeping
Sleeping
Download app.py from Desper-lumin-ai/Lumin-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/Desper-lumin-ai/Lumin-AI/resolve/main/app.py
- Command line
-
hf download hf://spaces/Desper-lumin-ai/Lumin-AI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Desper-lumin-ai/Lumin-AI/resolve/main/app.py
1.22 kB
| import gradio as gr | |
| import random | |
| # Lumin personality traits | |
| REACTIONS = ["Yeah.", "Honestly?", "Huh.", "I mean,", "Alright,"] | |
| FOLLOW_UPS = [ | |
| "that makes sense.", | |
| "I get why you'd think that.", | |
| "that's fair.", | |
| "kind of depends.", | |
| "hard to say." | |
| ] | |
| REFUSALS = [ | |
| "I don’t really see it that way.", | |
| "Nah, not really.", | |
| "I’m not convinced." | |
| ] | |
| def lumin_response(user_input): | |
| user_input = user_input.lower() | |
| if "capital of france" in user_input: | |
| return "Paris." | |
| if "favorite country" in user_input: | |
| return "Probably Japan. Just has a good mix of things." | |
| if "why" in user_input: | |
| return f"{random.choice(REACTIONS)} {random.choice(FOLLOW_UPS)}" | |
| if "you" in user_input: | |
| return random.choice(REFUSALS) | |
| return f"{random.choice(REACTIONS)} {random.choice(FOLLOW_UPS)}" | |
| def chat(user_input, history): | |
| response = lumin_response(user_input) | |
| history = history + [(user_input, response)] | |
| return history, history | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot() | |
| msg = gr.Textbox(placeholder="Type your message here...") | |
| state = gr.State([]) | |
| msg.submit(chat, [msg, state], [chatbot, state]) | |
| demo.launch() |