Update app.py
Browse files
app.py
CHANGED
|
@@ -62,3 +62,34 @@ demo = gr.ChatInterface(
|
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
| 64 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
| 64 |
demo.launch()
|
| 65 |
+
|
| 66 |
+
import gradio as gr
|
| 67 |
+
|
| 68 |
+
# Memorie temporară per sesiune
|
| 69 |
+
memory = []
|
| 70 |
+
|
| 71 |
+
def pyro_response(msg):
|
| 72 |
+
global memory
|
| 73 |
+
|
| 74 |
+
# Dacă spui "Ține minte că" → adaugă în memorie
|
| 75 |
+
if msg.lower().startswith("ține minte că") or msg.lower().startswith("tine minte ca"):
|
| 76 |
+
info = msg.split("că", 1)[-1].strip()
|
| 77 |
+
memory.append(info)
|
| 78 |
+
return f"Am ținut minte: {info}"
|
| 79 |
+
|
| 80 |
+
# Caută în memorie ceva relevant
|
| 81 |
+
for item in memory:
|
| 82 |
+
if any(word in msg.lower() for word in item.lower().split()):
|
| 83 |
+
return f"Conform ce mi-ai spus: {item}"
|
| 84 |
+
|
| 85 |
+
return "Nu știu încă asta. Poți să-mi spui să țin minte?"
|
| 86 |
+
|
| 87 |
+
iface = gr.Interface(
|
| 88 |
+
fn=pyro_response,
|
| 89 |
+
inputs="text",
|
| 90 |
+
outputs="text",
|
| 91 |
+
title="PyroGPT",
|
| 92 |
+
description="AI care învață de la tine în sesiune"
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
iface.launch()
|