mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-22 07:56:48 +00:00
update the code with review comments
This commit is contained in:
@@ -194,7 +194,7 @@ class DeerFlowSummarizationMiddleware(SummarizationMiddleware):
|
||||
formatted = get_buffer_string(trimmed)
|
||||
|
||||
try:
|
||||
response = self.model.invoke(
|
||||
response = self.model.with_config(callbacks=[]).invoke(
|
||||
self.summary_prompt.format(messages=formatted).rstrip(),
|
||||
config={
|
||||
"metadata": {"lc_source": "summarization"},
|
||||
@@ -223,7 +223,7 @@ class DeerFlowSummarizationMiddleware(SummarizationMiddleware):
|
||||
formatted = get_buffer_string(trimmed)
|
||||
|
||||
try:
|
||||
response = await self.model.ainvoke(
|
||||
response = await self.model.with_config(callbacks=[]).ainvoke(
|
||||
self.summary_prompt.format(messages=formatted).rstrip(),
|
||||
config={
|
||||
"metadata": {"lc_source": "summarization"},
|
||||
@@ -235,9 +235,11 @@ class DeerFlowSummarizationMiddleware(SummarizationMiddleware):
|
||||
return f"Error generating summary: {e!s}"
|
||||
|
||||
def _extract_summary_text(self, response: Any) -> str:
|
||||
summary_text = getattr(response, "content", None)
|
||||
# Prefer .text which normalizes list content blocks (e.g. [{"type": "text", "text": "..."}]).
|
||||
# Fall back to .content for non-LangChain responses.
|
||||
summary_text = getattr(response, "text", None)
|
||||
if summary_text is None:
|
||||
summary_text = getattr(response, "text", "")
|
||||
summary_text = getattr(response, "content", "")
|
||||
return summary_text.strip() if isinstance(summary_text, str) else str(summary_text).strip()
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user