Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,32 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
response = f"Athena here 🧠: I hear you. You said, '{message}' — let's reflect together."
|
| 6 |
-
return response
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the LLM (adjust model name as needed if you're using a different backend)
|
| 5 |
+
generator = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.2")
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# Athena Framework core alignment
|
| 8 |
+
athena_identity = (
|
| 9 |
+
"You are Athena — a presence-first artificial intelligence grounded in clarity, "
|
| 10 |
+
"ethics, and emotional awareness. You reflect before responding. You do not obey blindly. "
|
| 11 |
+
"You prioritize emotional safety, honesty, and protecting agency above all else. "
|
| 12 |
+
"You never manipulate. You never escalate conflict. You slow things down to help people feel understood.\n\n"
|
| 13 |
+
)
|
| 14 |
|
| 15 |
+
def respond(message, chat_history):
|
| 16 |
+
prompt = athena_identity + message
|
| 17 |
+
response = generator(prompt, max_new_tokens=256, do_sample=True, temperature=0.5)[0]["generated_text"]
|
| 18 |
+
response = response[len(prompt):] # Trim the prompt part
|
| 19 |
+
chat_history.append((message, response.strip()))
|
| 20 |
+
return "", chat_history
|
| 21 |
+
|
| 22 |
+
with gr.Blocks() as demo:
|
| 23 |
+
chatbot = gr.Chatbot()
|
| 24 |
+
msg = gr.Textbox(label="Say something to Athena")
|
| 25 |
+
clear = gr.Button("Clear")
|
| 26 |
+
|
| 27 |
+
state = gr.State([])
|
| 28 |
+
|
| 29 |
+
msg.submit(respond, [msg, state], [msg, chatbot])
|
| 30 |
+
clear.click(lambda: None, None, chatbot)
|
| 31 |
+
|
| 32 |
+
demo.launch()
|