Bug fix of thinking llm in vllm (#3510)
This commit is contained in:
@@ -889,6 +889,7 @@ class Memory(MemoryBase):
|
||||
|
||||
try:
|
||||
procedural_memory = 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
|
||||
@@ -1784,6 +1785,8 @@ class AsyncMemory(MemoryBase):
|
||||
procedural_memory = response.content
|
||||
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
|
||||
|
||||
@@ -43,7 +43,9 @@ def remove_code_blocks(content: str) -> str:
|
||||
"""
|
||||
pattern = r"^```[a-zA-Z0-9]*\n([\s\S]*?)\n```$"
|
||||
match = re.match(pattern, content.strip())
|
||||
return match.group(1).strip() if match else content.strip()
|
||||
match_res=match.group(1).strip() if match else content.strip()
|
||||
return re.sub(r"<think>.*?</think>", "", match_res, flags=re.DOTALL).strip()
|
||||
|
||||
|
||||
|
||||
def extract_json(text):
|
||||
@@ -182,3 +184,4 @@ def sanitize_relationship_for_cypher(relationship) -> str:
|
||||
sanitized = sanitized.replace(old, new)
|
||||
|
||||
return re.sub(r"_+", "_", sanitized).strip("_")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user