From 4d0b993bd912f2c4f3669b25bc28cdcde603dc52 Mon Sep 17 00:00:00 2001 From: bigbrother666 Date: Sun, 4 Aug 2024 18:26:58 +0800 Subject: [PATCH] add summary to url-info --- core/insights/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/insights/__init__.py b/core/insights/__init__.py index 18be43e..c13e35f 100644 --- a/core/insights/__init__.py +++ b/core/insights/__init__.py @@ -103,7 +103,7 @@ async def pipeline(url: str, cache: Dict[str, str] = {}): async def message_manager(_input: dict): - source = _input['user_id'].split('@')[-1] + source = _input['user_id'] logger.debug(f"received new task, user: {source}, Addition info: {_input['addition']}") if _input['type'] == 'publicMsg': items = item_pattern.findall(_input["content"]) @@ -148,6 +148,9 @@ async def message_manager(_input: dict): logger.warning(f"cannot find url in \n{_input['content']}") return extract_url = item.group(1).replace('amp;', '') - await pipeline(extract_url) + summary_match = re.search(r'(.*?)', _input["content"], re.DOTALL) + summary = summary_match.group(1) if summary_match else None + cache = {'source': source, 'abstract': summary} + await pipeline(extract_url, cache) else: return