lidp
commited on
Commit
·
c89cd5f
1
Parent(s):
9bead83
Add component Concentrator (#2586)
Browse files### What problem does this PR solve?
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
agent/component/__init__.py
CHANGED
@@ -9,6 +9,7 @@ from .relevant import Relevant, RelevantParam
|
|
9 |
from .message import Message, MessageParam
|
10 |
from .rewrite import RewriteQuestion, RewriteQuestionParam
|
11 |
from .keyword import KeywordExtract, KeywordExtractParam
|
|
|
12 |
from .baidu import Baidu, BaiduParam
|
13 |
from .duckduckgo import DuckDuckGo, DuckDuckGoParam
|
14 |
from .wikipedia import Wikipedia, WikipediaParam
|
|
|
9 |
from .message import Message, MessageParam
|
10 |
from .rewrite import RewriteQuestion, RewriteQuestionParam
|
11 |
from .keyword import KeywordExtract, KeywordExtractParam
|
12 |
+
from .concentrator import Concentrator, ConcentratorParam
|
13 |
from .baidu import Baidu, BaiduParam
|
14 |
from .duckduckgo import DuckDuckGo, DuckDuckGoParam
|
15 |
from .wikipedia import Wikipedia, WikipediaParam
|
agent/component/concentrator.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#
|
2 |
+
# Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
#
|
16 |
+
from abc import ABC
|
17 |
+
from agent.component.base import ComponentBase, ComponentParamBase
|
18 |
+
|
19 |
+
|
20 |
+
class ConcentratorParam(ComponentParamBase):
|
21 |
+
"""
|
22 |
+
Define the Concentrator component parameters.
|
23 |
+
"""
|
24 |
+
|
25 |
+
def __init__(self):
|
26 |
+
super().__init__()
|
27 |
+
|
28 |
+
def check(self):
|
29 |
+
super().check()
|
30 |
+
|
31 |
+
|
32 |
+
class Concentrator(ComponentBase, ABC):
|
33 |
+
component_name = "Concentrator"
|
34 |
+
|
35 |
+
def _run(self, history, **kwargs):
|
36 |
+
input = self.get_input()
|
37 |
+
ans = " - ".join(input["content"]) if "content" in input else ""
|
38 |
+
if not ans:
|
39 |
+
return Concentrator.be_output("")
|
40 |
+
|
41 |
+
return Concentrator.be_output(input)
|