Skip to content

Commit

Permalink
Update gif for readme and add input param to every components (#3145)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?


### Type of change

- [x] New Feature (non-breaking change which adds functionality)
- [x] Documentation Update
  • Loading branch information
KevinHuSh authored Nov 1, 2024
1 parent 039cde7 commit 33e5e5d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ data.
Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
<div align="center" style="margin-top:20px;margin-bottom:20px;">
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
<img src="https://github.com/infiniflow/ragflow/assets/12318111/b083d173-dadc-4ea9-bdeb-180d7df514eb" width="1200"/>
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
</div>

## 🔥 Latest Updates

- 2024-11-01 Adds keyword extraction and related question generation to the parsed chunk to improve the accuracy of retrieval.
- 2024-09-29 Optimizes multi-round conversations.
- 2024-09-13 Adds search mode for knowledge base Q&A.
- 2024-09-09 Adds a medical consultant agent template.
Expand Down
3 changes: 2 additions & 1 deletion README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
デモをお試しください:[https://demo.ragflow.io](https://demo.ragflow.io)
<div align="center" style="margin-top:20px;margin-bottom:20px;">
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
<img src="https://github.com/infiniflow/ragflow/assets/12318111/b083d173-dadc-4ea9-bdeb-180d7df514eb" width="1200"/>
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
</div>


## 🔥 最新情報

- 2024-11-01 再現の精度を向上させるために、解析されたチャンクにキーワード抽出と関連質問の生成を追加しました。
- 2024-09-29 マルチラウンドダイアログを最適化。
- 2024-09-13 ナレッジベース Q&A の検索モードを追加しました。
- 2024-09-09 エージェントに医療相談テンプレートを追加しました。
Expand Down
4 changes: 3 additions & 1 deletion README_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
데모를 [https://demo.ragflow.io](https://demo.ragflow.io)에서 실행해 보세요.
<div align="center" style="margin-top:20px;margin-bottom:20px;">
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
<img src="https://github.com/infiniflow/ragflow/assets/12318111/b083d173-dadc-4ea9-bdeb-180d7df514eb" width="1200"/>
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
</div>


## 🔥 업데이트

- 2024-11-01 파싱된 청크에 키워드 추출 및 관련 질문 생성을 추가하여 재현율을 향상시킵니다.

- 2024-09-29 다단계 대화를 최적화합니다.

- 2024-09-13 지식베이스 Q&A 검색 모드를 추가합니다.
Expand Down
3 changes: 2 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
请登录网址 [https://demo.ragflow.io](https://demo.ragflow.io) 试用 demo。
<div align="center" style="margin-top:20px;margin-bottom:20px;">
<img src="https://github.com/infiniflow/ragflow/assets/7248/2f6baa3e-1092-4f11-866d-36f6a9d075e5" width="1200"/>
<img src="https://github.com/infiniflow/ragflow/assets/12318111/b083d173-dadc-4ea9-bdeb-180d7df514eb" width="1200"/>
<img src="https://github.com/user-attachments/assets/504bbbf1-c9f7-4d83-8cc5-e9cb63c26db6" width="1200"/>
</div>


## 🔥 近期更新

- 2024-11-01 对解析后的chunk加入关键词抽取和相关问题生成以提高召回的准确度。
- 2024-09-29 优化多轮对话.
- 2024-09-13 增加知识库问答搜索模式。
- 2024-09-09 在 Agent 中加入医疗问诊模板。
Expand Down
11 changes: 11 additions & 0 deletions agent/component/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ComponentParamBase(ABC):
def __init__(self):
self.output_var_name = "output"
self.message_history_window_size = 22
self.query = []

def set_name(self, name: str):
self._name = name
Expand Down Expand Up @@ -436,6 +437,16 @@ def set_output(self, v: pd.DataFrame):
setattr(self._param, self._param.output_var_name, v)

def get_input(self):
if self._param.query:
outs = []
for q in self._param.query:
if q["value"]: outs.append(pd.DataFrame([{"content": q["value"]}]))
if q["component_id"]: outs.append(self._canvas.get_component(q["component_id"])["obj"].output(allow_partial=False)[1])
if outs:
df = pd.concat(outs, ignore_index=True)
if "content" in df: df = df.drop_duplicates(subset=['content']).reset_index(drop=True)
return df

upstream_outs = []
reversed_cpnts = []
if len(self._canvas.path) > 1:
Expand Down
2 changes: 2 additions & 0 deletions agent/component/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def _run(self, history, **kwargs):

msg = self._canvas.get_history(self._param.message_history_window_size)
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
if len(msg) < 2: msg.append({"role": "user", "content": ""})
ans = chat_mdl.chat(msg[0]["content"], msg[1:], self._param.gen_conf())

if self._param.cite and "content_ltks" in retrieval_res.columns and "vector" in retrieval_res.columns:
Expand All @@ -149,6 +150,7 @@ def stream_output(self, chat_mdl, prompt, retrieval_res):

msg = self._canvas.get_history(self._param.message_history_window_size)
_, msg = message_fit_in([{"role": "system", "content": prompt}, *msg], int(chat_mdl.max_length * 0.97))
if len(msg) < 2: msg.append({"role": "user", "content": ""})
answer = ""
for ans in chat_mdl.chat_streamly(msg[0]["content"], msg[1:], self._param.gen_conf()):
res = {"content": ans, "reference": []}
Expand Down
3 changes: 3 additions & 0 deletions agent/component/invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def _run(self, history, **kwargs):
for para in self._param.variables:
if para.get("component_id"):
cpn = self._canvas.get_component(para["component_id"])["obj"]
if cpn.component_name.lower() == "answer":
args[para["key"]] = self._canvas.get_history(1)[0]["content"]
continue
_, out = cpn.output(allow_partial=False)
args[para["key"]] = "\n".join(out["content"])
else:
Expand Down
28 changes: 22 additions & 6 deletions agent/templates/HR_callout_zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@
"Generate:ToughLawsCheat",
"Generate:KindCarrotsSit",
"Generate:DirtyToolsTrain",
"Generate:FluffyPillowsGrow"
"Generate:FluffyPillowsGrow",
"Generate:ProudEarsWorry"
]
},
"Retrieval:ShaggyRadiosRetire": {
Expand Down Expand Up @@ -212,7 +213,9 @@
"top_p": 0.3
}
},
"downstream": [],
"downstream": [
"Answer:TwentyMugsDeny"
],
"upstream": [
"categorize:0"
]
Expand Down Expand Up @@ -331,9 +334,9 @@
"message_history_window_size": 12,
"parameters": [
{
"component_id": "Retrieval:ColdEelsArrive",
"id": "5166a107-e859-4c71-99a2-3a216c775347",
"key": "jd",
"component_id": "Retrieval:ColdEelsArrive"
"key": "jd"
}
],
"presence_penalty": 0.4,
Expand Down Expand Up @@ -1266,9 +1269,9 @@
"parameter": "Precise",
"parameters": [
{
"component_id": "Retrieval:ColdEelsArrive",
"id": "5166a107-e859-4c71-99a2-3a216c775347",
"key": "jd",
"component_id": "Retrieval:ColdEelsArrive"
"key": "jd"
}
],
"presencePenaltyEnabled": true,
Expand Down Expand Up @@ -1541,6 +1544,19 @@
"target": "Answer:TwentyMugsDeny",
"targetHandle": "c",
"type": "buttonEdge"
},
{
"type": "buttonEdge",
"markerEnd": "logo",
"style": {
"strokeWidth": 2,
"stroke": "rgb(202 197 245)"
},
"source": "Generate:ProudEarsWorry",
"sourceHandle": "b",
"target": "Answer:TwentyMugsDeny",
"targetHandle": "c",
"id": "reactflow__edge-Generate:ProudEarsWorryb-Answer:TwentyMugsDenyc"
}
]
},
Expand Down

0 comments on commit 33e5e5d

Please sign in to comment.