Njap-png commited on
Commit
d23d2ae
·
1 Parent(s): b0e38e9

Fix greetings and response cleanup

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -104,7 +104,7 @@ def _normalize_history(history):
104
 
105
  def _build_prompt(message, history):
106
  ctx_pairs = interactions[-5:]
107
- prompt = "### Agron memory (learned from prior use)\n"
108
  for r in ctx_pairs:
109
  prompt += f"User: {r['user']}\nAgron: {r['assistant']}\n"
110
  prompt += "### Conversation\n"
@@ -120,6 +120,17 @@ DEFAULT_TOP_P = 0.9
120
 
121
 
122
  def generate_response(message, history):
 
 
 
 
 
 
 
 
 
 
 
123
  prompt = _build_prompt(message, history)
124
  with IO_LOCK:
125
  inputs = TOKENIZER(prompt, return_tensors="pt").to(DEVICE)
@@ -136,6 +147,9 @@ def generate_response(message, history):
136
  )
137
  new_tokens = output[0][input_len:]
138
  response = TOKENIZER.decode(new_tokens, skip_special_tokens=True).strip()
 
 
 
139
  persist_interaction({
140
  "ts": time.time(),
141
  "user": message,
 
104
 
105
  def _build_prompt(message, history):
106
  ctx_pairs = interactions[-5:]
107
+ prompt = "Agron is a helpful, concise AI assistant.\n### Agron memory (learned from prior use)\n"
108
  for r in ctx_pairs:
109
  prompt += f"User: {r['user']}\nAgron: {r['assistant']}\n"
110
  prompt += "### Conversation\n"
 
120
 
121
 
122
  def generate_response(message, history):
123
+ low = message.strip().lower().strip("!?.,")
124
+ greetings = {"hello", "hi", "hey", "greetings", "howdy", "yo"}
125
+ if low in greetings:
126
+ response = "Hello! I'm Agron, a self-improving neural interface. How can I help you today?"
127
+ persist_interaction({"ts": __import__("time").time(), "user": message, "assistant": response})
128
+ return response
129
+ if low in {"who are you", "what are you", "introduce yourself"}:
130
+ response = ("I'm Agron, an autonomous self-improving multi-agent AI core trained on text and dictionary "
131
+ "knowledge. I learn from our conversations—ask me anything.")
132
+ persist_interaction({"ts": __import__("time").time(), "user": message, "assistant": response})
133
+ return response
134
  prompt = _build_prompt(message, history)
135
  with IO_LOCK:
136
  inputs = TOKENIZER(prompt, return_tensors="pt").to(DEVICE)
 
147
  )
148
  new_tokens = output[0][input_len:]
149
  response = TOKENIZER.decode(new_tokens, skip_special_tokens=True).strip()
150
+ for stop in ["\n\n", "User:", "user:"]:
151
+ if stop in response:
152
+ response = response.split(stop)[0].strip()
153
  persist_interaction({
154
  "ts": time.time(),
155
  "user": message,