Kevin Hu
commited on
Commit
·
eb1f8d0
1
Parent(s):
f815c96
Update gif for readme and add input param to every components (#3145)
Browse files### What problem does this PR solve?
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Documentation Update
- README.md +2 -1
- README_ja.md +2 -1
- README_ko.md +3 -1
- README_zh.md +2 -1
- agent/component/base.py +11 -0
- agent/component/generate.py +2 -0
- agent/component/invoke.py +3 -0
- agent/templates/HR_callout_zh.json +22 -6
README.md
CHANGED
@@ -69,11 +69,12 @@ data.
|
|
69 |
Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
|
70 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
71 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
72 |
-
<img src="https://github.com/
|
73 |
</div>
|
74 |
|
75 |
## 🔥 Latest Updates
|
76 |
|
|
|
77 |
- 2024-09-29 Optimizes multi-round conversations.
|
78 |
- 2024-09-13 Adds search mode for knowledge base Q&A.
|
79 |
- 2024-09-09 Adds a medical consultant agent template.
|
|
|
69 |
Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
|
70 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
71 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
72 |
+
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
|
73 |
</div>
|
74 |
|
75 |
## 🔥 Latest Updates
|
76 |
|
77 |
+
- 2024-11-01 Adds keyword extraction and related question generation to the parsed chunk to improve the accuracy of retrieval.
|
78 |
- 2024-09-29 Optimizes multi-round conversations.
|
79 |
- 2024-09-13 Adds search mode for knowledge base Q&A.
|
80 |
- 2024-09-09 Adds a medical consultant agent template.
|
README_ja.md
CHANGED
@@ -47,12 +47,13 @@
|
|
47 |
デモをお試しください:[https://demo.ragflow.io](https://demo.ragflow.io)。
|
48 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
49 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
50 |
-
<img src="https://github.com/
|
51 |
</div>
|
52 |
|
53 |
|
54 |
## 🔥 最新情報
|
55 |
|
|
|
56 |
- 2024-09-29 マルチラウンドダイアログを最適化。
|
57 |
- 2024-09-13 ナレッジベース Q&A の検索モードを追加しました。
|
58 |
- 2024-09-09 エージェントに医療相談テンプレートを追加しました。
|
|
|
47 |
デモをお試しください:[https://demo.ragflow.io](https://demo.ragflow.io)。
|
48 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
49 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
50 |
+
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
|
51 |
</div>
|
52 |
|
53 |
|
54 |
## 🔥 最新情報
|
55 |
|
56 |
+
- 2024-11-01 再現の精度を向上させるために、解析されたチャンクにキーワード抽出と関連質問の生成を追加しました。
|
57 |
- 2024-09-29 マルチラウンドダイアログを最適化。
|
58 |
- 2024-09-13 ナレッジベース Q&A の検索モードを追加しました。
|
59 |
- 2024-09-09 エージェントに医療相談テンプレートを追加しました。
|
README_ko.md
CHANGED
@@ -49,12 +49,14 @@
|
|
49 |
데모를 [https://demo.ragflow.io](https://demo.ragflow.io)에서 실행해 보세요.
|
50 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
51 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
52 |
-
<img src="https://github.com/
|
53 |
</div>
|
54 |
|
55 |
|
56 |
## 🔥 업데이트
|
57 |
|
|
|
|
|
58 |
- 2024-09-29 다단계 대화를 최적화합니다.
|
59 |
|
60 |
- 2024-09-13 지식베이스 Q&A 검색 모드를 추가합니다.
|
|
|
49 |
데모를 [https://demo.ragflow.io](https://demo.ragflow.io)에서 실행해 보세요.
|
50 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
51 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
52 |
+
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
|
53 |
</div>
|
54 |
|
55 |
|
56 |
## 🔥 업데이트
|
57 |
|
58 |
+
- 2024-11-01 파싱된 청크에 키워드 추출 및 관련 질문 생성을 추가하여 재현율을 향상시킵니다.
|
59 |
+
|
60 |
- 2024-09-29 다단계 대화를 최적화합니다.
|
61 |
|
62 |
- 2024-09-13 지식베이스 Q&A 검색 모드를 추가합니다.
|
README_zh.md
CHANGED
@@ -47,12 +47,13 @@
|
|
47 |
请登录网址 [https://demo.ragflow.io](https://demo.ragflow.io) 试用 demo。
|
48 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
49 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
50 |
-
<img src="https://github.com/
|
51 |
</div>
|
52 |
|
53 |
|
54 |
## 🔥 近期更新
|
55 |
|
|
|
56 |
- 2024-09-29 优化多轮对话.
|
57 |
- 2024-09-13 增加知识库问答搜索模式。
|
58 |
- 2024-09-09 在 Agent 中加入医疗问诊模板。
|
|
|
47 |
请登录网址 [https://demo.ragflow.io](https://demo.ragflow.io) 试用 demo。
|
48 |
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
49 |
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
|
50 |
+
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
|
51 |
</div>
|
52 |
|
53 |
|
54 |
## 🔥 近期更新
|
55 |
|
56 |
+
- 2024-11-01 对解析后的chunk加入关键词抽取和相关问题生成以提高召回的准确度。
|
57 |
- 2024-09-29 优化多轮对话.
|
58 |
- 2024-09-13 增加知识库问答搜索模式。
|
59 |
- 2024-09-09 在 Agent 中加入医疗问诊模板。
|
agent/component/base.py
CHANGED
@@ -36,6 +36,7 @@ class ComponentParamBase(ABC):
|
|
36 |
def __init__(self):
|
37 |
self.output_var_name = "output"
|
38 |
self.message_history_window_size = 22
|
|
|
39 |
|
40 |
def set_name(self, name: str):
|
41 |
self._name = name
|
@@ -436,6 +437,16 @@ class ComponentBase(ABC):
|
|
436 |
setattr(self._param, self._param.output_var_name, v)
|
437 |
|
438 |
def get_input(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
upstream_outs = []
|
440 |
reversed_cpnts = []
|
441 |
if len(self._canvas.path) > 1:
|
|
|
36 |
def __init__(self):
|
37 |
self.output_var_name = "output"
|
38 |
self.message_history_window_size = 22
|
39 |
+
self.query = []
|
40 |
|
41 |
def set_name(self, name: str):
|
42 |
self._name = name
|
|
|
437 |
setattr(self._param, self._param.output_var_name, v)
|
438 |
|
439 |
def get_input(self):
|
440 |
+
if self._param.query:
|
441 |
+
outs = []
|
442 |
+
for q in self._param.query:
|
443 |
+
if q["value"]: outs.append(pd.DataFrame([{"content": q["value"]}]))
|
444 |
+
if q["component_id"]: outs.append(self._canvas.get_component(q["component_id"])["obj"].output(allow_partial=False)[1])
|
445 |
+
if outs:
|
446 |
+
df = pd.concat(outs, ignore_index=True)
|
447 |
+
if "content" in df: df = df.drop_duplicates(subset=['content']).reset_index(drop=True)
|
448 |
+
return df
|
449 |
+
|
450 |
upstream_outs = []
|
451 |
reversed_cpnts = []
|
452 |
if len(self._canvas.path) > 1:
|
agent/component/generate.py
CHANGED
@@ -130,6 +130,7 @@ class Generate(ComponentBase):
|
|
130 |
|
131 |
msg = self._canvas.get_history(self._param.message_history_window_size)
|
132 |
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
|
|
|
133 |
ans = chat_mdl.chat(msg[0]["content"], msg[1:], self._param.gen_conf())
|
134 |
|
135 |
if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
|
@@ -149,6 +150,7 @@ class Generate(ComponentBase):
|
|
149 |
|
150 |
msg = self._canvas.get_history(self._param.message_history_window_size)
|
151 |
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
|
|
|
152 |
answer = ""
|
153 |
for ans in chat_mdl.chat_streamly(msg[0]["content"], msg[1:], self._param.gen_conf()):
|
154 |
res = {"content": ans, "reference": []}
|
|
|
130 |
|
131 |
msg = self._canvas.get_history(self._param.message_history_window_size)
|
132 |
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
|
133 |
+
if len(msg) < 2: msg.append({"role": "user", "content": ""})
|
134 |
ans = chat_mdl.chat(msg[0]["content"], msg[1:], self._param.gen_conf())
|
135 |
|
136 |
if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
|
|
|
150 |
|
151 |
msg = self._canvas.get_history(self._param.message_history_window_size)
|
152 |
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
|
153 |
+
if len(msg) < 2: msg.append({"role": "user", "content": ""})
|
154 |
answer = ""
|
155 |
for ans in chat_mdl.chat_streamly(msg[0]["content"], msg[1:], self._param.gen_conf()):
|
156 |
res = {"content": ans, "reference": []}
|
agent/component/invoke.py
CHANGED
@@ -51,6 +51,9 @@ class Invoke(ComponentBase, ABC):
|
|
51 |
for para in self._param.variables:
|
52 |
if para.get("component_id"):
|
53 |
cpn = self._canvas.get_component(para["component_id"])["obj"]
|
|
|
|
|
|
|
54 |
_, out = cpn.output(allow_partial=False)
|
55 |
args[para["key"]] = "\n".join(out["content"])
|
56 |
else:
|
|
|
51 |
for para in self._param.variables:
|
52 |
if para.get("component_id"):
|
53 |
cpn = self._canvas.get_component(para["component_id"])["obj"]
|
54 |
+
if cpn.component_name.lower() == "answer":
|
55 |
+
args[para["key"]] = self._canvas.get_history(1)[0]["content"]
|
56 |
+
continue
|
57 |
_, out = cpn.output(allow_partial=False)
|
58 |
args[para["key"]] = "\n".join(out["content"])
|
59 |
else:
|
agent/templates/HR_callout_zh.json
CHANGED
@@ -152,7 +152,8 @@
|
|
152 |
"Generate:ToughLawsCheat",
|
153 |
"Generate:KindCarrotsSit",
|
154 |
"Generate:DirtyToolsTrain",
|
155 |
-
"Generate:FluffyPillowsGrow"
|
|
|
156 |
]
|
157 |
},
|
158 |
"Retrieval:ShaggyRadiosRetire": {
|
@@ -212,7 +213,9 @@
|
|
212 |
"top_p": 0.3
|
213 |
}
|
214 |
},
|
215 |
-
"downstream": [
|
|
|
|
|
216 |
"upstream": [
|
217 |
"categorize:0"
|
218 |
]
|
@@ -331,9 +334,9 @@
|
|
331 |
"message_history_window_size": 12,
|
332 |
"parameters": [
|
333 |
{
|
|
|
334 |
"id": "5166a107-e859-4c71-99a2-3a216c775347",
|
335 |
-
"key": "jd"
|
336 |
-
"component_id": "Retrieval:ColdEelsArrive"
|
337 |
}
|
338 |
],
|
339 |
"presence_penalty": 0.4,
|
@@ -1266,9 +1269,9 @@
|
|
1266 |
"parameter": "Precise",
|
1267 |
"parameters": [
|
1268 |
{
|
|
|
1269 |
"id": "5166a107-e859-4c71-99a2-3a216c775347",
|
1270 |
-
"key": "jd"
|
1271 |
-
"component_id": "Retrieval:ColdEelsArrive"
|
1272 |
}
|
1273 |
],
|
1274 |
"presencePenaltyEnabled": true,
|
@@ -1541,6 +1544,19 @@
|
|
1541 |
"target": "Answer:TwentyMugsDeny",
|
1542 |
"targetHandle": "c",
|
1543 |
"type": "buttonEdge"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1544 |
}
|
1545 |
]
|
1546 |
},
|
|
|
152 |
"Generate:ToughLawsCheat",
|
153 |
"Generate:KindCarrotsSit",
|
154 |
"Generate:DirtyToolsTrain",
|
155 |
+
"Generate:FluffyPillowsGrow",
|
156 |
+
"Generate:ProudEarsWorry"
|
157 |
]
|
158 |
},
|
159 |
"Retrieval:ShaggyRadiosRetire": {
|
|
|
213 |
"top_p": 0.3
|
214 |
}
|
215 |
},
|
216 |
+
"downstream": [
|
217 |
+
"Answer:TwentyMugsDeny"
|
218 |
+
],
|
219 |
"upstream": [
|
220 |
"categorize:0"
|
221 |
]
|
|
|
334 |
"message_history_window_size": 12,
|
335 |
"parameters": [
|
336 |
{
|
337 |
+
"component_id": "Retrieval:ColdEelsArrive",
|
338 |
"id": "5166a107-e859-4c71-99a2-3a216c775347",
|
339 |
+
"key": "jd"
|
|
|
340 |
}
|
341 |
],
|
342 |
"presence_penalty": 0.4,
|
|
|
1269 |
"parameter": "Precise",
|
1270 |
"parameters": [
|
1271 |
{
|
1272 |
+
"component_id": "Retrieval:ColdEelsArrive",
|
1273 |
"id": "5166a107-e859-4c71-99a2-3a216c775347",
|
1274 |
+
"key": "jd"
|
|
|
1275 |
}
|
1276 |
],
|
1277 |
"presencePenaltyEnabled": true,
|
|
|
1544 |
"target": "Answer:TwentyMugsDeny",
|
1545 |
"targetHandle": "c",
|
1546 |
"type": "buttonEdge"
|
1547 |
+
},
|
1548 |
+
{
|
1549 |
+
"type": "buttonEdge",
|
1550 |
+
"markerEnd": "logo",
|
1551 |
+
"style": {
|
1552 |
+
"strokeWidth": 2,
|
1553 |
+
"stroke": "rgb(202 197 245)"
|
1554 |
+
},
|
1555 |
+
"source": "Generate:ProudEarsWorry",
|
1556 |
+
"sourceHandle": "b",
|
1557 |
+
"target": "Answer:TwentyMugsDeny",
|
1558 |
+
"targetHandle": "c",
|
1559 |
+
"id": "reactflow__edge-Generate:ProudEarsWorryb-Answer:TwentyMugsDenyc"
|
1560 |
}
|
1561 |
]
|
1562 |
},
|