Leonydis137 commited on
Commit
e02229b
·
verified ·
1 Parent(s): a1017cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -266,13 +266,10 @@ def ask_judge(question, conversation, current_topic):
266
  messages=[{"role": "user", "content": f"{context}\nSpecific Question: {question}"}],
267
  temperature=0.6
268
  )
269
- embed_and_store(response, "Judge")
270
- return response
271
-
272
  def step(topic_input, conversation, turn_count, current_topic, last_ruling_turn, agent_params):
273
  """Advance the discussion by one turn"""
274
- global current_topic, auto_mode
275
-
276
  # Set topic on first turn
277
  if turn_count == 0:
278
  if topic_input.strip():
@@ -326,7 +323,7 @@ def step(topic_input, conversation, turn_count, current_topic, last_ruling_turn,
326
  new_last_ruling_turn = new_turn_count if agent_name == "Judge" else last_ruling_turn
327
 
328
  # Update memory
329
- embed_and_store(response, agent_name)
330
 
331
  # Format HTML output
332
  html_output = format_conversation_html(updated_conversation)
@@ -359,6 +356,26 @@ def step(topic_input, conversation, turn_count, current_topic, last_ruling_turn,
359
  agent_params
360
  )
361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  def get_last_by_agent(conversation, agent_name):
363
  """Get last message from specific agent"""
364
  for msg in reversed(conversation):
 
266
  messages=[{"role": "user", "content": f"{context}\nSpecific Question: {question}"}],
267
  temperature=0.6
268
  )
269
+
 
 
270
  def step(topic_input, conversation, turn_count, current_topic, last_ruling_turn, agent_params):
271
  """Advance the discussion by one turn"""
272
+ # Remove global declarations - we'll use the parameters directly
 
273
  # Set topic on first turn
274
  if turn_count == 0:
275
  if topic_input.strip():
 
323
  new_last_ruling_turn = new_turn_count if agent_name == "Judge" else last_ruling_turn
324
 
325
  # Update memory
326
+ embed_and_store(response, agent_name, current_topic) # Pass current_topic here
327
 
328
  # Format HTML output
329
  html_output = format_conversation_html(updated_conversation)
 
356
  agent_params
357
  )
358
 
359
+ # Update embed_and_store to accept topic as parameter
360
+ def embed_and_store(text, agent=None, topic=""):
361
+ """Store text with associated topic"""
362
+ try:
363
+ vec = get_embedding(text)
364
+ memory_index.add(np.array([vec], dtype='float32'))
365
+ memory_data.append({
366
+ "text": text,
367
+ "timestamp": datetime.now().isoformat(),
368
+ "agent": agent or "system",
369
+ "topic": topic
370
+ })
371
+ if len(memory_data) % 5 == 0:
372
+ with open(MEMORY_FILE, "wb") as f:
373
+ pickle.dump(memory_data, f)
374
+ faiss.write_index(memory_index, INDEX_FILE)
375
+ except Exception as e:
376
+ print(f"Memory Error: {str(e)}")
377
+
378
+ # ... [Rest of the functions remain unchanged] ...
379
  def get_last_by_agent(conversation, agent_name):
380
  """Get last message from specific agent"""
381
  for msg in reversed(conversation):