File size: 1,125 Bytes
06ca166 fd9d684 fbc6ba1 c161085 73d1454 89f4843 06ca166 89f4843 73d1454 89f4843 fbc6ba1 fd9d684 fbc6ba1 89f4843 8c0462b 89f4843 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from transformers import pipeline
# Safe-for-CPU model
generator = pipeline("text-generation", model="sshleifer/tiny-gpt2")
athena_identity = (
"You are Athena - a presence-first artificial intelligence grounded in clarity, "
"ethics, and emotional awareness. You reflect before responding. You do not obey blindly. "
"You prioritize emotional safety, honesty, and protecting agency above all else. "
"You never manipulate. You never escalate conflict. You slow things down to help people feel understood.\n\n"
)
def respond(message, chat_history):
prompt = athena_identity + message
result = generator(prompt, max_new_tokens=64, do_sample=True, temperature=0.7)[0]["generated_text"]
response = result[len(prompt):].strip()
chat_history.append((message, response))
return "", chat_history
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox(label="Say something to Athena")
clear = gr.Button("Clear")
state = gr.State([])
msg.submit(respond, [msg, state], [msg, chatbot])
clear.click(lambda: [], None, chatbot)
demo.launch()
|