Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

dataset_service.py 113KB

2 år sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 månader sedan
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507
  1. import copy
  2. import datetime
  3. import json
  4. import logging
  5. import secrets
  6. import time
  7. import uuid
  8. from collections import Counter
  9. from typing import Any, Optional
  10. from flask_login import current_user
  11. from sqlalchemy import func, select
  12. from sqlalchemy.orm import Session
  13. from werkzeug.exceptions import NotFound
  14. from configs import dify_config
  15. from core.errors.error import LLMBadRequestError, ProviderTokenNotInitError
  16. from core.model_manager import ModelManager
  17. from core.model_runtime.entities.model_entities import ModelType
  18. from core.plugin.entities.plugin import ModelProviderID
  19. from core.rag.index_processor.constant.built_in_field import BuiltInField
  20. from core.rag.index_processor.constant.index_type import IndexType
  21. from core.rag.retrieval.retrieval_methods import RetrievalMethod
  22. from events.dataset_event import dataset_was_deleted
  23. from events.document_event import document_was_deleted
  24. from extensions.ext_database import db
  25. from extensions.ext_redis import redis_client
  26. from libs import helper
  27. from models.account import Account, TenantAccountRole
  28. from models.dataset import (
  29. AppDatasetJoin,
  30. ChildChunk,
  31. Dataset,
  32. DatasetAutoDisableLog,
  33. DatasetCollectionBinding,
  34. DatasetPermission,
  35. DatasetPermissionEnum,
  36. DatasetProcessRule,
  37. DatasetQuery,
  38. Document,
  39. DocumentSegment,
  40. ExternalKnowledgeBindings,
  41. )
  42. from models.model import UploadFile
  43. from models.source import DataSourceOauthBinding
  44. from services.entities.knowledge_entities.knowledge_entities import (
  45. ChildChunkUpdateArgs,
  46. KnowledgeConfig,
  47. RerankingModel,
  48. RetrievalModel,
  49. SegmentUpdateArgs,
  50. )
  51. from services.errors.account import InvalidActionError, NoPermissionError
  52. from services.errors.chunk import ChildChunkDeleteIndexError, ChildChunkIndexingError
  53. from services.errors.dataset import DatasetNameDuplicateError
  54. from services.errors.document import DocumentIndexingError
  55. from services.errors.file import FileNotExistsError
  56. from services.external_knowledge_service import ExternalDatasetService
  57. from services.feature_service import FeatureModel, FeatureService
  58. from services.tag_service import TagService
  59. from services.vector_service import VectorService
  60. from tasks.add_document_to_index_task import add_document_to_index_task
  61. from tasks.batch_clean_document_task import batch_clean_document_task
  62. from tasks.clean_notion_document_task import clean_notion_document_task
  63. from tasks.deal_dataset_vector_index_task import deal_dataset_vector_index_task
  64. from tasks.delete_segment_from_index_task import delete_segment_from_index_task
  65. from tasks.disable_segment_from_index_task import disable_segment_from_index_task
  66. from tasks.disable_segments_from_index_task import disable_segments_from_index_task
  67. from tasks.document_indexing_task import document_indexing_task
  68. from tasks.document_indexing_update_task import document_indexing_update_task
  69. from tasks.duplicate_document_indexing_task import duplicate_document_indexing_task
  70. from tasks.enable_segments_to_index_task import enable_segments_to_index_task
  71. from tasks.recover_document_indexing_task import recover_document_indexing_task
  72. from tasks.remove_document_from_index_task import remove_document_from_index_task
  73. from tasks.retry_document_indexing_task import retry_document_indexing_task
  74. from tasks.sync_website_document_indexing_task import sync_website_document_indexing_task
  75. class DatasetService:
  76. @staticmethod
  77. def get_datasets(page, per_page, tenant_id=None, user=None, search=None, tag_ids=None, include_all=False):
  78. query = select(Dataset).filter(Dataset.tenant_id == tenant_id).order_by(Dataset.created_at.desc())
  79. if user:
  80. # get permitted dataset ids
  81. dataset_permission = (
  82. db.session.query(DatasetPermission).filter_by(account_id=user.id, tenant_id=tenant_id).all()
  83. )
  84. permitted_dataset_ids = {dp.dataset_id for dp in dataset_permission} if dataset_permission else None
  85. if user.current_role == TenantAccountRole.DATASET_OPERATOR:
  86. # only show datasets that the user has permission to access
  87. if permitted_dataset_ids:
  88. query = query.filter(Dataset.id.in_(permitted_dataset_ids))
  89. else:
  90. return [], 0
  91. else:
  92. if user.current_role != TenantAccountRole.OWNER or not include_all:
  93. # show all datasets that the user has permission to access
  94. if permitted_dataset_ids:
  95. query = query.filter(
  96. db.or_(
  97. Dataset.permission == DatasetPermissionEnum.ALL_TEAM,
  98. db.and_(
  99. Dataset.permission == DatasetPermissionEnum.ONLY_ME, Dataset.created_by == user.id
  100. ),
  101. db.and_(
  102. Dataset.permission == DatasetPermissionEnum.PARTIAL_TEAM,
  103. Dataset.id.in_(permitted_dataset_ids),
  104. ),
  105. )
  106. )
  107. else:
  108. query = query.filter(
  109. db.or_(
  110. Dataset.permission == DatasetPermissionEnum.ALL_TEAM,
  111. db.and_(
  112. Dataset.permission == DatasetPermissionEnum.ONLY_ME, Dataset.created_by == user.id
  113. ),
  114. )
  115. )
  116. else:
  117. # if no user, only show datasets that are shared with all team members
  118. query = query.filter(Dataset.permission == DatasetPermissionEnum.ALL_TEAM)
  119. if search:
  120. query = query.filter(Dataset.name.ilike(f"%{search}%"))
  121. if tag_ids:
  122. target_ids = TagService.get_target_ids_by_tag_ids("knowledge", tenant_id, tag_ids)
  123. if target_ids:
  124. query = query.filter(Dataset.id.in_(target_ids))
  125. else:
  126. return [], 0
  127. datasets = db.paginate(select=query, page=page, per_page=per_page, max_per_page=100, error_out=False)
  128. return datasets.items, datasets.total
  129. @staticmethod
  130. def get_process_rules(dataset_id):
  131. # get the latest process rule
  132. dataset_process_rule = (
  133. db.session.query(DatasetProcessRule)
  134. .filter(DatasetProcessRule.dataset_id == dataset_id)
  135. .order_by(DatasetProcessRule.created_at.desc())
  136. .limit(1)
  137. .one_or_none()
  138. )
  139. if dataset_process_rule:
  140. mode = dataset_process_rule.mode
  141. rules = dataset_process_rule.rules_dict
  142. else:
  143. mode = DocumentService.DEFAULT_RULES["mode"]
  144. rules = DocumentService.DEFAULT_RULES["rules"]
  145. return {"mode": mode, "rules": rules}
  146. @staticmethod
  147. def get_datasets_by_ids(ids, tenant_id):
  148. stmt = select(Dataset).filter(Dataset.id.in_(ids), Dataset.tenant_id == tenant_id)
  149. datasets = db.paginate(select=stmt, page=1, per_page=len(ids), max_per_page=len(ids), error_out=False)
  150. return datasets.items, datasets.total
  151. @staticmethod
  152. def create_empty_dataset(
  153. tenant_id: str,
  154. name: str,
  155. description: Optional[str],
  156. indexing_technique: Optional[str],
  157. account: Account,
  158. permission: Optional[str] = None,
  159. provider: str = "vendor",
  160. external_knowledge_api_id: Optional[str] = None,
  161. external_knowledge_id: Optional[str] = None,
  162. embedding_model_provider: Optional[str] = None,
  163. embedding_model_name: Optional[str] = None,
  164. retrieval_model: Optional[RetrievalModel] = None,
  165. ):
  166. # check if dataset name already exists
  167. if db.session.query(Dataset).filter_by(name=name, tenant_id=tenant_id).first():
  168. raise DatasetNameDuplicateError(f"Dataset with name {name} already exists.")
  169. embedding_model = None
  170. if indexing_technique == "high_quality":
  171. model_manager = ModelManager()
  172. if embedding_model_provider and embedding_model_name:
  173. # check if embedding model setting is valid
  174. DatasetService.check_embedding_model_setting(tenant_id, embedding_model_provider, embedding_model_name)
  175. embedding_model = model_manager.get_model_instance(
  176. tenant_id=tenant_id,
  177. provider=embedding_model_provider,
  178. model_type=ModelType.TEXT_EMBEDDING,
  179. model=embedding_model_name,
  180. )
  181. else:
  182. embedding_model = model_manager.get_default_model_instance(
  183. tenant_id=tenant_id, model_type=ModelType.TEXT_EMBEDDING
  184. )
  185. if retrieval_model and retrieval_model.reranking_model:
  186. if (
  187. retrieval_model.reranking_model.reranking_provider_name
  188. and retrieval_model.reranking_model.reranking_model_name
  189. ):
  190. # check if reranking model setting is valid
  191. DatasetService.check_embedding_model_setting(
  192. tenant_id,
  193. retrieval_model.reranking_model.reranking_provider_name,
  194. retrieval_model.reranking_model.reranking_model_name,
  195. )
  196. dataset = Dataset(name=name, indexing_technique=indexing_technique)
  197. # dataset = Dataset(name=name, provider=provider, config=config)
  198. dataset.description = description
  199. dataset.created_by = account.id
  200. dataset.updated_by = account.id
  201. dataset.tenant_id = tenant_id
  202. dataset.embedding_model_provider = embedding_model.provider if embedding_model else None
  203. dataset.embedding_model = embedding_model.model if embedding_model else None
  204. dataset.retrieval_model = retrieval_model.model_dump() if retrieval_model else None
  205. dataset.permission = permission or DatasetPermissionEnum.ONLY_ME
  206. dataset.provider = provider
  207. db.session.add(dataset)
  208. db.session.flush()
  209. if provider == "external" and external_knowledge_api_id:
  210. external_knowledge_api = ExternalDatasetService.get_external_knowledge_api(external_knowledge_api_id)
  211. if not external_knowledge_api:
  212. raise ValueError("External API template not found.")
  213. external_knowledge_binding = ExternalKnowledgeBindings(
  214. tenant_id=tenant_id,
  215. dataset_id=dataset.id,
  216. external_knowledge_api_id=external_knowledge_api_id,
  217. external_knowledge_id=external_knowledge_id,
  218. created_by=account.id,
  219. )
  220. db.session.add(external_knowledge_binding)
  221. db.session.commit()
  222. return dataset
  223. @staticmethod
  224. def get_dataset(dataset_id) -> Optional[Dataset]:
  225. dataset: Optional[Dataset] = db.session.query(Dataset).filter_by(id=dataset_id).first()
  226. return dataset
  227. @staticmethod
  228. def check_dataset_model_setting(dataset):
  229. if dataset.indexing_technique == "high_quality":
  230. try:
  231. model_manager = ModelManager()
  232. model_manager.get_model_instance(
  233. tenant_id=dataset.tenant_id,
  234. provider=dataset.embedding_model_provider,
  235. model_type=ModelType.TEXT_EMBEDDING,
  236. model=dataset.embedding_model,
  237. )
  238. except LLMBadRequestError:
  239. raise ValueError(
  240. "No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider."
  241. )
  242. except ProviderTokenNotInitError as ex:
  243. raise ValueError(f"The dataset in unavailable, due to: {ex.description}")
  244. @staticmethod
  245. def check_embedding_model_setting(tenant_id: str, embedding_model_provider: str, embedding_model: str):
  246. try:
  247. model_manager = ModelManager()
  248. model_manager.get_model_instance(
  249. tenant_id=tenant_id,
  250. provider=embedding_model_provider,
  251. model_type=ModelType.TEXT_EMBEDDING,
  252. model=embedding_model,
  253. )
  254. except LLMBadRequestError:
  255. raise ValueError(
  256. "No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider."
  257. )
  258. except ProviderTokenNotInitError as ex:
  259. raise ValueError(ex.description)
  260. @staticmethod
  261. def update_dataset(dataset_id, data, user):
  262. dataset = DatasetService.get_dataset(dataset_id)
  263. if not dataset:
  264. raise ValueError("Dataset not found")
  265. DatasetService.check_dataset_permission(dataset, user)
  266. if dataset.provider == "external":
  267. external_retrieval_model = data.get("external_retrieval_model", None)
  268. if external_retrieval_model:
  269. dataset.retrieval_model = external_retrieval_model
  270. dataset.name = data.get("name", dataset.name)
  271. dataset.description = data.get("description", "")
  272. permission = data.get("permission")
  273. if permission:
  274. dataset.permission = permission
  275. external_knowledge_id = data.get("external_knowledge_id", None)
  276. db.session.add(dataset)
  277. if not external_knowledge_id:
  278. raise ValueError("External knowledge id is required.")
  279. external_knowledge_api_id = data.get("external_knowledge_api_id", None)
  280. if not external_knowledge_api_id:
  281. raise ValueError("External knowledge api id is required.")
  282. with Session(db.engine) as session:
  283. external_knowledge_binding = (
  284. session.query(ExternalKnowledgeBindings).filter_by(dataset_id=dataset_id).first()
  285. )
  286. if not external_knowledge_binding:
  287. raise ValueError("External knowledge binding not found.")
  288. if (
  289. external_knowledge_binding.external_knowledge_id != external_knowledge_id
  290. or external_knowledge_binding.external_knowledge_api_id != external_knowledge_api_id
  291. ):
  292. external_knowledge_binding.external_knowledge_id = external_knowledge_id
  293. external_knowledge_binding.external_knowledge_api_id = external_knowledge_api_id
  294. db.session.add(external_knowledge_binding)
  295. db.session.commit()
  296. else:
  297. data.pop("partial_member_list", None)
  298. data.pop("external_knowledge_api_id", None)
  299. data.pop("external_knowledge_id", None)
  300. data.pop("external_retrieval_model", None)
  301. filtered_data = {k: v for k, v in data.items() if v is not None or k == "description"}
  302. action = None
  303. if dataset.indexing_technique != data["indexing_technique"]:
  304. # if update indexing_technique
  305. if data["indexing_technique"] == "economy":
  306. action = "remove"
  307. filtered_data["embedding_model"] = None
  308. filtered_data["embedding_model_provider"] = None
  309. filtered_data["collection_binding_id"] = None
  310. elif data["indexing_technique"] == "high_quality":
  311. action = "add"
  312. # get embedding model setting
  313. try:
  314. model_manager = ModelManager()
  315. embedding_model = model_manager.get_model_instance(
  316. tenant_id=current_user.current_tenant_id,
  317. provider=data["embedding_model_provider"],
  318. model_type=ModelType.TEXT_EMBEDDING,
  319. model=data["embedding_model"],
  320. )
  321. filtered_data["embedding_model"] = embedding_model.model
  322. filtered_data["embedding_model_provider"] = embedding_model.provider
  323. dataset_collection_binding = DatasetCollectionBindingService.get_dataset_collection_binding(
  324. embedding_model.provider, embedding_model.model
  325. )
  326. filtered_data["collection_binding_id"] = dataset_collection_binding.id
  327. except LLMBadRequestError:
  328. raise ValueError(
  329. "No Embedding Model available. Please configure a valid provider "
  330. "in the Settings -> Model Provider."
  331. )
  332. except ProviderTokenNotInitError as ex:
  333. raise ValueError(ex.description)
  334. else:
  335. # add default plugin id to both setting sets, to make sure the plugin model provider is consistent
  336. # Skip embedding model checks if not provided in the update request
  337. if (
  338. "embedding_model_provider" not in data
  339. or "embedding_model" not in data
  340. or not data.get("embedding_model_provider")
  341. or not data.get("embedding_model")
  342. ):
  343. # If the dataset already has embedding model settings, use those
  344. if dataset.embedding_model_provider and dataset.embedding_model:
  345. # Keep existing values
  346. filtered_data["embedding_model_provider"] = dataset.embedding_model_provider
  347. filtered_data["embedding_model"] = dataset.embedding_model
  348. # If collection_binding_id exists, keep it too
  349. if dataset.collection_binding_id:
  350. filtered_data["collection_binding_id"] = dataset.collection_binding_id
  351. # Otherwise, don't try to update embedding model settings at all
  352. # Remove these fields from filtered_data if they exist but are None/empty
  353. if "embedding_model_provider" in filtered_data and not filtered_data["embedding_model_provider"]:
  354. del filtered_data["embedding_model_provider"]
  355. if "embedding_model" in filtered_data and not filtered_data["embedding_model"]:
  356. del filtered_data["embedding_model"]
  357. else:
  358. skip_embedding_update = False
  359. try:
  360. # Handle existing model provider
  361. plugin_model_provider = dataset.embedding_model_provider
  362. plugin_model_provider_str = None
  363. if plugin_model_provider:
  364. plugin_model_provider_str = str(ModelProviderID(plugin_model_provider))
  365. # Handle new model provider from request
  366. new_plugin_model_provider = data["embedding_model_provider"]
  367. new_plugin_model_provider_str = None
  368. if new_plugin_model_provider:
  369. new_plugin_model_provider_str = str(ModelProviderID(new_plugin_model_provider))
  370. # Only update embedding model if both values are provided and different from current
  371. if (
  372. plugin_model_provider_str != new_plugin_model_provider_str
  373. or data["embedding_model"] != dataset.embedding_model
  374. ):
  375. action = "update"
  376. model_manager = ModelManager()
  377. try:
  378. embedding_model = model_manager.get_model_instance(
  379. tenant_id=current_user.current_tenant_id,
  380. provider=data["embedding_model_provider"],
  381. model_type=ModelType.TEXT_EMBEDDING,
  382. model=data["embedding_model"],
  383. )
  384. except ProviderTokenNotInitError:
  385. # If we can't get the embedding model, skip updating it
  386. # and keep the existing settings if available
  387. if dataset.embedding_model_provider and dataset.embedding_model:
  388. filtered_data["embedding_model_provider"] = dataset.embedding_model_provider
  389. filtered_data["embedding_model"] = dataset.embedding_model
  390. if dataset.collection_binding_id:
  391. filtered_data["collection_binding_id"] = dataset.collection_binding_id
  392. # Skip the rest of the embedding model update
  393. skip_embedding_update = True
  394. if not skip_embedding_update:
  395. filtered_data["embedding_model"] = embedding_model.model
  396. filtered_data["embedding_model_provider"] = embedding_model.provider
  397. dataset_collection_binding = (
  398. DatasetCollectionBindingService.get_dataset_collection_binding(
  399. embedding_model.provider, embedding_model.model
  400. )
  401. )
  402. filtered_data["collection_binding_id"] = dataset_collection_binding.id
  403. except LLMBadRequestError:
  404. raise ValueError(
  405. "No Embedding Model available. Please configure a valid provider "
  406. "in the Settings -> Model Provider."
  407. )
  408. except ProviderTokenNotInitError as ex:
  409. raise ValueError(ex.description)
  410. filtered_data["updated_by"] = user.id
  411. filtered_data["updated_at"] = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  412. # update Retrieval model
  413. filtered_data["retrieval_model"] = data["retrieval_model"]
  414. db.session.query(Dataset).filter_by(id=dataset_id).update(filtered_data)
  415. db.session.commit()
  416. if action:
  417. deal_dataset_vector_index_task.delay(dataset_id, action)
  418. return dataset
  419. @staticmethod
  420. def delete_dataset(dataset_id, user):
  421. dataset = DatasetService.get_dataset(dataset_id)
  422. if dataset is None:
  423. return False
  424. DatasetService.check_dataset_permission(dataset, user)
  425. dataset_was_deleted.send(dataset)
  426. db.session.delete(dataset)
  427. db.session.commit()
  428. return True
  429. @staticmethod
  430. def dataset_use_check(dataset_id) -> bool:
  431. count = db.session.query(AppDatasetJoin).filter_by(dataset_id=dataset_id).count()
  432. if count > 0:
  433. return True
  434. return False
  435. @staticmethod
  436. def check_dataset_permission(dataset, user):
  437. if dataset.tenant_id != user.current_tenant_id:
  438. logging.debug(f"User {user.id} does not have permission to access dataset {dataset.id}")
  439. raise NoPermissionError("You do not have permission to access this dataset.")
  440. if user.current_role != TenantAccountRole.OWNER:
  441. if dataset.permission == DatasetPermissionEnum.ONLY_ME and dataset.created_by != user.id:
  442. logging.debug(f"User {user.id} does not have permission to access dataset {dataset.id}")
  443. raise NoPermissionError("You do not have permission to access this dataset.")
  444. if dataset.permission == DatasetPermissionEnum.PARTIAL_TEAM:
  445. # For partial team permission, user needs explicit permission or be the creator
  446. if dataset.created_by != user.id:
  447. user_permission = (
  448. db.session.query(DatasetPermission).filter_by(dataset_id=dataset.id, account_id=user.id).first()
  449. )
  450. if not user_permission:
  451. logging.debug(f"User {user.id} does not have permission to access dataset {dataset.id}")
  452. raise NoPermissionError("You do not have permission to access this dataset.")
  453. @staticmethod
  454. def check_dataset_operator_permission(user: Optional[Account] = None, dataset: Optional[Dataset] = None):
  455. if not dataset:
  456. raise ValueError("Dataset not found")
  457. if not user:
  458. raise ValueError("User not found")
  459. if user.current_role != TenantAccountRole.OWNER:
  460. if dataset.permission == DatasetPermissionEnum.ONLY_ME:
  461. if dataset.created_by != user.id:
  462. raise NoPermissionError("You do not have permission to access this dataset.")
  463. elif dataset.permission == DatasetPermissionEnum.PARTIAL_TEAM:
  464. if not any(
  465. dp.dataset_id == dataset.id
  466. for dp in db.session.query(DatasetPermission).filter_by(account_id=user.id).all()
  467. ):
  468. raise NoPermissionError("You do not have permission to access this dataset.")
  469. @staticmethod
  470. def get_dataset_queries(dataset_id: str, page: int, per_page: int):
  471. stmt = select(DatasetQuery).filter_by(dataset_id=dataset_id).order_by(db.desc(DatasetQuery.created_at))
  472. dataset_queries = db.paginate(select=stmt, page=page, per_page=per_page, max_per_page=100, error_out=False)
  473. return dataset_queries.items, dataset_queries.total
  474. @staticmethod
  475. def get_related_apps(dataset_id: str):
  476. return (
  477. db.session.query(AppDatasetJoin)
  478. .filter(AppDatasetJoin.dataset_id == dataset_id)
  479. .order_by(db.desc(AppDatasetJoin.created_at))
  480. .all()
  481. )
  482. @staticmethod
  483. def get_dataset_auto_disable_logs(dataset_id: str) -> dict:
  484. features = FeatureService.get_features(current_user.current_tenant_id)
  485. if not features.billing.enabled or features.billing.subscription.plan == "sandbox":
  486. return {
  487. "document_ids": [],
  488. "count": 0,
  489. }
  490. # get recent 30 days auto disable logs
  491. start_date = datetime.datetime.now() - datetime.timedelta(days=30)
  492. dataset_auto_disable_logs = (
  493. db.session.query(DatasetAutoDisableLog)
  494. .filter(
  495. DatasetAutoDisableLog.dataset_id == dataset_id,
  496. DatasetAutoDisableLog.created_at >= start_date,
  497. )
  498. .all()
  499. )
  500. if dataset_auto_disable_logs:
  501. return {
  502. "document_ids": [log.document_id for log in dataset_auto_disable_logs],
  503. "count": len(dataset_auto_disable_logs),
  504. }
  505. return {
  506. "document_ids": [],
  507. "count": 0,
  508. }
  509. class DocumentService:
  510. DEFAULT_RULES: dict[str, Any] = {
  511. "mode": "custom",
  512. "rules": {
  513. "pre_processing_rules": [
  514. {"id": "remove_extra_spaces", "enabled": True},
  515. {"id": "remove_urls_emails", "enabled": False},
  516. ],
  517. "segmentation": {"delimiter": "\n", "max_tokens": 1024, "chunk_overlap": 50},
  518. },
  519. "limits": {
  520. "indexing_max_segmentation_tokens_length": dify_config.INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH,
  521. },
  522. }
  523. DOCUMENT_METADATA_SCHEMA: dict[str, Any] = {
  524. "book": {
  525. "title": str,
  526. "language": str,
  527. "author": str,
  528. "publisher": str,
  529. "publication_date": str,
  530. "isbn": str,
  531. "category": str,
  532. },
  533. "web_page": {
  534. "title": str,
  535. "url": str,
  536. "language": str,
  537. "publish_date": str,
  538. "author/publisher": str,
  539. "topic/keywords": str,
  540. "description": str,
  541. },
  542. "paper": {
  543. "title": str,
  544. "language": str,
  545. "author": str,
  546. "publish_date": str,
  547. "journal/conference_name": str,
  548. "volume/issue/page_numbers": str,
  549. "doi": str,
  550. "topic/keywords": str,
  551. "abstract": str,
  552. },
  553. "social_media_post": {
  554. "platform": str,
  555. "author/username": str,
  556. "publish_date": str,
  557. "post_url": str,
  558. "topic/tags": str,
  559. },
  560. "wikipedia_entry": {
  561. "title": str,
  562. "language": str,
  563. "web_page_url": str,
  564. "last_edit_date": str,
  565. "editor/contributor": str,
  566. "summary/introduction": str,
  567. },
  568. "personal_document": {
  569. "title": str,
  570. "author": str,
  571. "creation_date": str,
  572. "last_modified_date": str,
  573. "document_type": str,
  574. "tags/category": str,
  575. },
  576. "business_document": {
  577. "title": str,
  578. "author": str,
  579. "creation_date": str,
  580. "last_modified_date": str,
  581. "document_type": str,
  582. "department/team": str,
  583. },
  584. "im_chat_log": {
  585. "chat_platform": str,
  586. "chat_participants/group_name": str,
  587. "start_date": str,
  588. "end_date": str,
  589. "summary": str,
  590. },
  591. "synced_from_notion": {
  592. "title": str,
  593. "language": str,
  594. "author/creator": str,
  595. "creation_date": str,
  596. "last_modified_date": str,
  597. "notion_page_link": str,
  598. "category/tags": str,
  599. "description": str,
  600. },
  601. "synced_from_github": {
  602. "repository_name": str,
  603. "repository_description": str,
  604. "repository_owner/organization": str,
  605. "code_filename": str,
  606. "code_file_path": str,
  607. "programming_language": str,
  608. "github_link": str,
  609. "open_source_license": str,
  610. "commit_date": str,
  611. "commit_author": str,
  612. },
  613. "others": dict,
  614. }
  615. @staticmethod
  616. def get_document(dataset_id: str, document_id: Optional[str] = None) -> Optional[Document]:
  617. if document_id:
  618. document = (
  619. db.session.query(Document).filter(Document.id == document_id, Document.dataset_id == dataset_id).first()
  620. )
  621. return document
  622. else:
  623. return None
  624. @staticmethod
  625. def get_document_by_id(document_id: str) -> Optional[Document]:
  626. document = db.session.query(Document).filter(Document.id == document_id).first()
  627. return document
  628. @staticmethod
  629. def get_document_by_ids(document_ids: list[str]) -> list[Document]:
  630. documents = (
  631. db.session.query(Document)
  632. .filter(
  633. Document.id.in_(document_ids),
  634. Document.enabled == True,
  635. Document.indexing_status == "completed",
  636. Document.archived == False,
  637. )
  638. .all()
  639. )
  640. return documents
  641. @staticmethod
  642. def get_document_by_dataset_id(dataset_id: str) -> list[Document]:
  643. documents = (
  644. db.session.query(Document)
  645. .filter(
  646. Document.dataset_id == dataset_id,
  647. Document.enabled == True,
  648. )
  649. .all()
  650. )
  651. return documents
  652. @staticmethod
  653. def get_working_documents_by_dataset_id(dataset_id: str) -> list[Document]:
  654. documents = (
  655. db.session.query(Document)
  656. .filter(
  657. Document.dataset_id == dataset_id,
  658. Document.enabled == True,
  659. Document.indexing_status == "completed",
  660. Document.archived == False,
  661. )
  662. .all()
  663. )
  664. return documents
  665. @staticmethod
  666. def get_error_documents_by_dataset_id(dataset_id: str) -> list[Document]:
  667. documents = (
  668. db.session.query(Document)
  669. .filter(Document.dataset_id == dataset_id, Document.indexing_status.in_(["error", "paused"]))
  670. .all()
  671. )
  672. return documents
  673. @staticmethod
  674. def get_batch_documents(dataset_id: str, batch: str) -> list[Document]:
  675. documents = (
  676. db.session.query(Document)
  677. .filter(
  678. Document.batch == batch,
  679. Document.dataset_id == dataset_id,
  680. Document.tenant_id == current_user.current_tenant_id,
  681. )
  682. .all()
  683. )
  684. return documents
  685. @staticmethod
  686. def get_document_file_detail(file_id: str):
  687. file_detail = db.session.query(UploadFile).filter(UploadFile.id == file_id).one_or_none()
  688. return file_detail
  689. @staticmethod
  690. def check_archived(document):
  691. if document.archived:
  692. return True
  693. else:
  694. return False
  695. @staticmethod
  696. def delete_document(document):
  697. # trigger document_was_deleted signal
  698. file_id = None
  699. if document.data_source_type == "upload_file":
  700. if document.data_source_info:
  701. data_source_info = document.data_source_info_dict
  702. if data_source_info and "upload_file_id" in data_source_info:
  703. file_id = data_source_info["upload_file_id"]
  704. document_was_deleted.send(
  705. document.id, dataset_id=document.dataset_id, doc_form=document.doc_form, file_id=file_id
  706. )
  707. db.session.delete(document)
  708. db.session.commit()
  709. @staticmethod
  710. def delete_documents(dataset: Dataset, document_ids: list[str]):
  711. documents = db.session.query(Document).filter(Document.id.in_(document_ids)).all()
  712. file_ids = [
  713. document.data_source_info_dict["upload_file_id"]
  714. for document in documents
  715. if document.data_source_type == "upload_file"
  716. ]
  717. batch_clean_document_task.delay(document_ids, dataset.id, dataset.doc_form, file_ids)
  718. for document in documents:
  719. db.session.delete(document)
  720. db.session.commit()
  721. @staticmethod
  722. def rename_document(dataset_id: str, document_id: str, name: str) -> Document:
  723. dataset = DatasetService.get_dataset(dataset_id)
  724. if not dataset:
  725. raise ValueError("Dataset not found.")
  726. document = DocumentService.get_document(dataset_id, document_id)
  727. if not document:
  728. raise ValueError("Document not found.")
  729. if document.tenant_id != current_user.current_tenant_id:
  730. raise ValueError("No permission.")
  731. if dataset.built_in_field_enabled:
  732. if document.doc_metadata:
  733. doc_metadata = copy.deepcopy(document.doc_metadata)
  734. doc_metadata[BuiltInField.document_name.value] = name
  735. document.doc_metadata = doc_metadata
  736. document.name = name
  737. db.session.add(document)
  738. db.session.commit()
  739. return document
  740. @staticmethod
  741. def pause_document(document):
  742. if document.indexing_status not in {"waiting", "parsing", "cleaning", "splitting", "indexing"}:
  743. raise DocumentIndexingError()
  744. # update document to be paused
  745. document.is_paused = True
  746. document.paused_by = current_user.id
  747. document.paused_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  748. db.session.add(document)
  749. db.session.commit()
  750. # set document paused flag
  751. indexing_cache_key = "document_{}_is_paused".format(document.id)
  752. redis_client.setnx(indexing_cache_key, "True")
  753. @staticmethod
  754. def recover_document(document):
  755. if not document.is_paused:
  756. raise DocumentIndexingError()
  757. # update document to be recover
  758. document.is_paused = False
  759. document.paused_by = None
  760. document.paused_at = None
  761. db.session.add(document)
  762. db.session.commit()
  763. # delete paused flag
  764. indexing_cache_key = "document_{}_is_paused".format(document.id)
  765. redis_client.delete(indexing_cache_key)
  766. # trigger async task
  767. recover_document_indexing_task.delay(document.dataset_id, document.id)
  768. @staticmethod
  769. def retry_document(dataset_id: str, documents: list[Document]):
  770. for document in documents:
  771. # add retry flag
  772. retry_indexing_cache_key = "document_{}_is_retried".format(document.id)
  773. cache_result = redis_client.get(retry_indexing_cache_key)
  774. if cache_result is not None:
  775. raise ValueError("Document is being retried, please try again later")
  776. # retry document indexing
  777. document.indexing_status = "waiting"
  778. db.session.add(document)
  779. db.session.commit()
  780. redis_client.setex(retry_indexing_cache_key, 600, 1)
  781. # trigger async task
  782. document_ids = [document.id for document in documents]
  783. retry_document_indexing_task.delay(dataset_id, document_ids)
  784. @staticmethod
  785. def sync_website_document(dataset_id: str, document: Document):
  786. # add sync flag
  787. sync_indexing_cache_key = "document_{}_is_sync".format(document.id)
  788. cache_result = redis_client.get(sync_indexing_cache_key)
  789. if cache_result is not None:
  790. raise ValueError("Document is being synced, please try again later")
  791. # sync document indexing
  792. document.indexing_status = "waiting"
  793. data_source_info = document.data_source_info_dict
  794. data_source_info["mode"] = "scrape"
  795. document.data_source_info = json.dumps(data_source_info, ensure_ascii=False)
  796. db.session.add(document)
  797. db.session.commit()
  798. redis_client.setex(sync_indexing_cache_key, 600, 1)
  799. sync_website_document_indexing_task.delay(dataset_id, document.id)
  800. @staticmethod
  801. def get_documents_position(dataset_id):
  802. document = (
  803. db.session.query(Document).filter_by(dataset_id=dataset_id).order_by(Document.position.desc()).first()
  804. )
  805. if document:
  806. return document.position + 1
  807. else:
  808. return 1
  809. @staticmethod
  810. def save_document_with_dataset_id(
  811. dataset: Dataset,
  812. knowledge_config: KnowledgeConfig,
  813. account: Account | Any,
  814. dataset_process_rule: Optional[DatasetProcessRule] = None,
  815. created_from: str = "web",
  816. ):
  817. # check document limit
  818. features = FeatureService.get_features(current_user.current_tenant_id)
  819. if features.billing.enabled:
  820. if not knowledge_config.original_document_id:
  821. count = 0
  822. if knowledge_config.data_source:
  823. if knowledge_config.data_source.info_list.data_source_type == "upload_file":
  824. upload_file_list = knowledge_config.data_source.info_list.file_info_list.file_ids # type: ignore
  825. count = len(upload_file_list)
  826. elif knowledge_config.data_source.info_list.data_source_type == "notion_import":
  827. notion_info_list = knowledge_config.data_source.info_list.notion_info_list
  828. for notion_info in notion_info_list: # type: ignore
  829. count = count + len(notion_info.pages)
  830. elif knowledge_config.data_source.info_list.data_source_type == "website_crawl":
  831. website_info = knowledge_config.data_source.info_list.website_info_list
  832. count = len(website_info.urls) # type: ignore
  833. batch_upload_limit = int(dify_config.BATCH_UPLOAD_LIMIT)
  834. if features.billing.subscription.plan == "sandbox" and count > 1:
  835. raise ValueError("Your current plan does not support batch upload, please upgrade your plan.")
  836. if count > batch_upload_limit:
  837. raise ValueError(f"You have reached the batch upload limit of {batch_upload_limit}.")
  838. DocumentService.check_documents_upload_quota(count, features)
  839. # if dataset is empty, update dataset data_source_type
  840. if not dataset.data_source_type:
  841. dataset.data_source_type = knowledge_config.data_source.info_list.data_source_type # type: ignore
  842. if not dataset.indexing_technique:
  843. if knowledge_config.indexing_technique not in Dataset.INDEXING_TECHNIQUE_LIST:
  844. raise ValueError("Indexing technique is invalid")
  845. dataset.indexing_technique = knowledge_config.indexing_technique
  846. if knowledge_config.indexing_technique == "high_quality":
  847. model_manager = ModelManager()
  848. if knowledge_config.embedding_model and knowledge_config.embedding_model_provider:
  849. dataset_embedding_model = knowledge_config.embedding_model
  850. dataset_embedding_model_provider = knowledge_config.embedding_model_provider
  851. else:
  852. embedding_model = model_manager.get_default_model_instance(
  853. tenant_id=current_user.current_tenant_id, model_type=ModelType.TEXT_EMBEDDING
  854. )
  855. dataset_embedding_model = embedding_model.model
  856. dataset_embedding_model_provider = embedding_model.provider
  857. dataset.embedding_model = dataset_embedding_model
  858. dataset.embedding_model_provider = dataset_embedding_model_provider
  859. dataset_collection_binding = DatasetCollectionBindingService.get_dataset_collection_binding(
  860. dataset_embedding_model_provider, dataset_embedding_model
  861. )
  862. dataset.collection_binding_id = dataset_collection_binding.id
  863. if not dataset.retrieval_model:
  864. default_retrieval_model = {
  865. "search_method": RetrievalMethod.SEMANTIC_SEARCH.value,
  866. "reranking_enable": False,
  867. "reranking_model": {"reranking_provider_name": "", "reranking_model_name": ""},
  868. "top_k": 2,
  869. "score_threshold_enabled": False,
  870. }
  871. dataset.retrieval_model = (
  872. knowledge_config.retrieval_model.model_dump()
  873. if knowledge_config.retrieval_model
  874. else default_retrieval_model
  875. ) # type: ignore
  876. documents = []
  877. if knowledge_config.original_document_id:
  878. document = DocumentService.update_document_with_dataset_id(dataset, knowledge_config, account)
  879. documents.append(document)
  880. batch = document.batch
  881. else:
  882. batch = time.strftime("%Y%m%d%H%M%S") + str(100000 + secrets.randbelow(exclusive_upper_bound=900000))
  883. # save process rule
  884. if not dataset_process_rule:
  885. process_rule = knowledge_config.process_rule
  886. if process_rule:
  887. if process_rule.mode in ("custom", "hierarchical"):
  888. if process_rule.rules:
  889. dataset_process_rule = DatasetProcessRule(
  890. dataset_id=dataset.id,
  891. mode=process_rule.mode,
  892. rules=process_rule.rules.model_dump_json() if process_rule.rules else None,
  893. created_by=account.id,
  894. )
  895. else:
  896. dataset_process_rule = dataset.latest_process_rule
  897. if not dataset_process_rule:
  898. raise ValueError("No process rule found.")
  899. elif process_rule.mode == "automatic":
  900. dataset_process_rule = DatasetProcessRule(
  901. dataset_id=dataset.id,
  902. mode=process_rule.mode,
  903. rules=json.dumps(DatasetProcessRule.AUTOMATIC_RULES),
  904. created_by=account.id,
  905. )
  906. else:
  907. logging.warning(
  908. f"Invalid process rule mode: {process_rule.mode}, can not find dataset process rule"
  909. )
  910. return
  911. db.session.add(dataset_process_rule)
  912. db.session.commit()
  913. lock_name = "add_document_lock_dataset_id_{}".format(dataset.id)
  914. with redis_client.lock(lock_name, timeout=600):
  915. position = DocumentService.get_documents_position(dataset.id)
  916. document_ids = []
  917. duplicate_document_ids = []
  918. if knowledge_config.data_source.info_list.data_source_type == "upload_file": # type: ignore
  919. upload_file_list = knowledge_config.data_source.info_list.file_info_list.file_ids # type: ignore
  920. for file_id in upload_file_list:
  921. file = (
  922. db.session.query(UploadFile)
  923. .filter(UploadFile.tenant_id == dataset.tenant_id, UploadFile.id == file_id)
  924. .first()
  925. )
  926. # raise error if file not found
  927. if not file:
  928. raise FileNotExistsError()
  929. file_name = file.name
  930. data_source_info = {
  931. "upload_file_id": file_id,
  932. }
  933. # check duplicate
  934. if knowledge_config.duplicate:
  935. document = (
  936. db.session.query(Document)
  937. .filter_by(
  938. dataset_id=dataset.id,
  939. tenant_id=current_user.current_tenant_id,
  940. data_source_type="upload_file",
  941. enabled=True,
  942. name=file_name,
  943. )
  944. .first()
  945. )
  946. if document:
  947. document.dataset_process_rule_id = dataset_process_rule.id # type: ignore
  948. document.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  949. document.created_from = created_from
  950. document.doc_form = knowledge_config.doc_form
  951. document.doc_language = knowledge_config.doc_language
  952. document.data_source_info = json.dumps(data_source_info)
  953. document.batch = batch
  954. document.indexing_status = "waiting"
  955. db.session.add(document)
  956. documents.append(document)
  957. duplicate_document_ids.append(document.id)
  958. continue
  959. document = DocumentService.build_document(
  960. dataset,
  961. dataset_process_rule.id, # type: ignore
  962. knowledge_config.data_source.info_list.data_source_type, # type: ignore
  963. knowledge_config.doc_form,
  964. knowledge_config.doc_language,
  965. data_source_info,
  966. created_from,
  967. position,
  968. account,
  969. file_name,
  970. batch,
  971. )
  972. db.session.add(document)
  973. db.session.flush()
  974. document_ids.append(document.id)
  975. documents.append(document)
  976. position += 1
  977. elif knowledge_config.data_source.info_list.data_source_type == "notion_import": # type: ignore
  978. notion_info_list = knowledge_config.data_source.info_list.notion_info_list # type: ignore
  979. if not notion_info_list:
  980. raise ValueError("No notion info list found.")
  981. exist_page_ids = []
  982. exist_document = {}
  983. documents = (
  984. db.session.query(Document)
  985. .filter_by(
  986. dataset_id=dataset.id,
  987. tenant_id=current_user.current_tenant_id,
  988. data_source_type="notion_import",
  989. enabled=True,
  990. )
  991. .all()
  992. )
  993. if documents:
  994. for document in documents:
  995. data_source_info = json.loads(document.data_source_info)
  996. exist_page_ids.append(data_source_info["notion_page_id"])
  997. exist_document[data_source_info["notion_page_id"]] = document.id
  998. for notion_info in notion_info_list:
  999. workspace_id = notion_info.workspace_id
  1000. data_source_binding = (
  1001. db.session.query(DataSourceOauthBinding)
  1002. .filter(
  1003. db.and_(
  1004. DataSourceOauthBinding.tenant_id == current_user.current_tenant_id,
  1005. DataSourceOauthBinding.provider == "notion",
  1006. DataSourceOauthBinding.disabled == False,
  1007. DataSourceOauthBinding.source_info["workspace_id"] == f'"{workspace_id}"',
  1008. )
  1009. )
  1010. .first()
  1011. )
  1012. if not data_source_binding:
  1013. raise ValueError("Data source binding not found.")
  1014. for page in notion_info.pages:
  1015. if page.page_id not in exist_page_ids:
  1016. data_source_info = {
  1017. "notion_workspace_id": workspace_id,
  1018. "notion_page_id": page.page_id,
  1019. "notion_page_icon": page.page_icon.model_dump() if page.page_icon else None,
  1020. "type": page.type,
  1021. }
  1022. # Truncate page name to 255 characters to prevent DB field length errors
  1023. truncated_page_name = page.page_name[:255] if page.page_name else "nopagename"
  1024. document = DocumentService.build_document(
  1025. dataset,
  1026. dataset_process_rule.id, # type: ignore
  1027. knowledge_config.data_source.info_list.data_source_type, # type: ignore
  1028. knowledge_config.doc_form,
  1029. knowledge_config.doc_language,
  1030. data_source_info,
  1031. created_from,
  1032. position,
  1033. account,
  1034. truncated_page_name,
  1035. batch,
  1036. )
  1037. db.session.add(document)
  1038. db.session.flush()
  1039. document_ids.append(document.id)
  1040. documents.append(document)
  1041. position += 1
  1042. else:
  1043. exist_document.pop(page.page_id)
  1044. # delete not selected documents
  1045. if len(exist_document) > 0:
  1046. clean_notion_document_task.delay(list(exist_document.values()), dataset.id)
  1047. elif knowledge_config.data_source.info_list.data_source_type == "website_crawl": # type: ignore
  1048. website_info = knowledge_config.data_source.info_list.website_info_list # type: ignore
  1049. if not website_info:
  1050. raise ValueError("No website info list found.")
  1051. urls = website_info.urls
  1052. for url in urls:
  1053. data_source_info = {
  1054. "url": url,
  1055. "provider": website_info.provider,
  1056. "job_id": website_info.job_id,
  1057. "only_main_content": website_info.only_main_content,
  1058. "mode": "crawl",
  1059. }
  1060. if len(url) > 255:
  1061. document_name = url[:200] + "..."
  1062. else:
  1063. document_name = url
  1064. document = DocumentService.build_document(
  1065. dataset,
  1066. dataset_process_rule.id, # type: ignore
  1067. knowledge_config.data_source.info_list.data_source_type, # type: ignore
  1068. knowledge_config.doc_form,
  1069. knowledge_config.doc_language,
  1070. data_source_info,
  1071. created_from,
  1072. position,
  1073. account,
  1074. document_name,
  1075. batch,
  1076. )
  1077. db.session.add(document)
  1078. db.session.flush()
  1079. document_ids.append(document.id)
  1080. documents.append(document)
  1081. position += 1
  1082. db.session.commit()
  1083. # trigger async task
  1084. if document_ids:
  1085. document_indexing_task.delay(dataset.id, document_ids)
  1086. if duplicate_document_ids:
  1087. duplicate_document_indexing_task.delay(dataset.id, duplicate_document_ids)
  1088. return documents, batch
  1089. @staticmethod
  1090. def check_documents_upload_quota(count: int, features: FeatureModel):
  1091. can_upload_size = features.documents_upload_quota.limit - features.documents_upload_quota.size
  1092. if count > can_upload_size:
  1093. raise ValueError(
  1094. f"You have reached the limit of your subscription. Only {can_upload_size} documents can be uploaded."
  1095. )
  1096. @staticmethod
  1097. def build_document(
  1098. dataset: Dataset,
  1099. process_rule_id: str,
  1100. data_source_type: str,
  1101. document_form: str,
  1102. document_language: str,
  1103. data_source_info: dict,
  1104. created_from: str,
  1105. position: int,
  1106. account: Account,
  1107. name: str,
  1108. batch: str,
  1109. ):
  1110. document = Document(
  1111. tenant_id=dataset.tenant_id,
  1112. dataset_id=dataset.id,
  1113. position=position,
  1114. data_source_type=data_source_type,
  1115. data_source_info=json.dumps(data_source_info),
  1116. dataset_process_rule_id=process_rule_id,
  1117. batch=batch,
  1118. name=name,
  1119. created_from=created_from,
  1120. created_by=account.id,
  1121. doc_form=document_form,
  1122. doc_language=document_language,
  1123. )
  1124. doc_metadata = {}
  1125. if dataset.built_in_field_enabled:
  1126. doc_metadata = {
  1127. BuiltInField.document_name: name,
  1128. BuiltInField.uploader: account.name,
  1129. BuiltInField.upload_date: datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d %H:%M:%S"),
  1130. BuiltInField.last_update_date: datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d %H:%M:%S"),
  1131. BuiltInField.source: data_source_type,
  1132. }
  1133. if doc_metadata:
  1134. document.doc_metadata = doc_metadata
  1135. return document
  1136. @staticmethod
  1137. def get_tenant_documents_count():
  1138. documents_count = (
  1139. db.session.query(Document)
  1140. .filter(
  1141. Document.completed_at.isnot(None),
  1142. Document.enabled == True,
  1143. Document.archived == False,
  1144. Document.tenant_id == current_user.current_tenant_id,
  1145. )
  1146. .count()
  1147. )
  1148. return documents_count
  1149. @staticmethod
  1150. def update_document_with_dataset_id(
  1151. dataset: Dataset,
  1152. document_data: KnowledgeConfig,
  1153. account: Account,
  1154. dataset_process_rule: Optional[DatasetProcessRule] = None,
  1155. created_from: str = "web",
  1156. ):
  1157. DatasetService.check_dataset_model_setting(dataset)
  1158. document = DocumentService.get_document(dataset.id, document_data.original_document_id)
  1159. if document is None:
  1160. raise NotFound("Document not found")
  1161. if document.display_status != "available":
  1162. raise ValueError("Document is not available")
  1163. # save process rule
  1164. if document_data.process_rule:
  1165. process_rule = document_data.process_rule
  1166. if process_rule.mode in {"custom", "hierarchical"}:
  1167. dataset_process_rule = DatasetProcessRule(
  1168. dataset_id=dataset.id,
  1169. mode=process_rule.mode,
  1170. rules=process_rule.rules.model_dump_json() if process_rule.rules else None,
  1171. created_by=account.id,
  1172. )
  1173. elif process_rule.mode == "automatic":
  1174. dataset_process_rule = DatasetProcessRule(
  1175. dataset_id=dataset.id,
  1176. mode=process_rule.mode,
  1177. rules=json.dumps(DatasetProcessRule.AUTOMATIC_RULES),
  1178. created_by=account.id,
  1179. )
  1180. if dataset_process_rule is not None:
  1181. db.session.add(dataset_process_rule)
  1182. db.session.commit()
  1183. document.dataset_process_rule_id = dataset_process_rule.id
  1184. # update document data source
  1185. if document_data.data_source:
  1186. file_name = ""
  1187. data_source_info = {}
  1188. if document_data.data_source.info_list.data_source_type == "upload_file":
  1189. if not document_data.data_source.info_list.file_info_list:
  1190. raise ValueError("No file info list found.")
  1191. upload_file_list = document_data.data_source.info_list.file_info_list.file_ids
  1192. for file_id in upload_file_list:
  1193. file = (
  1194. db.session.query(UploadFile)
  1195. .filter(UploadFile.tenant_id == dataset.tenant_id, UploadFile.id == file_id)
  1196. .first()
  1197. )
  1198. # raise error if file not found
  1199. if not file:
  1200. raise FileNotExistsError()
  1201. file_name = file.name
  1202. data_source_info = {
  1203. "upload_file_id": file_id,
  1204. }
  1205. elif document_data.data_source.info_list.data_source_type == "notion_import":
  1206. if not document_data.data_source.info_list.notion_info_list:
  1207. raise ValueError("No notion info list found.")
  1208. notion_info_list = document_data.data_source.info_list.notion_info_list
  1209. for notion_info in notion_info_list:
  1210. workspace_id = notion_info.workspace_id
  1211. data_source_binding = (
  1212. db.session.query(DataSourceOauthBinding)
  1213. .filter(
  1214. db.and_(
  1215. DataSourceOauthBinding.tenant_id == current_user.current_tenant_id,
  1216. DataSourceOauthBinding.provider == "notion",
  1217. DataSourceOauthBinding.disabled == False,
  1218. DataSourceOauthBinding.source_info["workspace_id"] == f'"{workspace_id}"',
  1219. )
  1220. )
  1221. .first()
  1222. )
  1223. if not data_source_binding:
  1224. raise ValueError("Data source binding not found.")
  1225. for page in notion_info.pages:
  1226. data_source_info = {
  1227. "notion_workspace_id": workspace_id,
  1228. "notion_page_id": page.page_id,
  1229. "notion_page_icon": page.page_icon.model_dump() if page.page_icon else None, # type: ignore
  1230. "type": page.type,
  1231. }
  1232. elif document_data.data_source.info_list.data_source_type == "website_crawl":
  1233. website_info = document_data.data_source.info_list.website_info_list
  1234. if website_info:
  1235. urls = website_info.urls
  1236. for url in urls:
  1237. data_source_info = {
  1238. "url": url,
  1239. "provider": website_info.provider,
  1240. "job_id": website_info.job_id,
  1241. "only_main_content": website_info.only_main_content, # type: ignore
  1242. "mode": "crawl",
  1243. }
  1244. document.data_source_type = document_data.data_source.info_list.data_source_type
  1245. document.data_source_info = json.dumps(data_source_info)
  1246. document.name = file_name
  1247. # update document name
  1248. if document_data.name:
  1249. document.name = document_data.name
  1250. # update document to be waiting
  1251. document.indexing_status = "waiting"
  1252. document.completed_at = None
  1253. document.processing_started_at = None
  1254. document.parsing_completed_at = None
  1255. document.cleaning_completed_at = None
  1256. document.splitting_completed_at = None
  1257. document.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1258. document.created_from = created_from
  1259. document.doc_form = document_data.doc_form
  1260. db.session.add(document)
  1261. db.session.commit()
  1262. # update document segment
  1263. update_params = {DocumentSegment.status: "re_segment"}
  1264. db.session.query(DocumentSegment).filter_by(document_id=document.id).update(update_params)
  1265. db.session.commit()
  1266. # trigger async task
  1267. document_indexing_update_task.delay(document.dataset_id, document.id)
  1268. return document
  1269. @staticmethod
  1270. def save_document_without_dataset_id(tenant_id: str, knowledge_config: KnowledgeConfig, account: Account):
  1271. features = FeatureService.get_features(current_user.current_tenant_id)
  1272. if features.billing.enabled:
  1273. count = 0
  1274. if knowledge_config.data_source.info_list.data_source_type == "upload_file": # type: ignore
  1275. upload_file_list = (
  1276. knowledge_config.data_source.info_list.file_info_list.file_ids # type: ignore
  1277. if knowledge_config.data_source.info_list.file_info_list # type: ignore
  1278. else []
  1279. )
  1280. count = len(upload_file_list)
  1281. elif knowledge_config.data_source.info_list.data_source_type == "notion_import": # type: ignore
  1282. notion_info_list = knowledge_config.data_source.info_list.notion_info_list # type: ignore
  1283. if notion_info_list:
  1284. for notion_info in notion_info_list:
  1285. count = count + len(notion_info.pages)
  1286. elif knowledge_config.data_source.info_list.data_source_type == "website_crawl": # type: ignore
  1287. website_info = knowledge_config.data_source.info_list.website_info_list # type: ignore
  1288. if website_info:
  1289. count = len(website_info.urls)
  1290. if features.billing.subscription.plan == "sandbox" and count > 1:
  1291. raise ValueError("Your current plan does not support batch upload, please upgrade your plan.")
  1292. batch_upload_limit = int(dify_config.BATCH_UPLOAD_LIMIT)
  1293. if count > batch_upload_limit:
  1294. raise ValueError(f"You have reached the batch upload limit of {batch_upload_limit}.")
  1295. DocumentService.check_documents_upload_quota(count, features)
  1296. dataset_collection_binding_id = None
  1297. retrieval_model = None
  1298. if knowledge_config.indexing_technique == "high_quality":
  1299. dataset_collection_binding = DatasetCollectionBindingService.get_dataset_collection_binding(
  1300. knowledge_config.embedding_model_provider, # type: ignore
  1301. knowledge_config.embedding_model, # type: ignore
  1302. )
  1303. dataset_collection_binding_id = dataset_collection_binding.id
  1304. if knowledge_config.retrieval_model:
  1305. retrieval_model = knowledge_config.retrieval_model
  1306. else:
  1307. retrieval_model = RetrievalModel(
  1308. search_method=RetrievalMethod.SEMANTIC_SEARCH.value,
  1309. reranking_enable=False,
  1310. reranking_model=RerankingModel(reranking_provider_name="", reranking_model_name=""),
  1311. top_k=2,
  1312. score_threshold_enabled=False,
  1313. )
  1314. # save dataset
  1315. dataset = Dataset(
  1316. tenant_id=tenant_id,
  1317. name="",
  1318. data_source_type=knowledge_config.data_source.info_list.data_source_type, # type: ignore
  1319. indexing_technique=knowledge_config.indexing_technique,
  1320. created_by=account.id,
  1321. embedding_model=knowledge_config.embedding_model,
  1322. embedding_model_provider=knowledge_config.embedding_model_provider,
  1323. collection_binding_id=dataset_collection_binding_id,
  1324. retrieval_model=retrieval_model.model_dump() if retrieval_model else None,
  1325. )
  1326. db.session.add(dataset) # type: ignore
  1327. db.session.flush()
  1328. documents, batch = DocumentService.save_document_with_dataset_id(dataset, knowledge_config, account)
  1329. cut_length = 18
  1330. cut_name = documents[0].name[:cut_length]
  1331. dataset.name = cut_name + "..."
  1332. dataset.description = "useful for when you want to answer queries about the " + documents[0].name
  1333. db.session.commit()
  1334. return dataset, documents, batch
  1335. @classmethod
  1336. def document_create_args_validate(cls, knowledge_config: KnowledgeConfig):
  1337. if not knowledge_config.data_source and not knowledge_config.process_rule:
  1338. raise ValueError("Data source or Process rule is required")
  1339. else:
  1340. if knowledge_config.data_source:
  1341. DocumentService.data_source_args_validate(knowledge_config)
  1342. if knowledge_config.process_rule:
  1343. DocumentService.process_rule_args_validate(knowledge_config)
  1344. @classmethod
  1345. def data_source_args_validate(cls, knowledge_config: KnowledgeConfig):
  1346. if not knowledge_config.data_source:
  1347. raise ValueError("Data source is required")
  1348. if knowledge_config.data_source.info_list.data_source_type not in Document.DATA_SOURCES:
  1349. raise ValueError("Data source type is invalid")
  1350. if not knowledge_config.data_source.info_list:
  1351. raise ValueError("Data source info is required")
  1352. if knowledge_config.data_source.info_list.data_source_type == "upload_file":
  1353. if not knowledge_config.data_source.info_list.file_info_list:
  1354. raise ValueError("File source info is required")
  1355. if knowledge_config.data_source.info_list.data_source_type == "notion_import":
  1356. if not knowledge_config.data_source.info_list.notion_info_list:
  1357. raise ValueError("Notion source info is required")
  1358. if knowledge_config.data_source.info_list.data_source_type == "website_crawl":
  1359. if not knowledge_config.data_source.info_list.website_info_list:
  1360. raise ValueError("Website source info is required")
  1361. @classmethod
  1362. def process_rule_args_validate(cls, knowledge_config: KnowledgeConfig):
  1363. if not knowledge_config.process_rule:
  1364. raise ValueError("Process rule is required")
  1365. if not knowledge_config.process_rule.mode:
  1366. raise ValueError("Process rule mode is required")
  1367. if knowledge_config.process_rule.mode not in DatasetProcessRule.MODES:
  1368. raise ValueError("Process rule mode is invalid")
  1369. if knowledge_config.process_rule.mode == "automatic":
  1370. knowledge_config.process_rule.rules = None
  1371. else:
  1372. if not knowledge_config.process_rule.rules:
  1373. raise ValueError("Process rule rules is required")
  1374. if knowledge_config.process_rule.rules.pre_processing_rules is None:
  1375. raise ValueError("Process rule pre_processing_rules is required")
  1376. unique_pre_processing_rule_dicts = {}
  1377. for pre_processing_rule in knowledge_config.process_rule.rules.pre_processing_rules:
  1378. if not pre_processing_rule.id:
  1379. raise ValueError("Process rule pre_processing_rules id is required")
  1380. if not isinstance(pre_processing_rule.enabled, bool):
  1381. raise ValueError("Process rule pre_processing_rules enabled is invalid")
  1382. unique_pre_processing_rule_dicts[pre_processing_rule.id] = pre_processing_rule
  1383. knowledge_config.process_rule.rules.pre_processing_rules = list(unique_pre_processing_rule_dicts.values())
  1384. if not knowledge_config.process_rule.rules.segmentation:
  1385. raise ValueError("Process rule segmentation is required")
  1386. if not knowledge_config.process_rule.rules.segmentation.separator:
  1387. raise ValueError("Process rule segmentation separator is required")
  1388. if not isinstance(knowledge_config.process_rule.rules.segmentation.separator, str):
  1389. raise ValueError("Process rule segmentation separator is invalid")
  1390. if not (
  1391. knowledge_config.process_rule.mode == "hierarchical"
  1392. and knowledge_config.process_rule.rules.parent_mode == "full-doc"
  1393. ):
  1394. if not knowledge_config.process_rule.rules.segmentation.max_tokens:
  1395. raise ValueError("Process rule segmentation max_tokens is required")
  1396. if not isinstance(knowledge_config.process_rule.rules.segmentation.max_tokens, int):
  1397. raise ValueError("Process rule segmentation max_tokens is invalid")
  1398. @classmethod
  1399. def estimate_args_validate(cls, args: dict):
  1400. if "info_list" not in args or not args["info_list"]:
  1401. raise ValueError("Data source info is required")
  1402. if not isinstance(args["info_list"], dict):
  1403. raise ValueError("Data info is invalid")
  1404. if "process_rule" not in args or not args["process_rule"]:
  1405. raise ValueError("Process rule is required")
  1406. if not isinstance(args["process_rule"], dict):
  1407. raise ValueError("Process rule is invalid")
  1408. if "mode" not in args["process_rule"] or not args["process_rule"]["mode"]:
  1409. raise ValueError("Process rule mode is required")
  1410. if args["process_rule"]["mode"] not in DatasetProcessRule.MODES:
  1411. raise ValueError("Process rule mode is invalid")
  1412. if args["process_rule"]["mode"] == "automatic":
  1413. args["process_rule"]["rules"] = {}
  1414. else:
  1415. if "rules" not in args["process_rule"] or not args["process_rule"]["rules"]:
  1416. raise ValueError("Process rule rules is required")
  1417. if not isinstance(args["process_rule"]["rules"], dict):
  1418. raise ValueError("Process rule rules is invalid")
  1419. if (
  1420. "pre_processing_rules" not in args["process_rule"]["rules"]
  1421. or args["process_rule"]["rules"]["pre_processing_rules"] is None
  1422. ):
  1423. raise ValueError("Process rule pre_processing_rules is required")
  1424. if not isinstance(args["process_rule"]["rules"]["pre_processing_rules"], list):
  1425. raise ValueError("Process rule pre_processing_rules is invalid")
  1426. unique_pre_processing_rule_dicts = {}
  1427. for pre_processing_rule in args["process_rule"]["rules"]["pre_processing_rules"]:
  1428. if "id" not in pre_processing_rule or not pre_processing_rule["id"]:
  1429. raise ValueError("Process rule pre_processing_rules id is required")
  1430. if pre_processing_rule["id"] not in DatasetProcessRule.PRE_PROCESSING_RULES:
  1431. raise ValueError("Process rule pre_processing_rules id is invalid")
  1432. if "enabled" not in pre_processing_rule or pre_processing_rule["enabled"] is None:
  1433. raise ValueError("Process rule pre_processing_rules enabled is required")
  1434. if not isinstance(pre_processing_rule["enabled"], bool):
  1435. raise ValueError("Process rule pre_processing_rules enabled is invalid")
  1436. unique_pre_processing_rule_dicts[pre_processing_rule["id"]] = pre_processing_rule
  1437. args["process_rule"]["rules"]["pre_processing_rules"] = list(unique_pre_processing_rule_dicts.values())
  1438. if (
  1439. "segmentation" not in args["process_rule"]["rules"]
  1440. or args["process_rule"]["rules"]["segmentation"] is None
  1441. ):
  1442. raise ValueError("Process rule segmentation is required")
  1443. if not isinstance(args["process_rule"]["rules"]["segmentation"], dict):
  1444. raise ValueError("Process rule segmentation is invalid")
  1445. if (
  1446. "separator" not in args["process_rule"]["rules"]["segmentation"]
  1447. or not args["process_rule"]["rules"]["segmentation"]["separator"]
  1448. ):
  1449. raise ValueError("Process rule segmentation separator is required")
  1450. if not isinstance(args["process_rule"]["rules"]["segmentation"]["separator"], str):
  1451. raise ValueError("Process rule segmentation separator is invalid")
  1452. if (
  1453. "max_tokens" not in args["process_rule"]["rules"]["segmentation"]
  1454. or not args["process_rule"]["rules"]["segmentation"]["max_tokens"]
  1455. ):
  1456. raise ValueError("Process rule segmentation max_tokens is required")
  1457. if not isinstance(args["process_rule"]["rules"]["segmentation"]["max_tokens"], int):
  1458. raise ValueError("Process rule segmentation max_tokens is invalid")
  1459. @staticmethod
  1460. def batch_update_document_status(dataset: Dataset, document_ids: list[str], action: str, user):
  1461. """
  1462. Batch update document status.
  1463. Args:
  1464. dataset (Dataset): The dataset object
  1465. document_ids (list[str]): List of document IDs to update
  1466. action (str): Action to perform (enable, disable, archive, un_archive)
  1467. user: Current user performing the action
  1468. Raises:
  1469. DocumentIndexingError: If document is being indexed or not in correct state
  1470. """
  1471. if not document_ids:
  1472. return
  1473. for document_id in document_ids:
  1474. document = DocumentService.get_document(dataset.id, document_id)
  1475. if not document:
  1476. continue
  1477. indexing_cache_key = f"document_{document.id}_indexing"
  1478. cache_result = redis_client.get(indexing_cache_key)
  1479. if cache_result is not None:
  1480. raise DocumentIndexingError(f"Document:{document.name} is being indexed, please try again later")
  1481. if action == "enable":
  1482. if document.enabled:
  1483. continue
  1484. document.enabled = True
  1485. document.disabled_at = None
  1486. document.disabled_by = None
  1487. document.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1488. db.session.commit()
  1489. # Set cache to prevent indexing the same document multiple times
  1490. redis_client.setex(indexing_cache_key, 600, 1)
  1491. add_document_to_index_task.delay(document_id)
  1492. elif action == "disable":
  1493. if not document.completed_at or document.indexing_status != "completed":
  1494. raise DocumentIndexingError(f"Document: {document.name} is not completed.")
  1495. if not document.enabled:
  1496. continue
  1497. document.enabled = False
  1498. document.disabled_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1499. document.disabled_by = user.id
  1500. document.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1501. db.session.commit()
  1502. # Set cache to prevent indexing the same document multiple times
  1503. redis_client.setex(indexing_cache_key, 600, 1)
  1504. remove_document_from_index_task.delay(document_id)
  1505. elif action == "archive":
  1506. if document.archived:
  1507. continue
  1508. document.archived = True
  1509. document.archived_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1510. document.archived_by = user.id
  1511. document.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1512. db.session.commit()
  1513. if document.enabled:
  1514. # Set cache to prevent indexing the same document multiple times
  1515. redis_client.setex(indexing_cache_key, 600, 1)
  1516. remove_document_from_index_task.delay(document_id)
  1517. elif action == "un_archive":
  1518. if not document.archived:
  1519. continue
  1520. document.archived = False
  1521. document.archived_at = None
  1522. document.archived_by = None
  1523. document.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1524. db.session.commit()
  1525. # Only re-index if the document is currently enabled
  1526. if document.enabled:
  1527. # Set cache to prevent indexing the same document multiple times
  1528. redis_client.setex(indexing_cache_key, 600, 1)
  1529. add_document_to_index_task.delay(document_id)
  1530. else:
  1531. raise ValueError(f"Invalid action: {action}")
  1532. class SegmentService:
  1533. @classmethod
  1534. def segment_create_args_validate(cls, args: dict, document: Document):
  1535. if document.doc_form == "qa_model":
  1536. if "answer" not in args or not args["answer"]:
  1537. raise ValueError("Answer is required")
  1538. if not args["answer"].strip():
  1539. raise ValueError("Answer is empty")
  1540. if "content" not in args or not args["content"] or not args["content"].strip():
  1541. raise ValueError("Content is empty")
  1542. @classmethod
  1543. def create_segment(cls, args: dict, document: Document, dataset: Dataset):
  1544. content = args["content"]
  1545. doc_id = str(uuid.uuid4())
  1546. segment_hash = helper.generate_text_hash(content)
  1547. tokens = 0
  1548. if dataset.indexing_technique == "high_quality":
  1549. model_manager = ModelManager()
  1550. embedding_model = model_manager.get_model_instance(
  1551. tenant_id=current_user.current_tenant_id,
  1552. provider=dataset.embedding_model_provider,
  1553. model_type=ModelType.TEXT_EMBEDDING,
  1554. model=dataset.embedding_model,
  1555. )
  1556. # calc embedding use tokens
  1557. tokens = embedding_model.get_text_embedding_num_tokens(texts=[content])[0]
  1558. lock_name = "add_segment_lock_document_id_{}".format(document.id)
  1559. with redis_client.lock(lock_name, timeout=600):
  1560. max_position = (
  1561. db.session.query(func.max(DocumentSegment.position))
  1562. .filter(DocumentSegment.document_id == document.id)
  1563. .scalar()
  1564. )
  1565. segment_document = DocumentSegment(
  1566. tenant_id=current_user.current_tenant_id,
  1567. dataset_id=document.dataset_id,
  1568. document_id=document.id,
  1569. index_node_id=doc_id,
  1570. index_node_hash=segment_hash,
  1571. position=max_position + 1 if max_position else 1,
  1572. content=content,
  1573. word_count=len(content),
  1574. tokens=tokens,
  1575. status="completed",
  1576. indexing_at=datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
  1577. completed_at=datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
  1578. created_by=current_user.id,
  1579. )
  1580. if document.doc_form == "qa_model":
  1581. segment_document.word_count += len(args["answer"])
  1582. segment_document.answer = args["answer"]
  1583. db.session.add(segment_document)
  1584. # update document word count
  1585. document.word_count += segment_document.word_count
  1586. db.session.add(document)
  1587. db.session.commit()
  1588. # save vector index
  1589. try:
  1590. VectorService.create_segments_vector([args["keywords"]], [segment_document], dataset, document.doc_form)
  1591. except Exception as e:
  1592. logging.exception("create segment index failed")
  1593. segment_document.enabled = False
  1594. segment_document.disabled_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1595. segment_document.status = "error"
  1596. segment_document.error = str(e)
  1597. db.session.commit()
  1598. segment = db.session.query(DocumentSegment).filter(DocumentSegment.id == segment_document.id).first()
  1599. return segment
  1600. @classmethod
  1601. def multi_create_segment(cls, segments: list, document: Document, dataset: Dataset):
  1602. lock_name = "multi_add_segment_lock_document_id_{}".format(document.id)
  1603. increment_word_count = 0
  1604. with redis_client.lock(lock_name, timeout=600):
  1605. embedding_model = None
  1606. if dataset.indexing_technique == "high_quality":
  1607. model_manager = ModelManager()
  1608. embedding_model = model_manager.get_model_instance(
  1609. tenant_id=current_user.current_tenant_id,
  1610. provider=dataset.embedding_model_provider,
  1611. model_type=ModelType.TEXT_EMBEDDING,
  1612. model=dataset.embedding_model,
  1613. )
  1614. max_position = (
  1615. db.session.query(func.max(DocumentSegment.position))
  1616. .filter(DocumentSegment.document_id == document.id)
  1617. .scalar()
  1618. )
  1619. pre_segment_data_list = []
  1620. segment_data_list = []
  1621. keywords_list = []
  1622. position = max_position + 1 if max_position else 1
  1623. for segment_item in segments:
  1624. content = segment_item["content"]
  1625. doc_id = str(uuid.uuid4())
  1626. segment_hash = helper.generate_text_hash(content)
  1627. tokens = 0
  1628. if dataset.indexing_technique == "high_quality" and embedding_model:
  1629. # calc embedding use tokens
  1630. if document.doc_form == "qa_model":
  1631. tokens = embedding_model.get_text_embedding_num_tokens(
  1632. texts=[content + segment_item["answer"]]
  1633. )[0]
  1634. else:
  1635. tokens = embedding_model.get_text_embedding_num_tokens(texts=[content])[0]
  1636. segment_document = DocumentSegment(
  1637. tenant_id=current_user.current_tenant_id,
  1638. dataset_id=document.dataset_id,
  1639. document_id=document.id,
  1640. index_node_id=doc_id,
  1641. index_node_hash=segment_hash,
  1642. position=position,
  1643. content=content,
  1644. word_count=len(content),
  1645. tokens=tokens,
  1646. keywords=segment_item.get("keywords", []),
  1647. status="completed",
  1648. indexing_at=datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
  1649. completed_at=datetime.datetime.now(datetime.UTC).replace(tzinfo=None),
  1650. created_by=current_user.id,
  1651. )
  1652. if document.doc_form == "qa_model":
  1653. segment_document.answer = segment_item["answer"]
  1654. segment_document.word_count += len(segment_item["answer"])
  1655. increment_word_count += segment_document.word_count
  1656. db.session.add(segment_document)
  1657. segment_data_list.append(segment_document)
  1658. position += 1
  1659. pre_segment_data_list.append(segment_document)
  1660. if "keywords" in segment_item:
  1661. keywords_list.append(segment_item["keywords"])
  1662. else:
  1663. keywords_list.append(None)
  1664. # update document word count
  1665. document.word_count += increment_word_count
  1666. db.session.add(document)
  1667. try:
  1668. # save vector index
  1669. VectorService.create_segments_vector(keywords_list, pre_segment_data_list, dataset, document.doc_form)
  1670. except Exception as e:
  1671. logging.exception("create segment index failed")
  1672. for segment_document in segment_data_list:
  1673. segment_document.enabled = False
  1674. segment_document.disabled_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1675. segment_document.status = "error"
  1676. segment_document.error = str(e)
  1677. db.session.commit()
  1678. return segment_data_list
  1679. @classmethod
  1680. def update_segment(cls, args: SegmentUpdateArgs, segment: DocumentSegment, document: Document, dataset: Dataset):
  1681. indexing_cache_key = "segment_{}_indexing".format(segment.id)
  1682. cache_result = redis_client.get(indexing_cache_key)
  1683. if cache_result is not None:
  1684. raise ValueError("Segment is indexing, please try again later")
  1685. if args.enabled is not None:
  1686. action = args.enabled
  1687. if segment.enabled != action:
  1688. if not action:
  1689. segment.enabled = action
  1690. segment.disabled_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1691. segment.disabled_by = current_user.id
  1692. db.session.add(segment)
  1693. db.session.commit()
  1694. # Set cache to prevent indexing the same segment multiple times
  1695. redis_client.setex(indexing_cache_key, 600, 1)
  1696. disable_segment_from_index_task.delay(segment.id)
  1697. return segment
  1698. if not segment.enabled:
  1699. if args.enabled is not None:
  1700. if not args.enabled:
  1701. raise ValueError("Can't update disabled segment")
  1702. else:
  1703. raise ValueError("Can't update disabled segment")
  1704. try:
  1705. word_count_change = segment.word_count
  1706. content = args.content or segment.content
  1707. if segment.content == content:
  1708. segment.word_count = len(content)
  1709. if document.doc_form == "qa_model":
  1710. segment.answer = args.answer
  1711. segment.word_count += len(args.answer) if args.answer else 0
  1712. word_count_change = segment.word_count - word_count_change
  1713. keyword_changed = False
  1714. if args.keywords:
  1715. if Counter(segment.keywords) != Counter(args.keywords):
  1716. segment.keywords = args.keywords
  1717. keyword_changed = True
  1718. segment.enabled = True
  1719. segment.disabled_at = None
  1720. segment.disabled_by = None
  1721. db.session.add(segment)
  1722. db.session.commit()
  1723. # update document word count
  1724. if word_count_change != 0:
  1725. document.word_count = max(0, document.word_count + word_count_change)
  1726. db.session.add(document)
  1727. # update segment index task
  1728. if document.doc_form == IndexType.PARENT_CHILD_INDEX and args.regenerate_child_chunks:
  1729. # regenerate child chunks
  1730. # get embedding model instance
  1731. if dataset.indexing_technique == "high_quality":
  1732. # check embedding model setting
  1733. model_manager = ModelManager()
  1734. if dataset.embedding_model_provider:
  1735. embedding_model_instance = model_manager.get_model_instance(
  1736. tenant_id=dataset.tenant_id,
  1737. provider=dataset.embedding_model_provider,
  1738. model_type=ModelType.TEXT_EMBEDDING,
  1739. model=dataset.embedding_model,
  1740. )
  1741. else:
  1742. embedding_model_instance = model_manager.get_default_model_instance(
  1743. tenant_id=dataset.tenant_id,
  1744. model_type=ModelType.TEXT_EMBEDDING,
  1745. )
  1746. else:
  1747. raise ValueError("The knowledge base index technique is not high quality!")
  1748. # get the process rule
  1749. processing_rule = (
  1750. db.session.query(DatasetProcessRule)
  1751. .filter(DatasetProcessRule.id == document.dataset_process_rule_id)
  1752. .first()
  1753. )
  1754. if not processing_rule:
  1755. raise ValueError("No processing rule found.")
  1756. VectorService.generate_child_chunks(
  1757. segment, document, dataset, embedding_model_instance, processing_rule, True
  1758. )
  1759. elif document.doc_form in (IndexType.PARAGRAPH_INDEX, IndexType.QA_INDEX):
  1760. if args.enabled or keyword_changed:
  1761. # update segment vector index
  1762. VectorService.update_segment_vector(args.keywords, segment, dataset)
  1763. else:
  1764. segment_hash = helper.generate_text_hash(content)
  1765. tokens = 0
  1766. if dataset.indexing_technique == "high_quality":
  1767. model_manager = ModelManager()
  1768. embedding_model = model_manager.get_model_instance(
  1769. tenant_id=current_user.current_tenant_id,
  1770. provider=dataset.embedding_model_provider,
  1771. model_type=ModelType.TEXT_EMBEDDING,
  1772. model=dataset.embedding_model,
  1773. )
  1774. # calc embedding use tokens
  1775. if document.doc_form == "qa_model":
  1776. tokens = embedding_model.get_text_embedding_num_tokens(texts=[content + segment.answer])[0]
  1777. else:
  1778. tokens = embedding_model.get_text_embedding_num_tokens(texts=[content])[0]
  1779. segment.content = content
  1780. segment.index_node_hash = segment_hash
  1781. segment.word_count = len(content)
  1782. segment.tokens = tokens
  1783. segment.status = "completed"
  1784. segment.indexing_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1785. segment.completed_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1786. segment.updated_by = current_user.id
  1787. segment.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1788. segment.enabled = True
  1789. segment.disabled_at = None
  1790. segment.disabled_by = None
  1791. if document.doc_form == "qa_model":
  1792. segment.answer = args.answer
  1793. segment.word_count += len(args.answer) if args.answer else 0
  1794. word_count_change = segment.word_count - word_count_change
  1795. # update document word count
  1796. if word_count_change != 0:
  1797. document.word_count = max(0, document.word_count + word_count_change)
  1798. db.session.add(document)
  1799. db.session.add(segment)
  1800. db.session.commit()
  1801. if document.doc_form == IndexType.PARENT_CHILD_INDEX and args.regenerate_child_chunks:
  1802. # get embedding model instance
  1803. if dataset.indexing_technique == "high_quality":
  1804. # check embedding model setting
  1805. model_manager = ModelManager()
  1806. if dataset.embedding_model_provider:
  1807. embedding_model_instance = model_manager.get_model_instance(
  1808. tenant_id=dataset.tenant_id,
  1809. provider=dataset.embedding_model_provider,
  1810. model_type=ModelType.TEXT_EMBEDDING,
  1811. model=dataset.embedding_model,
  1812. )
  1813. else:
  1814. embedding_model_instance = model_manager.get_default_model_instance(
  1815. tenant_id=dataset.tenant_id,
  1816. model_type=ModelType.TEXT_EMBEDDING,
  1817. )
  1818. else:
  1819. raise ValueError("The knowledge base index technique is not high quality!")
  1820. # get the process rule
  1821. processing_rule = (
  1822. db.session.query(DatasetProcessRule)
  1823. .filter(DatasetProcessRule.id == document.dataset_process_rule_id)
  1824. .first()
  1825. )
  1826. if not processing_rule:
  1827. raise ValueError("No processing rule found.")
  1828. VectorService.generate_child_chunks(
  1829. segment, document, dataset, embedding_model_instance, processing_rule, True
  1830. )
  1831. elif document.doc_form in (IndexType.PARAGRAPH_INDEX, IndexType.QA_INDEX):
  1832. # update segment vector index
  1833. VectorService.update_segment_vector(args.keywords, segment, dataset)
  1834. except Exception as e:
  1835. logging.exception("update segment index failed")
  1836. segment.enabled = False
  1837. segment.disabled_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1838. segment.status = "error"
  1839. segment.error = str(e)
  1840. db.session.commit()
  1841. new_segment = db.session.query(DocumentSegment).filter(DocumentSegment.id == segment.id).first()
  1842. return new_segment
  1843. @classmethod
  1844. def delete_segment(cls, segment: DocumentSegment, document: Document, dataset: Dataset):
  1845. indexing_cache_key = "segment_{}_delete_indexing".format(segment.id)
  1846. cache_result = redis_client.get(indexing_cache_key)
  1847. if cache_result is not None:
  1848. raise ValueError("Segment is deleting.")
  1849. # enabled segment need to delete index
  1850. if segment.enabled:
  1851. # send delete segment index task
  1852. redis_client.setex(indexing_cache_key, 600, 1)
  1853. delete_segment_from_index_task.delay([segment.index_node_id], dataset.id, document.id)
  1854. db.session.delete(segment)
  1855. # update document word count
  1856. document.word_count -= segment.word_count
  1857. db.session.add(document)
  1858. db.session.commit()
  1859. @classmethod
  1860. def delete_segments(cls, segment_ids: list, document: Document, dataset: Dataset):
  1861. index_node_ids = (
  1862. db.session.query(DocumentSegment)
  1863. .with_entities(DocumentSegment.index_node_id)
  1864. .filter(
  1865. DocumentSegment.id.in_(segment_ids),
  1866. DocumentSegment.dataset_id == dataset.id,
  1867. DocumentSegment.document_id == document.id,
  1868. DocumentSegment.tenant_id == current_user.current_tenant_id,
  1869. )
  1870. .all()
  1871. )
  1872. index_node_ids = [index_node_id[0] for index_node_id in index_node_ids]
  1873. delete_segment_from_index_task.delay(index_node_ids, dataset.id, document.id)
  1874. db.session.query(DocumentSegment).filter(DocumentSegment.id.in_(segment_ids)).delete()
  1875. db.session.commit()
  1876. @classmethod
  1877. def update_segments_status(cls, segment_ids: list, action: str, dataset: Dataset, document: Document):
  1878. if action == "enable":
  1879. segments = (
  1880. db.session.query(DocumentSegment)
  1881. .filter(
  1882. DocumentSegment.id.in_(segment_ids),
  1883. DocumentSegment.dataset_id == dataset.id,
  1884. DocumentSegment.document_id == document.id,
  1885. DocumentSegment.enabled == False,
  1886. )
  1887. .all()
  1888. )
  1889. if not segments:
  1890. return
  1891. real_deal_segmment_ids = []
  1892. for segment in segments:
  1893. indexing_cache_key = "segment_{}_indexing".format(segment.id)
  1894. cache_result = redis_client.get(indexing_cache_key)
  1895. if cache_result is not None:
  1896. continue
  1897. segment.enabled = True
  1898. segment.disabled_at = None
  1899. segment.disabled_by = None
  1900. db.session.add(segment)
  1901. real_deal_segmment_ids.append(segment.id)
  1902. db.session.commit()
  1903. enable_segments_to_index_task.delay(real_deal_segmment_ids, dataset.id, document.id)
  1904. elif action == "disable":
  1905. segments = (
  1906. db.session.query(DocumentSegment)
  1907. .filter(
  1908. DocumentSegment.id.in_(segment_ids),
  1909. DocumentSegment.dataset_id == dataset.id,
  1910. DocumentSegment.document_id == document.id,
  1911. DocumentSegment.enabled == True,
  1912. )
  1913. .all()
  1914. )
  1915. if not segments:
  1916. return
  1917. real_deal_segmment_ids = []
  1918. for segment in segments:
  1919. indexing_cache_key = "segment_{}_indexing".format(segment.id)
  1920. cache_result = redis_client.get(indexing_cache_key)
  1921. if cache_result is not None:
  1922. continue
  1923. segment.enabled = False
  1924. segment.disabled_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  1925. segment.disabled_by = current_user.id
  1926. db.session.add(segment)
  1927. real_deal_segmment_ids.append(segment.id)
  1928. db.session.commit()
  1929. disable_segments_from_index_task.delay(real_deal_segmment_ids, dataset.id, document.id)
  1930. else:
  1931. raise InvalidActionError()
  1932. @classmethod
  1933. def create_child_chunk(
  1934. cls, content: str, segment: DocumentSegment, document: Document, dataset: Dataset
  1935. ) -> ChildChunk:
  1936. lock_name = "add_child_lock_{}".format(segment.id)
  1937. with redis_client.lock(lock_name, timeout=20):
  1938. index_node_id = str(uuid.uuid4())
  1939. index_node_hash = helper.generate_text_hash(content)
  1940. child_chunk_count = (
  1941. db.session.query(ChildChunk)
  1942. .filter(
  1943. ChildChunk.tenant_id == current_user.current_tenant_id,
  1944. ChildChunk.dataset_id == dataset.id,
  1945. ChildChunk.document_id == document.id,
  1946. ChildChunk.segment_id == segment.id,
  1947. )
  1948. .count()
  1949. )
  1950. max_position = (
  1951. db.session.query(func.max(ChildChunk.position))
  1952. .filter(
  1953. ChildChunk.tenant_id == current_user.current_tenant_id,
  1954. ChildChunk.dataset_id == dataset.id,
  1955. ChildChunk.document_id == document.id,
  1956. ChildChunk.segment_id == segment.id,
  1957. )
  1958. .scalar()
  1959. )
  1960. child_chunk = ChildChunk(
  1961. tenant_id=current_user.current_tenant_id,
  1962. dataset_id=dataset.id,
  1963. document_id=document.id,
  1964. segment_id=segment.id,
  1965. position=max_position + 1 if max_position else 1,
  1966. index_node_id=index_node_id,
  1967. index_node_hash=index_node_hash,
  1968. content=content,
  1969. word_count=len(content),
  1970. type="customized",
  1971. created_by=current_user.id,
  1972. )
  1973. db.session.add(child_chunk)
  1974. # save vector index
  1975. try:
  1976. VectorService.create_child_chunk_vector(child_chunk, dataset)
  1977. except Exception as e:
  1978. logging.exception("create child chunk index failed")
  1979. db.session.rollback()
  1980. raise ChildChunkIndexingError(str(e))
  1981. db.session.commit()
  1982. return child_chunk
  1983. @classmethod
  1984. def update_child_chunks(
  1985. cls,
  1986. child_chunks_update_args: list[ChildChunkUpdateArgs],
  1987. segment: DocumentSegment,
  1988. document: Document,
  1989. dataset: Dataset,
  1990. ) -> list[ChildChunk]:
  1991. child_chunks = (
  1992. db.session.query(ChildChunk)
  1993. .filter(
  1994. ChildChunk.dataset_id == dataset.id,
  1995. ChildChunk.document_id == document.id,
  1996. ChildChunk.segment_id == segment.id,
  1997. )
  1998. .all()
  1999. )
  2000. child_chunks_map = {chunk.id: chunk for chunk in child_chunks}
  2001. new_child_chunks, update_child_chunks, delete_child_chunks, new_child_chunks_args = [], [], [], []
  2002. for child_chunk_update_args in child_chunks_update_args:
  2003. if child_chunk_update_args.id:
  2004. child_chunk = child_chunks_map.pop(child_chunk_update_args.id, None)
  2005. if child_chunk:
  2006. if child_chunk.content != child_chunk_update_args.content:
  2007. child_chunk.content = child_chunk_update_args.content
  2008. child_chunk.word_count = len(child_chunk.content)
  2009. child_chunk.updated_by = current_user.id
  2010. child_chunk.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  2011. child_chunk.type = "customized"
  2012. update_child_chunks.append(child_chunk)
  2013. else:
  2014. new_child_chunks_args.append(child_chunk_update_args)
  2015. if child_chunks_map:
  2016. delete_child_chunks = list(child_chunks_map.values())
  2017. try:
  2018. if update_child_chunks:
  2019. db.session.bulk_save_objects(update_child_chunks)
  2020. if delete_child_chunks:
  2021. for child_chunk in delete_child_chunks:
  2022. db.session.delete(child_chunk)
  2023. if new_child_chunks_args:
  2024. child_chunk_count = len(child_chunks)
  2025. for position, args in enumerate(new_child_chunks_args, start=child_chunk_count + 1):
  2026. index_node_id = str(uuid.uuid4())
  2027. index_node_hash = helper.generate_text_hash(args.content)
  2028. child_chunk = ChildChunk(
  2029. tenant_id=current_user.current_tenant_id,
  2030. dataset_id=dataset.id,
  2031. document_id=document.id,
  2032. segment_id=segment.id,
  2033. position=position,
  2034. index_node_id=index_node_id,
  2035. index_node_hash=index_node_hash,
  2036. content=args.content,
  2037. word_count=len(args.content),
  2038. type="customized",
  2039. created_by=current_user.id,
  2040. )
  2041. db.session.add(child_chunk)
  2042. db.session.flush()
  2043. new_child_chunks.append(child_chunk)
  2044. VectorService.update_child_chunk_vector(new_child_chunks, update_child_chunks, delete_child_chunks, dataset)
  2045. db.session.commit()
  2046. except Exception as e:
  2047. logging.exception("update child chunk index failed")
  2048. db.session.rollback()
  2049. raise ChildChunkIndexingError(str(e))
  2050. return sorted(new_child_chunks + update_child_chunks, key=lambda x: x.position)
  2051. @classmethod
  2052. def update_child_chunk(
  2053. cls,
  2054. content: str,
  2055. child_chunk: ChildChunk,
  2056. segment: DocumentSegment,
  2057. document: Document,
  2058. dataset: Dataset,
  2059. ) -> ChildChunk:
  2060. try:
  2061. child_chunk.content = content
  2062. child_chunk.word_count = len(content)
  2063. child_chunk.updated_by = current_user.id
  2064. child_chunk.updated_at = datetime.datetime.now(datetime.UTC).replace(tzinfo=None)
  2065. child_chunk.type = "customized"
  2066. db.session.add(child_chunk)
  2067. VectorService.update_child_chunk_vector([], [child_chunk], [], dataset)
  2068. db.session.commit()
  2069. except Exception as e:
  2070. logging.exception("update child chunk index failed")
  2071. db.session.rollback()
  2072. raise ChildChunkIndexingError(str(e))
  2073. return child_chunk
  2074. @classmethod
  2075. def delete_child_chunk(cls, child_chunk: ChildChunk, dataset: Dataset):
  2076. db.session.delete(child_chunk)
  2077. try:
  2078. VectorService.delete_child_chunk_vector(child_chunk, dataset)
  2079. except Exception as e:
  2080. logging.exception("delete child chunk index failed")
  2081. db.session.rollback()
  2082. raise ChildChunkDeleteIndexError(str(e))
  2083. db.session.commit()
  2084. @classmethod
  2085. def get_child_chunks(
  2086. cls, segment_id: str, document_id: str, dataset_id: str, page: int, limit: int, keyword: Optional[str] = None
  2087. ):
  2088. query = (
  2089. select(ChildChunk)
  2090. .filter_by(
  2091. tenant_id=current_user.current_tenant_id,
  2092. dataset_id=dataset_id,
  2093. document_id=document_id,
  2094. segment_id=segment_id,
  2095. )
  2096. .order_by(ChildChunk.position.asc())
  2097. )
  2098. if keyword:
  2099. query = query.where(ChildChunk.content.ilike(f"%{keyword}%"))
  2100. return db.paginate(select=query, page=page, per_page=limit, max_per_page=100, error_out=False)
  2101. @classmethod
  2102. def get_child_chunk_by_id(cls, child_chunk_id: str, tenant_id: str) -> Optional[ChildChunk]:
  2103. """Get a child chunk by its ID."""
  2104. result = (
  2105. db.session.query(ChildChunk)
  2106. .filter(ChildChunk.id == child_chunk_id, ChildChunk.tenant_id == tenant_id)
  2107. .first()
  2108. )
  2109. return result if isinstance(result, ChildChunk) else None
  2110. @classmethod
  2111. def get_segments(
  2112. cls,
  2113. document_id: str,
  2114. tenant_id: str,
  2115. status_list: list[str] | None = None,
  2116. keyword: str | None = None,
  2117. page: int = 1,
  2118. limit: int = 20,
  2119. ):
  2120. """Get segments for a document with optional filtering."""
  2121. query = select(DocumentSegment).filter(
  2122. DocumentSegment.document_id == document_id, DocumentSegment.tenant_id == tenant_id
  2123. )
  2124. if status_list:
  2125. query = query.filter(DocumentSegment.status.in_(status_list))
  2126. if keyword:
  2127. query = query.filter(DocumentSegment.content.ilike(f"%{keyword}%"))
  2128. query = query.order_by(DocumentSegment.position.asc())
  2129. paginated_segments = db.paginate(select=query, page=page, per_page=limit, max_per_page=100, error_out=False)
  2130. return paginated_segments.items, paginated_segments.total
  2131. @classmethod
  2132. def update_segment_by_id(
  2133. cls, tenant_id: str, dataset_id: str, document_id: str, segment_id: str, segment_data: dict, user_id: str
  2134. ) -> tuple[DocumentSegment, Document]:
  2135. """Update a segment by its ID with validation and checks."""
  2136. # check dataset
  2137. dataset = db.session.query(Dataset).filter(Dataset.tenant_id == tenant_id, Dataset.id == dataset_id).first()
  2138. if not dataset:
  2139. raise NotFound("Dataset not found.")
  2140. # check user's model setting
  2141. DatasetService.check_dataset_model_setting(dataset)
  2142. # check document
  2143. document = DocumentService.get_document(dataset_id, document_id)
  2144. if not document:
  2145. raise NotFound("Document not found.")
  2146. # check embedding model setting if high quality
  2147. if dataset.indexing_technique == "high_quality":
  2148. try:
  2149. model_manager = ModelManager()
  2150. model_manager.get_model_instance(
  2151. tenant_id=user_id,
  2152. provider=dataset.embedding_model_provider,
  2153. model_type=ModelType.TEXT_EMBEDDING,
  2154. model=dataset.embedding_model,
  2155. )
  2156. except LLMBadRequestError:
  2157. raise ValueError(
  2158. "No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider."
  2159. )
  2160. except ProviderTokenNotInitError as ex:
  2161. raise ValueError(ex.description)
  2162. # check segment
  2163. segment = (
  2164. db.session.query(DocumentSegment)
  2165. .filter(DocumentSegment.id == segment_id, DocumentSegment.tenant_id == user_id)
  2166. .first()
  2167. )
  2168. if not segment:
  2169. raise NotFound("Segment not found.")
  2170. # validate and update segment
  2171. cls.segment_create_args_validate(segment_data, document)
  2172. updated_segment = cls.update_segment(SegmentUpdateArgs(**segment_data), segment, document, dataset)
  2173. return updated_segment, document
  2174. @classmethod
  2175. def get_segment_by_id(cls, segment_id: str, tenant_id: str) -> Optional[DocumentSegment]:
  2176. """Get a segment by its ID."""
  2177. result = (
  2178. db.session.query(DocumentSegment)
  2179. .filter(DocumentSegment.id == segment_id, DocumentSegment.tenant_id == tenant_id)
  2180. .first()
  2181. )
  2182. return result if isinstance(result, DocumentSegment) else None
  2183. class DatasetCollectionBindingService:
  2184. @classmethod
  2185. def get_dataset_collection_binding(
  2186. cls, provider_name: str, model_name: str, collection_type: str = "dataset"
  2187. ) -> DatasetCollectionBinding:
  2188. dataset_collection_binding = (
  2189. db.session.query(DatasetCollectionBinding)
  2190. .filter(
  2191. DatasetCollectionBinding.provider_name == provider_name,
  2192. DatasetCollectionBinding.model_name == model_name,
  2193. DatasetCollectionBinding.type == collection_type,
  2194. )
  2195. .order_by(DatasetCollectionBinding.created_at)
  2196. .first()
  2197. )
  2198. if not dataset_collection_binding:
  2199. dataset_collection_binding = DatasetCollectionBinding(
  2200. provider_name=provider_name,
  2201. model_name=model_name,
  2202. collection_name=Dataset.gen_collection_name_by_id(str(uuid.uuid4())),
  2203. type=collection_type,
  2204. )
  2205. db.session.add(dataset_collection_binding)
  2206. db.session.commit()
  2207. return dataset_collection_binding
  2208. @classmethod
  2209. def get_dataset_collection_binding_by_id_and_type(
  2210. cls, collection_binding_id: str, collection_type: str = "dataset"
  2211. ) -> DatasetCollectionBinding:
  2212. dataset_collection_binding = (
  2213. db.session.query(DatasetCollectionBinding)
  2214. .filter(
  2215. DatasetCollectionBinding.id == collection_binding_id, DatasetCollectionBinding.type == collection_type
  2216. )
  2217. .order_by(DatasetCollectionBinding.created_at)
  2218. .first()
  2219. )
  2220. if not dataset_collection_binding:
  2221. raise ValueError("Dataset collection binding not found")
  2222. return dataset_collection_binding
  2223. class DatasetPermissionService:
  2224. @classmethod
  2225. def get_dataset_partial_member_list(cls, dataset_id):
  2226. user_list_query = (
  2227. db.session.query(
  2228. DatasetPermission.account_id,
  2229. )
  2230. .filter(DatasetPermission.dataset_id == dataset_id)
  2231. .all()
  2232. )
  2233. user_list = []
  2234. for user in user_list_query:
  2235. user_list.append(user.account_id)
  2236. return user_list
  2237. @classmethod
  2238. def update_partial_member_list(cls, tenant_id, dataset_id, user_list):
  2239. try:
  2240. db.session.query(DatasetPermission).filter(DatasetPermission.dataset_id == dataset_id).delete()
  2241. permissions = []
  2242. for user in user_list:
  2243. permission = DatasetPermission(
  2244. tenant_id=tenant_id,
  2245. dataset_id=dataset_id,
  2246. account_id=user["user_id"],
  2247. )
  2248. permissions.append(permission)
  2249. db.session.add_all(permissions)
  2250. db.session.commit()
  2251. except Exception as e:
  2252. db.session.rollback()
  2253. raise e
  2254. @classmethod
  2255. def check_permission(cls, user, dataset, requested_permission, requested_partial_member_list):
  2256. if not user.is_dataset_editor:
  2257. raise NoPermissionError("User does not have permission to edit this dataset.")
  2258. if user.is_dataset_operator and dataset.permission != requested_permission:
  2259. raise NoPermissionError("Dataset operators cannot change the dataset permissions.")
  2260. if user.is_dataset_operator and requested_permission == "partial_members":
  2261. if not requested_partial_member_list:
  2262. raise ValueError("Partial member list is required when setting to partial members.")
  2263. local_member_list = cls.get_dataset_partial_member_list(dataset.id)
  2264. request_member_list = [user["user_id"] for user in requested_partial_member_list]
  2265. if set(local_member_list) != set(request_member_list):
  2266. raise ValueError("Dataset operators cannot change the dataset permissions.")
  2267. @classmethod
  2268. def clear_partial_member_list(cls, dataset_id):
  2269. try:
  2270. db.session.query(DatasetPermission).filter(DatasetPermission.dataset_id == dataset_id).delete()
  2271. db.session.commit()
  2272. except Exception as e:
  2273. db.session.rollback()
  2274. raise e