mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 15:20:30 +08:00
fix(agent): filter TuShare news with upstream keyword input (#16361)
## Summary TuShare required non-empty upstream input but filtered fetched news with the static `keyword` param (default empty string), so agent-provided keywords were ignored. Use `self._param.keyword or ans` when filtering, matching how AkShare uses upstream input for its query. Fixes #16360 ## Test plan - [x] `test_tushare_filters_with_upstream_keyword_when_param_empty` mocks the API and asserts only rows matching the upstream keyword are returned --------- Co-authored-by: yzc <yuzhichang@gmail.com> Co-authored-by: Harsh Kashyap <harshkashyap@Harshs-MacBook-Pro.local>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
import json
|
||||
import logging
|
||||
from abc import ABC
|
||||
import pandas as pd
|
||||
import time
|
||||
@@ -73,7 +74,18 @@ class TuShare(ComponentBase, ABC):
|
||||
df.columns = response['data']['fields']
|
||||
if self.check_if_canceled("TuShare processing"):
|
||||
return
|
||||
tus_res.append({"content": (df[df['content'].str.contains(self._param.keyword, case=False)]).to_markdown()})
|
||||
keyword = self._param.keyword or ans
|
||||
logging.info(
|
||||
"TuShare news filter keyword source=%s",
|
||||
"param.keyword" if self._param.keyword else "upstream_input",
|
||||
)
|
||||
tus_res.append(
|
||||
{
|
||||
"content": (
|
||||
df[df["content"].str.contains(keyword, case=False, na=False, regex=False)]
|
||||
).to_markdown()
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
if self.check_if_canceled("TuShare processing"):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user