feat:add summary label

This commit is contained in:
aries_ckt 2023-11-14 22:17:05 +08:00
parent 99fb07a8c0
commit 85da219a0a
4 changed files with 22 additions and 13 deletions

View File

@ -83,7 +83,7 @@ async def agent_hub_update(update_param: PluginHubParam = Body()):
return Result.succ(None)
except Exception as e:
logger.error("Agent Hub Update Error!", e)
return Result.faild(code="E0020", msg=f"Agent Hub Update Error! {e}")
return Result.failed(code="E0020", msg=f"Agent Hub Update Error! {e}")
@router.post("/v1/agent/query", response_model=Result[str])
@ -133,7 +133,7 @@ async def agent_install(plugin_name: str, user: str = None):
return Result.succ(None)
except Exception as e:
logger.error("Plugin Install Error!", e)
return Result.faild(code="E0021", msg=f"Plugin Install Error {e}")
return Result.failed(code="E0021", msg=f"Plugin Install Error {e}")
@router.post("/v1/agent/uninstall", response_model=Result[str])
@ -147,7 +147,7 @@ async def agent_uninstall(plugin_name: str, user: str = None):
return Result.succ(None)
except Exception as e:
logger.error("Plugin Uninstall Error!", e)
return Result.faild(code="E0022", msg=f"Plugin Uninstall Error {e}")
return Result.failed(code="E0022", msg=f"Plugin Uninstall Error {e}")
@router.post("/v1/personal/agent/upload", response_model=Result[str])
@ -160,4 +160,4 @@ async def personal_agent_upload(doc_file: UploadFile = File(...), user: str = No
return Result.succ(None)
except Exception as e:
logger.error("Upload Personal Plugin Error!", e)
return Result.faild(code="E0023", msg=f"Upload Personal Plugin Error {e}")
return Result.failed(code="E0023", msg=f"Upload Personal Plugin Error {e}")

View File

@ -32,6 +32,19 @@ class ExtractRefineSummary(BaseChat):
}
return input_values
# async def stream_call(self):
# last_output = None
# async for output in super().stream_call():
# last_output = output
# yield output
#
# last_output = f"<summary>{last_output}</summary>"
# yield last_output
def stream_call_reinforce_fn(self, text):
"""return reference"""
return f"<summary>{text}</summary>"
@property
def chat_type(self) -> str:
return ChatScene.ExtractRefineSummary.value

View File

@ -245,15 +245,8 @@ async def document_summary(request: DocumentSummaryRequest):
headers=headers,
media_type="text/plain",
)
# return Result.succ(
# knowledge_space_service.create_knowledge_document(
# space=space_name, request=request
# )
# )
# return Result.succ([])
except Exception as e:
return Result.faild(code="E000X", msg=f"document summary error {e}")
return Result.failed(code="E000X", msg=f"document summary error {e}")
@router.post("/knowledge/entity/extract")
@ -276,4 +269,4 @@ async def entity_extract(request: EntityExtractRequest):
)
return Result.succ(res)
except Exception as e:
return Result.faild(code="E000X", msg=f"entity extract error {e}")
return Result.failed(code="E000X", msg=f"entity extract error {e}")

View File

@ -576,6 +576,9 @@ class KnowledgeService:
reduce -> merge the summaries by map process
Args:
docs:List[str]
model_name:model name str
max_iteration:max iteration will call llm to summary
concurrency_limit:the max concurrency threads to call llm
"""
from pilot.scene.base import ChatScene
from pilot.common.chat_util import llm_chat_response_nostream