| import gradio as gr |
| from engine import extract_memory, PersonalityEngine, call_llm |
|
|
| chat_history = [ |
| {"role": "user", "content": "Hey, I'm Tharun, a 4th year student at IIT Kharagpur."}, |
| {"role": "assistant", "content": "Hi Tharun! Great to meet you."}, |
| {"role": "user", "content": "I enjoy working with React and Tailwind."}, |
| {"role": "assistant", "content": "That’s a great combination!"} |
| ] |
|
|
| def run_system(user_message, style): |
| memory = extract_memory(chat_history) |
| neutral = call_llm("You are a neutral assistant.", user_message) |
| engine = PersonalityEngine(style, memory) |
| styled = engine.transform(user_message, neutral) |
| return str(memory), neutral, styled |
|
|
| ui = gr.Interface( |
| fn=run_system, |
| inputs=[ |
| gr.Textbox(label="Enter your message"), |
| gr.Dropdown( |
| ["neutral", "calm_mentor", "witty_friend", "therapist_style"], |
| label="Choose Personality Style" |
| ) |
| ], |
| outputs=[ |
| gr.Textbox(label="Extracted Memory"), |
| gr.Textbox(label="Neutral Reply"), |
| gr.Textbox(label="Styled Reply") |
| ], |
| title="GuppShupp Assignment — Memory + Personality Engine" |
| ) |
|
|
| ui.launch() |
|
|