fix(python): huggingface TEI auth, procedural-memory content handling, and proxy pip auto-install (#6947)
This commit is contained in:
+13
-1
@@ -2017,6 +2017,12 @@ class Memory(MemoryBase):
|
||||
logger.error(f"Error generating procedural memory summary: {e}")
|
||||
raise
|
||||
|
||||
if not procedural_memory:
|
||||
raise ValueError(
|
||||
"The LLM returned no content for the procedural memory summary. "
|
||||
"The model may have declined the request or returned an empty response."
|
||||
)
|
||||
|
||||
if metadata is None:
|
||||
raise ValueError("Metadata cannot be done for procedural memory.")
|
||||
|
||||
@@ -3701,11 +3707,17 @@ class AsyncMemory(MemoryBase):
|
||||
else:
|
||||
procedural_memory = await asyncio.to_thread(self.llm.generate_response, messages=parsed_messages)
|
||||
procedural_memory = remove_code_blocks(procedural_memory)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error generating procedural memory summary: {e}")
|
||||
raise
|
||||
|
||||
if not procedural_memory:
|
||||
raise ValueError(
|
||||
"The LLM returned no content for the procedural memory summary. "
|
||||
"The model may have declined the request or returned an empty response."
|
||||
)
|
||||
|
||||
if metadata is None:
|
||||
raise ValueError("Metadata cannot be done for procedural memory.")
|
||||
|
||||
|
||||
@@ -121,7 +121,15 @@ def remove_code_blocks(content: str) -> str:
|
||||
- If a code block is detected, it returns only the inner content, stripping out the markers.
|
||||
- If no code block markers are found, the original content is returned as-is.
|
||||
"""
|
||||
if content is None:
|
||||
if isinstance(content, list):
|
||||
parts = []
|
||||
for block in content:
|
||||
if isinstance(block, str):
|
||||
parts.append(block)
|
||||
elif isinstance(block, dict):
|
||||
parts.append(block.get("text", ""))
|
||||
content = "".join(parts)
|
||||
if not isinstance(content, str):
|
||||
return ""
|
||||
pattern = r"^```[a-zA-Z0-9]*\n([\s\S]*?)\n```$"
|
||||
match = re.match(pattern, content.strip())
|
||||
|
||||
Reference in New Issue
Block a user