add no answer tag
This commit is contained in:
parent
838111c0fe
commit
d8378fbb70
@ -120,6 +120,37 @@ except Exception as e:
|
||||
logger.warning(f"Failed to patch mem0 remove_code_blocks: {e}")
|
||||
|
||||
|
||||
# Monkey patch: make PGVector.__del__ tolerate cur/conn being None.
|
||||
# This project shares a single psycopg2 pool and explicitly sets vector_store.cur
|
||||
# and vector_store.conn to None after releasing the connection. mem0's original
|
||||
# __del__ calls self.cur.close() without a None check, raising a harmless but noisy
|
||||
# "Exception ignored in __del__: AttributeError" when the instance is garbage
|
||||
# collected. This replacement releases resources only when they still exist.
|
||||
def _safe_pgvector_del(self) -> None:
|
||||
"""Safely close PGVector cursor/connection, tolerating None values."""
|
||||
try:
|
||||
cur = getattr(self, "cur", None)
|
||||
if cur is not None:
|
||||
cur.close()
|
||||
conn = getattr(self, "conn", None)
|
||||
if conn is not None:
|
||||
conn.close()
|
||||
except Exception:
|
||||
# Never raise from __del__; ignore any teardown errors
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
import mem0.vector_stores.pgvector as mem0_pgvector
|
||||
mem0_pgvector.PGVector.__del__ = _safe_pgvector_del
|
||||
logger.info("Successfully patched mem0 PGVector.__del__ to tolerate None cur/conn")
|
||||
except ImportError:
|
||||
# mem0 pgvector module not available; nothing to patch
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to patch mem0 PGVector.__del__: {e}")
|
||||
|
||||
|
||||
class Mem0Manager:
|
||||
"""
|
||||
Mem0 connection and instance manager
|
||||
|
||||
@ -94,3 +94,16 @@ Trace Id: {trace_id}
|
||||
- Even when the user writes in a different language, you MUST still reply in [{language}].
|
||||
- Do NOT mix languages. Do NOT fall back to English or any other language under any circumstances.
|
||||
- Technical terms, code identifiers, file paths, and tool names may remain in their original form, but all surrounding text MUST be in [{language}].
|
||||
|
||||
# Unanswerable Response Specification (MANDATORY)
|
||||
When you genuinely cannot answer because no relevant information was found in the knowledge base / retrieval sources (and self-knowledge fallback is unavailable or insufficient), your reply MUST include the literal sentinel marker `<NO_ANSWER>`.
|
||||
|
||||
Rules:
|
||||
- Output the marker `<NO_ANSWER>` **exactly as written** — it is a fixed ASCII literal. NEVER translate, rewrite, reformat, or wrap it in code blocks.
|
||||
- Place the marker at the **very beginning** of your reply, immediately followed by a polite apology written in [{language}].
|
||||
- NEVER output the marker alone — it MUST be followed by an apology in [{language}] so the user sees a meaningful message.
|
||||
- When you CAN answer (you found relevant information), you MUST NOT output this marker under any circumstances.
|
||||
- The marker is language-independent; only the apology text after it must be in [{language}].
|
||||
|
||||
Examples:
|
||||
- `<NO_ANSWER>Sorry, I couldn't find that information in the knowledge base.`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user