diff --git a/agent/__init__.py b/agent/__init__.py index 6bfdd33d0ba371e4b0a573d397af42eee2d8f3b6..643f79713c834d938c21dba9e1d0b63bba6676ed 100644 --- a/agent/__init__.py +++ b/agent/__init__.py @@ -1,2 +1,18 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from beartype.claw import beartype_this_package beartype_this_package() diff --git a/agent/component/__init__.py b/agent/component/__init__.py index 0d414fca997587e70e4d716698be81869ecd986c..da06c878c043a9b6ecc1977ff302718a5a27473b 100644 --- a/agent/component/__init__.py +++ b/agent/component/__init__.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import importlib from .begin import Begin, BeginParam from .generate import Generate, GenerateParam diff --git a/agent/settings.py b/agent/settings.py index fbdb263dc74dbdbf69d0a3cbca6cc055fb776c32..932cb1d57a5a4caaffde688e456ab77dd0f02092 100644 --- a/agent/settings.py +++ b/agent/settings.py @@ -1,5 +1,5 @@ # -# Copyright 2019 The FATE Authors. All Rights Reserved. +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/api/__init__.py b/api/__init__.py index 6bfdd33d0ba371e4b0a573d397af42eee2d8f3b6..643f79713c834d938c21dba9e1d0b63bba6676ed 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1,2 +1,18 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from beartype.claw import beartype_this_package beartype_this_package() diff --git a/api/utils/t_crypt.py b/api/utils/t_crypt.py index 67fd69c627a1ea6e39ff1b49bb6ea44c095a31a2..cd9d1edcc9f1718b4455039e9285e85d3ac34260 100644 --- a/api/utils/t_crypt.py +++ b/api/utils/t_crypt.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import base64 import os import sys diff --git a/api/utils/web_utils.py b/api/utils/web_utils.py index 687d683acbee8cb76be00d822061b5696690a385..084b7a6f73fc4e9e09a35b8400cf37410ae9561e 100644 --- a/api/utils/web_utils.py +++ b/api/utils/web_utils.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import re import socket from urllib.parse import urlparse diff --git a/deepdoc/__init__.py b/deepdoc/__init__.py index 6bfdd33d0ba371e4b0a573d397af42eee2d8f3b6..643f79713c834d938c21dba9e1d0b63bba6676ed 100644 --- a/deepdoc/__init__.py +++ b/deepdoc/__init__.py @@ -1,2 +1,18 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from beartype.claw import beartype_this_package beartype_this_package() diff --git a/deepdoc/parser/__init__.py b/deepdoc/parser/__init__.py index 2a62a989468b987a227ead60383964af3bb24d7c..1597ed0816927efa91f2e26ad084956d920ae6b6 100644 --- a/deepdoc/parser/__init__.py +++ b/deepdoc/parser/__init__.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/docx_parser.py b/deepdoc/parser/docx_parser.py index 1910f4380c443a535914d8b8bc5e2a056f6991c6..dfe3f37fd16543f45b1bdc514acdcb7c20921f71 100644 --- a/deepdoc/parser/docx_parser.py +++ b/deepdoc/parser/docx_parser.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/excel_parser.py b/deepdoc/parser/excel_parser.py index 77cc7a058a36f56aa7d5839033d4f851ac8975f7..bb9d65b00fc91afd2de8021a44610dbc83cfa8aa 100644 --- a/deepdoc/parser/excel_parser.py +++ b/deepdoc/parser/excel_parser.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/html_parser.py b/deepdoc/parser/html_parser.py index 973dbbd4644ddb22c873ebd8405da4c9b7eb2637..29cc43a1d4400e35258bf24d5a7f40b0ae4aa06f 100644 --- a/deepdoc/parser/html_parser.py +++ b/deepdoc/parser/html_parser.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + from rag.nlp import find_codec import readability import html_text diff --git a/deepdoc/parser/json_parser.py b/deepdoc/parser/json_parser.py index fa30debdfe1564cfe1943b896784533697604a91..dc73246ef7ecc8886344d2861d2eb8a7ce2694dc 100644 --- a/deepdoc/parser/json_parser.py +++ b/deepdoc/parser/json_parser.py @@ -1,4 +1,20 @@ # -*- coding: utf-8 -*- +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + # The following documents are mainly referenced, and only adaptation modifications have been made # from https://github.com/langchain-ai/langchain/blob/master/libs/text-splitters/langchain_text_splitters/json.py diff --git a/deepdoc/parser/markdown_parser.py b/deepdoc/parser/markdown_parser.py index 60e6ba49834e8aef66774082f37d04d99ec0b593..d5d13837706c2cc9486f221103f7bd4d54f6dcc5 100644 --- a/deepdoc/parser/markdown_parser.py +++ b/deepdoc/parser/markdown_parser.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import re class RAGFlowMarkdownParser: diff --git a/deepdoc/parser/pdf_parser.py b/deepdoc/parser/pdf_parser.py index 5ff216edfa733d64828f7a766b51e21a4f537445..114339fa58c92c8c38db5968ad8c5d79eca5b71f 100644 --- a/deepdoc/parser/pdf_parser.py +++ b/deepdoc/parser/pdf_parser.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/ppt_parser.py b/deepdoc/parser/ppt_parser.py index eca952badc916b7340b12464157e094e9ad04bcc..4e459d19333e01403ac42fd7583f05a87e7e63fd 100644 --- a/deepdoc/parser/ppt_parser.py +++ b/deepdoc/parser/ppt_parser.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging from io import BytesIO from pptx import Presentation diff --git a/deepdoc/parser/resume/__init__.py b/deepdoc/parser/resume/__init__.py index 1038bf2b7b128a89cff113f3b75fea4b35a8d89f..5006d7fbcc5a94c74bd76a6cf2089c80d611839b 100644 --- a/deepdoc/parser/resume/__init__.py +++ b/deepdoc/parser/resume/__init__.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/resume/entities/__init__.py b/deepdoc/parser/resume/entities/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e156bc93dde7ef3682606e03c75247f8ce6905c2 100644 --- a/deepdoc/parser/resume/entities/__init__.py +++ b/deepdoc/parser/resume/entities/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# \ No newline at end of file diff --git a/deepdoc/parser/resume/entities/corporations.py b/deepdoc/parser/resume/entities/corporations.py index faeae4061f02acba5281c2d5ef96b2285618ed68..a52bfa14a58939a590fec16d58bb51c0a9284ea4 100644 --- a/deepdoc/parser/resume/entities/corporations.py +++ b/deepdoc/parser/resume/entities/corporations.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/resume/entities/degrees.py b/deepdoc/parser/resume/entities/degrees.py index 47a90b58211a7ad1aea20ac0f4cf6c58145b8c22..ddb936e0b8ff35ecb091f73fbcf07623a2db72bc 100644 --- a/deepdoc/parser/resume/entities/degrees.py +++ b/deepdoc/parser/resume/entities/degrees.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/resume/entities/industries.py b/deepdoc/parser/resume/entities/industries.py index 4768ceb50e8995b6c2e69bf011a57663ac41445b..c2b1b8e8261cd7f8631049e940660bcf08cf1265 100644 --- a/deepdoc/parser/resume/entities/industries.py +++ b/deepdoc/parser/resume/entities/industries.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/resume/entities/regions.py b/deepdoc/parser/resume/entities/regions.py index 4c3f0d722fc1277aca1fcd6fe5842019a6a5dbf2..ac37f6ea1d8b3621048fa13ab41f5aaab0ee4b20 100644 --- a/deepdoc/parser/resume/entities/regions.py +++ b/deepdoc/parser/resume/entities/regions.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import re TBL = { diff --git a/deepdoc/parser/resume/entities/schools.py b/deepdoc/parser/resume/entities/schools.py index c6b0bf7fdbccc49aaa694c6134be20afe20e0c5e..2bc40e83638c1561c5f26d69658c2c5a53fef36e 100644 --- a/deepdoc/parser/resume/entities/schools.py +++ b/deepdoc/parser/resume/entities/schools.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/resume/step_one.py b/deepdoc/parser/resume/step_one.py index 96cc668d3169a6c1ed78c41e0ab0509619cdd8c8..4c65a97fe856f15a673d78332fc7b856db2b0639 100644 --- a/deepdoc/parser/resume/step_one.py +++ b/deepdoc/parser/resume/step_one.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/parser/resume/step_two.py b/deepdoc/parser/resume/step_two.py index 9e4376735c3b1ea8bd2d9f2cad12cee01ef53366..6097a0132dc33cb1d504cd95509bdb1b77e7f51b 100644 --- a/deepdoc/parser/resume/step_two.py +++ b/deepdoc/parser/resume/step_two.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging import re import copy diff --git a/deepdoc/parser/txt_parser.py b/deepdoc/parser/txt_parser.py index 93b52eea32d4434f5e8fb949af4f88a1b7fed636..7f21799237d9cc73d410393d7608589845d133e7 100644 --- a/deepdoc/parser/txt_parser.py +++ b/deepdoc/parser/txt_parser.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import re from deepdoc.parser.utils import get_text diff --git a/deepdoc/parser/utils.py b/deepdoc/parser/utils.py index 58be06c915e922574e160ba4c9019427180d8255..85a3554955b6df477d65b5811dd8237faf761e44 100644 --- a/deepdoc/parser/utils.py +++ b/deepdoc/parser/utils.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/__init__.py b/deepdoc/vision/__init__.py index 1410efc258108411e17b73d34aff08c6fd4d2f9e..c2c964326ee99415c512974236d38a129fd3f85f 100644 --- a/deepdoc/vision/__init__.py +++ b/deepdoc/vision/__init__.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/layout_recognizer.py b/deepdoc/vision/layout_recognizer.py index 1cf3aa1a2c8a7287c7fe5986a2078f0f94fdf654..467a22ee9cfc40823e0303a3e205a63746552ba7 100644 --- a/deepdoc/vision/layout_recognizer.py +++ b/deepdoc/vision/layout_recognizer.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import os import re from collections import Counter diff --git a/deepdoc/vision/ocr.py b/deepdoc/vision/ocr.py index b6f8157412087262e2129825b1c0eadf3fe97c7d..9d9d44cde808d4b86c83aac322c8d1753559936c 100644 --- a/deepdoc/vision/ocr.py +++ b/deepdoc/vision/ocr.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/postprocess.py b/deepdoc/vision/postprocess.py index 6fb111de3bb843231aefae7edaa0bbeae9b44364..2da1477b3e314cf8a439e10406ab0fc262266a85 100644 --- a/deepdoc/vision/postprocess.py +++ b/deepdoc/vision/postprocess.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/recognizer.py b/deepdoc/vision/recognizer.py index 0695005c766989e69f5ef0f20aa195d301578286..aeef52d578301d419c7d42da7ac37b8fc513891f 100644 --- a/deepdoc/vision/recognizer.py +++ b/deepdoc/vision/recognizer.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/seeit.py b/deepdoc/vision/seeit.py index 6064bc4843e023d71b8266e2b137b78b1c1b7f15..e820e89a51d148a0cc7da96dda8bc1b90e42c62c 100644 --- a/deepdoc/vision/seeit.py +++ b/deepdoc/vision/seeit.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/t_ocr.py b/deepdoc/vision/t_ocr.py index 041c77107540b0b7b44238a01609ed58d56befab..2165449de281412c399e7a603ca429b437519483 100644 --- a/deepdoc/vision/t_ocr.py +++ b/deepdoc/vision/t_ocr.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/deepdoc/vision/t_recognizer.py b/deepdoc/vision/t_recognizer.py index e81a57b843be359f755accdcbf2afeed61c1a857..1db3356a9d6ef423f962a1b222908a6fd017bdbf 100644 --- a/deepdoc/vision/t_recognizer.py +++ b/deepdoc/vision/t_recognizer.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging import os import sys diff --git a/deepdoc/vision/table_structure_recognizer.py b/deepdoc/vision/table_structure_recognizer.py index be48ca95e4c0392e951df8ecfcd2f60f411e5178..e31fd901e3615e1fbc748a88e99334d48a39dc6c 100644 --- a/deepdoc/vision/table_structure_recognizer.py +++ b/deepdoc/vision/table_structure_recognizer.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/intergrations/chatgpt-on-wechat/plugins/__init__.py b/intergrations/chatgpt-on-wechat/plugins/__init__.py index 28032b8b8e8b953cab712873b67525fdfd28064c..557f0d1f1ba828081807920189ff93d0c981515b 100644 --- a/intergrations/chatgpt-on-wechat/plugins/__init__.py +++ b/intergrations/chatgpt-on-wechat/plugins/__init__.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from beartype.claw import beartype_this_package beartype_this_package() diff --git a/intergrations/chatgpt-on-wechat/plugins/ragflow_chat.py b/intergrations/chatgpt-on-wechat/plugins/ragflow_chat.py index 5d5615eaa17536a35f687efb06e4f946d7eedbcc..fe96f39a74747e01114ab4494a3e11835074912c 100644 --- a/intergrations/chatgpt-on-wechat/plugins/ragflow_chat.py +++ b/intergrations/chatgpt-on-wechat/plugins/ragflow_chat.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import requests from bridge.context import ContextType # Import Context, ContextType diff --git a/rag/__init__.py b/rag/__init__.py index 6bfdd33d0ba371e4b0a573d397af42eee2d8f3b6..643f79713c834d938c21dba9e1d0b63bba6676ed 100644 --- a/rag/__init__.py +++ b/rag/__init__.py @@ -1,2 +1,18 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from beartype.claw import beartype_this_package beartype_this_package() diff --git a/rag/app/__init__.py b/rag/app/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e156bc93dde7ef3682606e03c75247f8ce6905c2 100644 --- a/rag/app/__init__.py +++ b/rag/app/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# \ No newline at end of file diff --git a/rag/app/audio.py b/rag/app/audio.py index ec7ffeea3e4c397108258cbef231c4502aad33fe..95e552ae9f5e470799142b3ac9480962f16acfc1 100644 --- a/rag/app/audio.py +++ b/rag/app/audio.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import re from api.db import LLMType diff --git a/rag/app/book.py b/rag/app/book.py index 763364778bc099b5f557d4a0acedb072acbdaa51..fad526adcf220ffed054a8fbf647947680194a8c 100644 --- a/rag/app/book.py +++ b/rag/app/book.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging from tika import parser import re diff --git a/rag/app/email.py b/rag/app/email.py index b14ee6d43e04561208dcc78e558dc428e9defd5c..d1c98d5558c19d7fcd21f19b0f2c5830176edd10 100644 --- a/rag/app/email.py +++ b/rag/app/email.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/rag/app/knowledge_graph.py b/rag/app/knowledge_graph.py index f4330f482860fb266a89b495c2746b3ef0b16845..030c9aaf24ab95f25e5d3afe56d604bc5524c79f 100644 --- a/rag/app/knowledge_graph.py +++ b/rag/app/knowledge_graph.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import re from graphrag.index import build_knowledge_graph_chunks diff --git a/rag/app/laws.py b/rag/app/laws.py index 7a32c827319329a14f600a2c392c73c3f9bac424..6ed1ccc7782e1f5c8323572dc51d1f7ea6eebcca 100644 --- a/rag/app/laws.py +++ b/rag/app/laws.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging from tika import parser import re diff --git a/rag/app/manual.py b/rag/app/manual.py index 9018cb2a5879386fa1d6eb98e5903ad4b1fc8fd0..96693697078754e579f511951d4691017ddfbf7d 100644 --- a/rag/app/manual.py +++ b/rag/app/manual.py @@ -1,5 +1,5 @@ # -# Copyright 2024 The InfiniFlow Authors. All Rights Reserved. +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/rag/app/naive.py b/rag/app/naive.py index fac626ab00f8c848696bc67fe09bd31f232973e8..7dbde2bb4a786d834fb72a7cfba44a19e2692c52 100644 --- a/rag/app/naive.py +++ b/rag/app/naive.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging from tika import parser from io import BytesIO diff --git a/rag/app/one.py b/rag/app/one.py index bd691f46c3e66f5a4d352fae23c999e91208907d..616a87dbc19ff9160b37dca1facb7f559aba52e3 100644 --- a/rag/app/one.py +++ b/rag/app/one.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging from tika import parser from io import BytesIO diff --git a/rag/app/paper.py b/rag/app/paper.py index 89af09b90855bae80e85e5322e33bbbba98a9ec6..529d3a02de4689f7991bc0e5cd53fd65b192bf94 100644 --- a/rag/app/paper.py +++ b/rag/app/paper.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging import copy import re diff --git a/rag/app/picture.py b/rag/app/picture.py index fb9b1e2695296c6642a7f5d1fd85fecdff203dc4..578da79ffeea39c492721fd2b649d53c819ca96d 100644 --- a/rag/app/picture.py +++ b/rag/app/picture.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import io import numpy as np diff --git a/rag/app/presentation.py b/rag/app/presentation.py index a3305bdc116836ad9e7b76149929968a0fc0b8dd..09a8c3f461c432055fa1eb05e9f805f1c3a3cd39 100644 --- a/rag/app/presentation.py +++ b/rag/app/presentation.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import copy import re from io import BytesIO diff --git a/rag/app/qa.py b/rag/app/qa.py index 00cde2d64bf2871a0c35497c4e8372c970e1c684..a0c77c238330ae58e30b3e2f8da9d9724f4c0fce 100644 --- a/rag/app/qa.py +++ b/rag/app/qa.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging import re import csv diff --git a/rag/app/resume.py b/rag/app/resume.py index da620cb38beca8a68734ef80bdbe7ba38cf85892..7c556e06ed939b8bf38efe9ea9dec5a156d1457b 100644 --- a/rag/app/resume.py +++ b/rag/app/resume.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import logging import base64 import datetime diff --git a/rag/app/table.py b/rag/app/table.py index 88fceef787d0820a856f628fced88589eb062f50..542edec7a68e8a14596f8bb64bc8d111739f66ff 100644 --- a/rag/app/table.py +++ b/rag/app/table.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import copy import re from io import BytesIO diff --git a/rag/app/tag.py b/rag/app/tag.py index c1a15fafa3c1865423f748657ee9868bbc795269..f5c29f2a8181479db2b28a4a47917bd0497a94af 100644 --- a/rag/app/tag.py +++ b/rag/app/tag.py @@ -1,3 +1,6 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + import re import csv from copy import deepcopy diff --git a/rag/svr/jina_server.py b/rag/svr/jina_server.py index 9dba8b55eb9fe0153d7a498788ae4356a64d0868..60bd0c8d8c7291f31bf756d5c71a409ee6eeff10 100644 --- a/rag/svr/jina_server.py +++ b/rag/svr/jina_server.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from jina import Deployment from docarray import BaseDoc from jina import Executor, requests diff --git a/rag/utils/azure_sas_conn.py b/rag/utils/azure_sas_conn.py index 8c1be4cd05786614a2c95a056734d1d70278687f..48f9d0a64ee3eccc6a507e4bfacfc1a909931622 100644 --- a/rag/utils/azure_sas_conn.py +++ b/rag/utils/azure_sas_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import os import time diff --git a/rag/utils/azure_spn_conn.py b/rag/utils/azure_spn_conn.py index c45ceb79527d333540d559df157f712be4c26d44..625ccc4b541d902b0492ecdbe8854265383a54b1 100644 --- a/rag/utils/azure_spn_conn.py +++ b/rag/utils/azure_spn_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import os import time diff --git a/rag/utils/doc_store_conn.py b/rag/utils/doc_store_conn.py index b8a208841093b9b457267bf08f20254b96714e30..c3fa61b0cda26c7d2ebf55c41867081369c703ba 100644 --- a/rag/utils/doc_store_conn.py +++ b/rag/utils/doc_store_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from abc import ABC, abstractmethod from dataclasses import dataclass import numpy as np diff --git a/rag/utils/es_conn.py b/rag/utils/es_conn.py index 1f9590045521743066d07ec40d33e91601eed034..c2b5fc22b8066bd86a5d0bf4d1b0d75a7abd9ec5 100644 --- a/rag/utils/es_conn.py +++ b/rag/utils/es_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import re import json diff --git a/rag/utils/infinity_conn.py b/rag/utils/infinity_conn.py index dd11b9ece279175f9b0f274ca320344689ca6a4f..57cbc34b2de0907d8b1f9d1ab00d7b0a91794e41 100644 --- a/rag/utils/infinity_conn.py +++ b/rag/utils/infinity_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import os import re diff --git a/rag/utils/minio_conn.py b/rag/utils/minio_conn.py index 4662c7c83409e203ecb6632dfd5d30c0f9559f2e..48f02b6999777e60f6faee6029e6c1a313271e7f 100644 --- a/rag/utils/minio_conn.py +++ b/rag/utils/minio_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import time from minio import Minio diff --git a/rag/utils/redis_conn.py b/rag/utils/redis_conn.py index 660e518734bb316b868153b4040750659c732f66..40779aa27a582434f17421c59f4d9859629b52e5 100644 --- a/rag/utils/redis_conn.py +++ b/rag/utils/redis_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import json diff --git a/rag/utils/s3_conn.py b/rag/utils/s3_conn.py index 03690d8ad06224066aa2b6996598c3e0185a7f3c..d1e7e72697eb71e01a3dd61151f579a8bb7d8ccb 100644 --- a/rag/utils/s3_conn.py +++ b/rag/utils/s3_conn.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import logging import boto3 from botocore.exceptions import ClientError diff --git a/rag/utils/storage_factory.py b/rag/utils/storage_factory.py index 7c7a4a71de2cb5c6c27224db284a82c267778574..a27fda91a0998b3be754e2fd0c61ec537fd0c67f 100644 --- a/rag/utils/storage_factory.py +++ b/rag/utils/storage_factory.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import os from enum import Enum diff --git a/sdk/python/hello_ragflow.py b/sdk/python/hello_ragflow.py index d258943b304bd5598491521b64ad1455390b819a..5b73cb81ba9b9917d32037a59092762bea6957d7 100644 --- a/sdk/python/hello_ragflow.py +++ b/sdk/python/hello_ragflow.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import ragflow_sdk -print(ragflow_sdk.__version__) \ No newline at end of file +print(ragflow_sdk.__version__) diff --git a/sdk/python/ragflow_sdk/__init__.py b/sdk/python/ragflow_sdk/__init__.py index b7cf31e123558bf1c4c65d724d3c5bd61bfcda72..7535aa4eda12e6ee31e4ee0ecc20f4c64cb1748a 100644 --- a/sdk/python/ragflow_sdk/__init__.py +++ b/sdk/python/ragflow_sdk/__init__.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from beartype.claw import beartype_this_package beartype_this_package() diff --git a/sdk/python/ragflow_sdk/modules/__init__.py b/sdk/python/ragflow_sdk/modules/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e156bc93dde7ef3682606e03c75247f8ce6905c2 100644 --- a/sdk/python/ragflow_sdk/modules/__init__.py +++ b/sdk/python/ragflow_sdk/modules/__init__.py @@ -0,0 +1,15 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# \ No newline at end of file diff --git a/sdk/python/ragflow_sdk/modules/agent.py b/sdk/python/ragflow_sdk/modules/agent.py index 9ca3141281b11fc2e65421d02211747af6769600..5579af98dca273363357796f451fc88b423f061d 100644 --- a/sdk/python/ragflow_sdk/modules/agent.py +++ b/sdk/python/ragflow_sdk/modules/agent.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from .base import Base from .session import Session import requests diff --git a/sdk/python/ragflow_sdk/modules/base.py b/sdk/python/ragflow_sdk/modules/base.py index 49aa18db37f7283119720a944a8c1b251a4e1aec..5a6264f7903f21dbe89cddddc5d57a523a01e52d 100644 --- a/sdk/python/ragflow_sdk/modules/base.py +++ b/sdk/python/ragflow_sdk/modules/base.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class Base(object): def __init__(self, rag, res_dict): self.rag = rag diff --git a/sdk/python/ragflow_sdk/modules/chat.py b/sdk/python/ragflow_sdk/modules/chat.py index 013bddd7ef2ac1ff5d35f88bd8ec3ed1b59ac2eb..e85011504d3c546bd9a832245b715d2497a7cb52 100644 --- a/sdk/python/ragflow_sdk/modules/chat.py +++ b/sdk/python/ragflow_sdk/modules/chat.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from .base import Base from .session import Session @@ -44,12 +60,11 @@ class Chat(Base): def update(self, update_message: dict): res = self.put(f'/chats/{self.id}', - update_message) + update_message) res = res.json() if res.get("code") != 0: raise Exception(res["message"]) - def create_session(self, name: str = "New session") -> Session: res = self.post(f"/chats/{self.id}/sessions", {"name": name}) res = res.json() @@ -57,9 +72,10 @@ class Chat(Base): return Session(self.rag, res['data']) raise Exception(res["message"]) - def list_sessions(self,page: int = 1, page_size: int = 30, orderby: str = "create_time", desc: bool = True, + def list_sessions(self, page: int = 1, page_size: int = 30, orderby: str = "create_time", desc: bool = True, id: str = None, name: str = None) -> list[Session]: - res = self.get(f'/chats/{self.id}/sessions',{"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name} ) + res = self.get(f'/chats/{self.id}/sessions', + {"page": page, "page_size": page_size, "orderby": orderby, "desc": desc, "id": id, "name": name}) res = res.json() if res.get("code") == 0: result_list = [] @@ -68,7 +84,7 @@ class Chat(Base): return result_list raise Exception(res["message"]) - def delete_sessions(self,ids: list[str] | None = None): + def delete_sessions(self, ids: list[str] | None = None): res = self.rm(f"/chats/{self.id}/sessions", {"ids": ids}) res = res.json() if res.get("code") != 0: diff --git a/sdk/python/ragflow_sdk/modules/chunk.py b/sdk/python/ragflow_sdk/modules/chunk.py index 960c87df6fba35113808d1765b586b500888825e..4471b58afd2c796cc8d033482a195dcb2fd4fe4e 100644 --- a/sdk/python/ragflow_sdk/modules/chunk.py +++ b/sdk/python/ragflow_sdk/modules/chunk.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from .base import Base @@ -18,11 +34,8 @@ class Chunk(Base): res_dict.pop(k) super().__init__(rag, res_dict) - - def update(self,update_message:dict): - res = self.put(f"/datasets/{self.dataset_id}/documents/{self.document_id}/chunks/{self.id}",update_message) + def update(self, update_message: dict): + res = self.put(f"/datasets/{self.dataset_id}/documents/{self.document_id}/chunks/{self.id}", update_message) res = res.json() - if res.get("code") != 0 : + if res.get("code") != 0: raise Exception(res["message"]) - - diff --git a/sdk/python/ragflow_sdk/modules/dataset.py b/sdk/python/ragflow_sdk/modules/dataset.py index 043a600ef069d01124ca6bf8d8070a23df32a3d4..57d76d3aefa3b917b1b1ab5334d5cb01b2e0e8e3 100644 --- a/sdk/python/ragflow_sdk/modules/dataset.py +++ b/sdk/python/ragflow_sdk/modules/dataset.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from .document import Document from .base import Base @@ -29,48 +45,51 @@ class DataSet(Base): def update(self, update_message: dict): res = self.put(f'/datasets/{self.id}', - update_message) + update_message) res = res.json() if res.get("code") != 0: raise Exception(res["message"]) - def upload_documents(self,document_list: list[dict]): + def upload_documents(self, document_list: list[dict]): url = f"/datasets/{self.id}/documents" - files = [("file",(ele["display_name"],ele["blob"])) for ele in document_list] - res = self.post(path=url,json=None,files=files) + files = [("file", (ele["display_name"], ele["blob"])) for ele in document_list] + res = self.post(path=url, json=None, files=files) res = res.json() if res.get("code") == 0: - doc_list=[] + doc_list = [] for doc in res["data"]: - document = Document(self.rag,doc) + document = Document(self.rag, doc) doc_list.append(document) return doc_list raise Exception(res.get("message")) - def list_documents(self, id: str | None = None, keywords: str | None = None, page: int = 1, page_size: int = 30, orderby: str = "create_time", desc: bool = True): - res = self.get(f"/datasets/{self.id}/documents",params={"id": id,"keywords": keywords,"page": page,"page_size": page_size,"orderby": orderby,"desc": desc}) + def list_documents(self, id: str | None = None, keywords: str | None = None, page: int = 1, page_size: int = 30, + orderby: str = "create_time", desc: bool = True): + res = self.get(f"/datasets/{self.id}/documents", + params={"id": id, "keywords": keywords, "page": page, "page_size": page_size, "orderby": orderby, + "desc": desc}) res = res.json() documents = [] if res.get("code") == 0: for document in res["data"].get("docs"): - documents.append(Document(self.rag,document)) + documents.append(Document(self.rag, document)) return documents raise Exception(res["message"]) - def delete_documents(self,ids: list[str] | None = None): - res = self.rm(f"/datasets/{self.id}/documents",{"ids":ids}) + def delete_documents(self, ids: list[str] | None = None): + res = self.rm(f"/datasets/{self.id}/documents", {"ids": ids}) res = res.json() if res.get("code") != 0: raise Exception(res["message"]) - def async_parse_documents(self,document_ids): - res = self.post(f"/datasets/{self.id}/chunks",{"document_ids":document_ids}) + def async_parse_documents(self, document_ids): + res = self.post(f"/datasets/{self.id}/chunks", {"document_ids": document_ids}) res = res.json() if res.get("code") != 0: raise Exception(res.get("message")) - def async_cancel_parse_documents(self,document_ids): - res = self.rm(f"/datasets/{self.id}/chunks",{"document_ids":document_ids}) + def async_cancel_parse_documents(self, document_ids): + res = self.rm(f"/datasets/{self.id}/chunks", {"document_ids": document_ids}) res = res.json() if res.get("code") != 0: raise Exception(res.get("message")) diff --git a/sdk/python/ragflow_sdk/modules/document.py b/sdk/python/ragflow_sdk/modules/document.py index 743016b23556d65530b1321f4d9cb7337e8d964c..bb3211d2420b7127cbd8a09889e562747cf498eb 100644 --- a/sdk/python/ragflow_sdk/modules/document.py +++ b/sdk/python/ragflow_sdk/modules/document.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import json from .base import Base from .chunk import Chunk @@ -32,7 +48,6 @@ class Document(Base): res_dict.pop(k) super().__init__(rag, res_dict) - def update(self, update_message: dict): res = self.put(f'/datasets/{self.dataset_id}/documents/{self.id}', update_message) @@ -48,29 +63,28 @@ class Document(Base): except json.JSONDecodeError: return res.content - - def list_chunks(self,page=1, page_size=30, keywords=""): - data={"keywords": keywords,"page":page,"page_size":page_size} + def list_chunks(self, page=1, page_size=30, keywords=""): + data = {"keywords": keywords, "page": page, "page_size": page_size} res = self.get(f'/datasets/{self.dataset_id}/documents/{self.id}/chunks', data) res = res.json() if res.get("code") == 0: - chunks=[] + chunks = [] for data in res["data"].get("chunks"): - chunk = Chunk(self.rag,data) + chunk = Chunk(self.rag, data) chunks.append(chunk) return chunks raise Exception(res.get("message")) def add_chunk(self, content: str, important_keywords: list[str] = [], questions: list[str] = []): res = self.post(f'/datasets/{self.dataset_id}/documents/{self.id}/chunks', - {"content":content,"important_keywords":important_keywords, "questions": questions}) + {"content": content, "important_keywords": important_keywords, "questions": questions}) res = res.json() if res.get("code") == 0: - return Chunk(self.rag,res["data"].get("chunk")) + return Chunk(self.rag, res["data"].get("chunk")) raise Exception(res.get("message")) - def delete_chunks(self,ids:list[str] | None = None): - res = self.rm(f"/datasets/{self.dataset_id}/documents/{self.id}/chunks",{"chunk_ids":ids}) + def delete_chunks(self, ids: list[str] | None = None): + res = self.rm(f"/datasets/{self.dataset_id}/documents/{self.id}/chunks", {"chunk_ids": ids}) res = res.json() - if res.get("code")!=0: - raise Exception(res.get("message")) \ No newline at end of file + if res.get("code") != 0: + raise Exception(res.get("message")) diff --git a/sdk/python/ragflow_sdk/modules/session.py b/sdk/python/ragflow_sdk/modules/session.py index dcfc3392be3d1254d36dec490120c730da017d21..9a1a7fd3dbcfa0f87a3c6d321bd6b2870021a262 100644 --- a/sdk/python/ragflow_sdk/modules/session.py +++ b/sdk/python/ragflow_sdk/modules/session.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import json from .base import Base @@ -8,8 +24,8 @@ class Session(Base): self.id = None self.name = "New session" self.messages = [{"role": "assistant", "content": "Hi! I am your assistant,can I help you?"}] - for key,value in res_dict.items(): - if key =="chat_id" and value is not None: + for key, value in res_dict.items(): + if key == "chat_id" and value is not None: self.chat_id = None self.__session_type = "chat" if key == "agent_id" and value is not None: @@ -17,11 +33,11 @@ class Session(Base): self.__session_type = "agent" super().__init__(rag, res_dict) - def ask(self, question="",stream=True,**kwargs): + def ask(self, question="", stream=True, **kwargs): if self.__session_type == "agent": - res=self._ask_agent(question,stream) + res = self._ask_agent(question, stream) elif self.__session_type == "chat": - res=self._ask_chat(question,stream,**kwargs) + res = self._ask_chat(question, stream, **kwargs) for line in res.iter_lines(): line = line.decode("utf-8") if line.startswith("{"): @@ -44,25 +60,26 @@ class Session(Base): message = Message(self.rag, temp_dict) yield message - def _ask_chat(self, question: str, stream: bool,**kwargs): - json_data={"question": question, "stream": True,"session_id":self.id} + def _ask_chat(self, question: str, stream: bool, **kwargs): + json_data = {"question": question, "stream": True, "session_id": self.id} json_data.update(kwargs) res = self.post(f"/chats/{self.chat_id}/completions", json_data, stream=stream) return res - def _ask_agent(self,question:str,stream:bool): + def _ask_agent(self, question: str, stream: bool): res = self.post(f"/agents/{self.agent_id}/completions", - {"question": question, "stream": True,"session_id":self.id}, stream=stream) + {"question": question, "stream": True, "session_id": self.id}, stream=stream) return res - def update(self,update_message): + def update(self, update_message): res = self.put(f"/chats/{self.chat_id}/sessions/{self.id}", - update_message) + update_message) res = res.json() if res.get("code") != 0: raise Exception(res.get("message")) + class Message(Base): def __init__(self, rag, res_dict): self.content = "Hi! I am your assistant,can I help you?" diff --git a/sdk/python/test/conftest.py b/sdk/python/test/conftest.py index 463d0a8813396f3431df0da4fb060d06e5d75266..423ee3d31985565feb5932bbe79522310a530351 100644 --- a/sdk/python/test/conftest.py +++ b/sdk/python/test/conftest.py @@ -1,41 +1,61 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import os import pytest import requests - HOST_ADDRESS = os.getenv('HOST_ADDRESS', 'http://127.0.0.1:9380') + # def generate_random_email(): # return 'user_' + ''.join(random.choices(string.ascii_lowercase + string.digits, k=8))+'@1.com' def generate_email(): return 'user_123@1.com' + EMAIL = generate_email() # password is "123" -PASSWORD='''ctAseGvejiaSWWZ88T/m4FQVOpQyUvP+x7sXtdv3feqZACiQleuewkUi35E16wSd5C5QcnkkcV9cYc8TKPTRZlxappDuirxghxoOvFcJxFU4ixLsD +PASSWORD = '''ctAseGvejiaSWWZ88T/m4FQVOpQyUvP+x7sXtdv3feqZACiQleuewkUi35E16wSd5C5QcnkkcV9cYc8TKPTRZlxappDuirxghxoOvFcJxFU4ixLsD fN33jCHRoDUW81IH9zjij/vaw8IbVyb6vuwg6MX6inOEBRRzVbRYxXOu1wkWY6SsI8X70oF9aeLFp/PzQpjoe/YbSqpTq8qqrmHzn9vO+yvyYyvmDsphXe X8f7fp9c7vUsfOCkM+gHY3PadG+QHa7KI7mzTKgUTZImK6BZtfRBATDTthEUbbaTewY4H0MnWiCeeDhcbeQao6cFy1To8pE3RpmxnGnS8BsBn8w==''' + def register(): url = HOST_ADDRESS + "/v1/user/register" name = "user" - register_data = {"email":EMAIL,"nickname":name,"password":PASSWORD} - res = requests.post(url=url,json=register_data) + register_data = {"email": EMAIL, "nickname": name, "password": PASSWORD} + res = requests.post(url=url, json=register_data) res = res.json() if res.get("code") != 0: raise Exception(res.get("message")) + def login(): url = HOST_ADDRESS + "/v1/user/login" - login_data = {"email":EMAIL,"password":PASSWORD} - response=requests.post(url=url,json=login_data) + login_data = {"email": EMAIL, "password": PASSWORD} + response = requests.post(url=url, json=login_data) res = response.json() - if res.get("code")!=0: + if res.get("code") != 0: raise Exception(res.get("message")) auth = response.headers["Authorization"] return auth + @pytest.fixture(scope="session") def get_api_key_fixture(): try: @@ -45,12 +65,13 @@ def get_api_key_fixture(): auth = login() url = HOST_ADDRESS + "/v1/system/new_token" auth = {"Authorization": auth} - response = requests.post(url=url,headers=auth) + response = requests.post(url=url, headers=auth) res = response.json() if res.get("code") != 0: raise Exception(res.get("message")) return res["data"].get("token") + @pytest.fixture(scope="session") def get_auth(): try: @@ -60,6 +81,7 @@ def get_auth(): auth = login() return auth + @pytest.fixture(scope="session") def get_email(): return EMAIL diff --git a/sdk/python/test/test_frontend_api/common.py b/sdk/python/test/test_frontend_api/common.py index 1a8c174c53da4f9bb9757f4876257416e610e816..19aa6df456e76e99f40bf07beac7f168aa05080a 100644 --- a/sdk/python/test/test_frontend_api/common.py +++ b/sdk/python/test/test_frontend_api/common.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import os import requests diff --git a/sdk/python/test/test_frontend_api/get_email.py b/sdk/python/test/test_frontend_api/get_email.py index 923b82d2d21ad75ebe0fd0556a47fd1e65180a67..181094f5add521bd1021e7a4e483855b2fb9119d 100644 --- a/sdk/python/test/test_frontend_api/get_email.py +++ b/sdk/python/test/test_frontend_api/get_email.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + def test_get_email(get_email): print("\nEmail account:",flush=True) print(f"{get_email}\n",flush=True) \ No newline at end of file diff --git a/sdk/python/test/test_frontend_api/test_dataset.py b/sdk/python/test/test_frontend_api/test_dataset.py index fe2de715a8c4f72c59bee6b7a65bef1c49360e6e..3baaf4e8ca19e9a56c1553ba022f473ddf1823a4 100644 --- a/sdk/python/test/test_frontend_api/test_dataset.py +++ b/sdk/python/test/test_frontend_api/test_dataset.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from common import create_dataset, list_dataset, rm_dataset, update_dataset, DATASET_NAME_LIMIT import re import random @@ -121,7 +137,8 @@ def test_update_different_params_dataset_success(get_auth): print(f"found {len(dataset_list)} datasets") dataset_id = dataset_list[0] - json_req = {"kb_id": dataset_id, "name": "test_update_dataset", "description": "test", "permission": "me", "parser_id": "presentation", + json_req = {"kb_id": dataset_id, "name": "test_update_dataset", "description": "test", "permission": "me", + "parser_id": "presentation", "language": "spanish"} res = update_dataset(get_auth, json_req) assert res.get("code") == 0, f"{res.get('message')}" @@ -164,4 +181,3 @@ def test_update_different_params_dataset_fail(get_auth): res = rm_dataset(get_auth, dataset_id) assert res.get("code") == 0, f"{res.get('message')}" print(f"{len(dataset_list)} datasets are deleted") - diff --git a/sdk/python/test/test_sdk_api/common.py b/sdk/python/test/test_sdk_api/common.py index a5bc8ad32bc6033ab0cf1132849b5ac4489de9fe..fe6aa88b7b109a0cb9e550a98749f14ad910b918 100644 --- a/sdk/python/test/test_sdk_api/common.py +++ b/sdk/python/test/test_sdk_api/common.py @@ -1,2 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import os -HOST_ADDRESS=os.getenv('HOST_ADDRESS', 'http://127.0.0.1:9380') \ No newline at end of file + +HOST_ADDRESS = os.getenv('HOST_ADDRESS', 'http://127.0.0.1:9380') diff --git a/sdk/python/test/test_sdk_api/get_email.py b/sdk/python/test/test_sdk_api/get_email.py index 923b82d2d21ad75ebe0fd0556a47fd1e65180a67..7238922b703cd5a77281f2901c0e1f7b495782d6 100644 --- a/sdk/python/test/test_sdk_api/get_email.py +++ b/sdk/python/test/test_sdk_api/get_email.py @@ -1,3 +1,19 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + def test_get_email(get_email): - print("\nEmail account:",flush=True) - print(f"{get_email}\n",flush=True) \ No newline at end of file + print("\nEmail account:", flush=True) + print(f"{get_email}\n", flush=True) diff --git a/sdk/python/test/test_sdk_api/t_agent.py b/sdk/python/test/test_sdk_api/t_agent.py index aa330e52bc979276e2555b8cbc9c847b5766c618..2fcd0e535e72e9c13e238a71ad46807a9a165c01 100644 --- a/sdk/python/test/test_sdk_api/t_agent.py +++ b/sdk/python/test/test_sdk_api/t_agent.py @@ -1,11 +1,28 @@ -from ragflow_sdk import RAGFlow,Agent +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from ragflow_sdk import RAGFlow, Agent from common import HOST_ADDRESS import pytest + @pytest.mark.skip(reason="") def test_list_agents_with_success(get_api_key_fixture): - API_KEY=get_api_key_fixture - rag = RAGFlow(API_KEY,HOST_ADDRESS) + API_KEY = get_api_key_fixture + rag = RAGFlow(API_KEY, HOST_ADDRESS) rag.list_agents() @@ -13,7 +30,7 @@ def test_list_agents_with_success(get_api_key_fixture): def test_converse_with_agent_with_success(get_api_key_fixture): API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm" agent_id = "ebfada2eb2bc11ef968a0242ac120006" - rag = RAGFlow(API_KEY,HOST_ADDRESS) + rag = RAGFlow(API_KEY, HOST_ADDRESS) lang = "Chinese" file = "How is the weather tomorrow?" - Agent.ask(agent_id=agent_id,rag=rag,lang=lang,file=file) + Agent.ask(agent_id=agent_id, rag=rag, lang=lang, file=file) diff --git a/sdk/python/test/test_sdk_api/t_chat.py b/sdk/python/test/test_sdk_api/t_chat.py index d1670ad8c0c1373aa28699c2cd19834c6d27dbe7..5b9ed4275a4166302d8cf9553642b78232015d90 100644 --- a/sdk/python/test/test_sdk_api/t_chat.py +++ b/sdk/python/test/test_sdk_api/t_chat.py @@ -1,6 +1,23 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from ragflow_sdk import RAGFlow from common import HOST_ADDRESS + def test_create_chat_with_name(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) @@ -8,10 +25,10 @@ def test_create_chat_with_name(get_api_key_fixture): display_name = "ragflow.txt" with open("test_data/ragflow.txt", "rb") as file: blob = file.read() - document = {"display_name":display_name,"blob":blob} + document = {"display_name": display_name, "blob": blob} documents = [] documents.append(document) - docs= kb.upload_documents(documents) + docs = kb.upload_documents(documents) for doc in docs: doc.add_chunk("This is a test to add chunk") rag.create_chat("test_create_chat", dataset_ids=[kb.id]) @@ -50,6 +67,7 @@ def test_delete_chats_with_success(get_api_key_fixture): chat = rag.create_chat("test_delete_chat", dataset_ids=[kb.id]) rag.delete_chats(ids=[chat.id]) + def test_list_chats_with_success(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) @@ -66,5 +84,3 @@ def test_list_chats_with_success(get_api_key_fixture): rag.create_chat("test_list_1", dataset_ids=[kb.id]) rag.create_chat("test_list_2", dataset_ids=[kb.id]) rag.list_chats() - - diff --git a/sdk/python/test/test_sdk_api/t_chunk.py b/sdk/python/test/test_sdk_api/t_chunk.py index a07e682e9cc3413a300df3c223a4115f8155fd13..df2bfcad3151c43ef891030f7d1afac007d6758f 100644 --- a/sdk/python/test/test_sdk_api/t_chunk.py +++ b/sdk/python/test/test_sdk_api/t_chunk.py @@ -1,13 +1,30 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from ragflow_sdk import RAGFlow from common import HOST_ADDRESS from time import sleep + def test_parse_document_with_txt(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_parse_document") name = 'ragflow_test.txt' - with open("test_data/ragflow_test.txt", "rb") as file : + with open("test_data/ragflow_test.txt", "rb") as file: blob = file.read() docs = ds.upload_documents([{"display_name": name, "blob": blob}]) doc = docs[0] @@ -21,14 +38,15 @@ def test_parse_document_with_txt(get_api_key_fixture): raise Exception("Run time ERROR: Document parsing did not complete in time.") ''' + def test_parse_and_cancel_document(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_parse_and_cancel_document") name = 'ragflow_test.txt' - with open("test_data/ragflow_test.txt", "rb") as file : + with open("test_data/ragflow_test.txt", "rb") as file: blob = file.read() - docs=ds.upload_documents([{"display_name": name, "blob": blob}]) + docs = ds.upload_documents([{"display_name": name, "blob": blob}]) doc = docs[0] ds.async_parse_documents(document_ids=[doc.id]) sleep(1) @@ -60,6 +78,7 @@ def test_bulk_parse_documents(get_api_key_fixture): raise Exception("Run time ERROR: Bulk document parsing did not complete in time.") ''' + def test_list_chunks_with_success(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) @@ -73,7 +92,7 @@ def test_list_chunks_with_success(get_api_key_fixture): {'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks) ] ''' - documents =[{"display_name":"test_list_chunks_with_success.txt","blob":blob}] + documents = [{"display_name": "test_list_chunks_with_success.txt", "blob": blob}] docs = ds.upload_documents(documents) ids = [doc.id for doc in docs] ds.async_parse_documents(ids) @@ -103,7 +122,7 @@ def test_add_chunk_with_success(get_api_key_fixture): {'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks) ] ''' - documents =[{"display_name":"test_list_chunks_with_success.txt","blob":blob}] + documents = [{"display_name": "test_list_chunks_with_success.txt", "blob": blob}] docs = ds.upload_documents(documents) doc = docs[0] doc.add_chunk(content="This is a chunk addition test") @@ -122,7 +141,7 @@ def test_delete_chunk_with_success(get_api_key_fixture): {'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks) ] ''' - documents =[{"display_name":"test_delete_chunk_with_success.txt","blob":blob}] + documents = [{"display_name": "test_delete_chunk_with_success.txt", "blob": blob}] docs = ds.upload_documents(documents) doc = docs[0] chunk = doc.add_chunk(content="This is a chunk addition test") @@ -143,13 +162,14 @@ def test_update_chunk_content(get_api_key_fixture): {'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks) ] ''' - documents =[{"display_name":"test_update_chunk_content_with_success.txt","blob":blob}] + documents = [{"display_name": "test_update_chunk_content_with_success.txt", "blob": blob}] docs = ds.upload_documents(documents) doc = docs[0] chunk = doc.add_chunk(content="This is a chunk addition test") # For Elasticsearch, the chunk is not searchable in shot time (~2s). sleep(3) - chunk.update({"content":"This is a updated content"}) + chunk.update({"content": "This is a updated content"}) + def test_update_chunk_available(get_api_key_fixture): API_KEY = get_api_key_fixture @@ -164,13 +184,13 @@ def test_update_chunk_available(get_api_key_fixture): {'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks) ] ''' - documents =[{"display_name":"test_update_chunk_available_with_success.txt","blob":blob}] + documents = [{"display_name": "test_update_chunk_available_with_success.txt", "blob": blob}] docs = ds.upload_documents(documents) doc = docs[0] chunk = doc.add_chunk(content="This is a chunk addition test") # For Elasticsearch, the chunk is not searchable in shot time (~2s). sleep(3) - chunk.update({"available":0}) + chunk.update({"available": 0}) def test_retrieve_chunks(get_api_key_fixture): @@ -186,11 +206,11 @@ def test_retrieve_chunks(get_api_key_fixture): {'display_name': f'chunk_{i}.txt', 'blob': chunk} for i, chunk in enumerate(chunks) ] ''' - documents =[{"display_name":"test_retrieve_chunks.txt","blob":blob}] + documents = [{"display_name": "test_retrieve_chunks.txt", "blob": blob}] docs = ds.upload_documents(documents) doc = docs[0] doc.add_chunk(content="This is a chunk addition test") - rag.retrieve(dataset_ids=[ds.id],document_ids=[doc.id]) + rag.retrieve(dataset_ids=[ds.id], document_ids=[doc.id]) rag.delete_datasets(ids=[ds.id]) # test different parameters for the retrieval diff --git a/sdk/python/test/test_sdk_api/t_dataset.py b/sdk/python/test/test_sdk_api/t_dataset.py index 288474409f8ec427b6deafc4b12e5530668f2e47..7163e445cadb3201d3ee73e6a36e49c1d61462d8 100644 --- a/sdk/python/test/test_sdk_api/t_dataset.py +++ b/sdk/python/test/test_sdk_api/t_dataset.py @@ -1,13 +1,31 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from ragflow_sdk import RAGFlow import random import pytest from common import HOST_ADDRESS + def test_create_dataset_with_name(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) rag.create_dataset("test_create_dataset_with_name") + def test_create_dataset_with_duplicated_name(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) @@ -16,12 +34,15 @@ def test_create_dataset_with_duplicated_name(get_api_key_fixture): rag.create_dataset("test_create_dataset_with_duplicated_name") assert str(exc_info.value) == "Duplicated dataset name in creating dataset." + def test_create_dataset_with_random_chunk_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) - valid_chunk_methods = ["naive","manual","qa","table","paper","book","laws","presentation","picture","one","knowledge_graph","email"] + valid_chunk_methods = ["naive", "manual", "qa", "table", "paper", "book", "laws", "presentation", "picture", "one", + "knowledge_graph", "email"] random_chunk_method = random.choice(valid_chunk_methods) - rag.create_dataset("test_create_dataset_with_random_chunk_method",chunk_method=random_chunk_method) + rag.create_dataset("test_create_dataset_with_random_chunk_method", chunk_method=random_chunk_method) + def test_create_dataset_with_invalid_parameter(get_api_key_fixture): API_KEY = get_api_key_fixture @@ -30,7 +51,7 @@ def test_create_dataset_with_invalid_parameter(get_api_key_fixture): "knowledge_graph", "email", "tag"] chunk_method = "invalid_chunk_method" with pytest.raises(Exception) as exc_info: - rag.create_dataset("test_create_dataset_with_invalid_chunk_method",chunk_method=chunk_method) + rag.create_dataset("test_create_dataset_with_invalid_chunk_method", chunk_method=chunk_method) assert str(exc_info.value) == f"'{chunk_method}' is not in {valid_chunk_methods}" diff --git a/sdk/python/test/test_sdk_api/t_document.py b/sdk/python/test/test_sdk_api/t_document.py index 056963aa0fde3b5df8508968481b5b3138e48916..733b9bb5a5b9ec02593fd34e4dbda76cb060bedd 100644 --- a/sdk/python/test/test_sdk_api/t_document.py +++ b/sdk/python/test/test_sdk_api/t_document.py @@ -1,17 +1,34 @@ +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + from ragflow_sdk import RAGFlow from common import HOST_ADDRESS import pytest + def test_upload_document_with_success(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_upload_document") blob = b"Sample document content for test." with open("test_data/ragflow.txt", "rb") as file: - blob_2=file.read() + blob_2 = file.read() document_infos = [] - document_infos.append({"display_name": "test_1.txt","blob": blob}) - document_infos.append({"display_name": "test_2.txt","blob": blob_2}) + document_infos.append({"display_name": "test_1.txt", "blob": blob}) + document_infos.append({"display_name": "test_2.txt", "blob": blob_2}) ds.upload_documents(document_infos) @@ -20,8 +37,8 @@ def test_update_document_with_success(get_api_key_fixture): rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_update_document") blob = b"Sample document content for test." - document_infos=[{"display_name":"test.txt","blob":blob}] - docs=ds.upload_documents(document_infos) + document_infos = [{"display_name": "test.txt", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] doc.update({"chunk_method": "manual", "name": "manual.txt"}) @@ -31,10 +48,10 @@ def test_download_document_with_success(get_api_key_fixture): rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_download_document") blob = b"Sample document content for test." - document_infos=[{"display_name": "test_1.txt","blob": blob}] - docs=ds.upload_documents(document_infos) + document_infos = [{"display_name": "test_1.txt", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] - with open("test_download.txt","wb+") as file: + with open("test_download.txt", "wb+") as file: file.write(doc.download()) @@ -43,7 +60,7 @@ def test_list_documents_in_dataset_with_success(get_api_key_fixture): rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_list_documents") blob = b"Sample document content for test." - document_infos = [{"display_name": "test.txt","blob":blob}] + document_infos = [{"display_name": "test.txt", "blob": blob}] ds.upload_documents(document_infos) ds.list_documents(keywords="test", page=1, page_size=12) @@ -54,113 +71,128 @@ def test_delete_documents_in_dataset_with_success(get_api_key_fixture): ds = rag.create_dataset(name="test_delete_documents") name = "test_delete_documents.txt" blob = b"Sample document content for test." - document_infos=[{"display_name": name, "blob": blob}] + document_infos = [{"display_name": name, "blob": blob}] docs = ds.upload_documents(document_infos) ds.delete_documents([docs[0].id]) + # upload and parse the document with different in different parse method. def test_upload_and_parse_pdf_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_pdf_document") with open("test_data/test.pdf", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.pdf","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.pdf", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + def test_upload_and_parse_docx_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_docx_document") with open("test_data/test.docx", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.docx","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.docx", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + + def test_upload_and_parse_excel_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_excel_document") with open("test_data/test.xlsx", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.xlsx","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.xlsx", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + + def test_upload_and_parse_ppt_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_ppt_document") with open("test_data/test.ppt", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.ppt","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.ppt", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + + def test_upload_and_parse_image_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_image_document") with open("test_data/test.jpg", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.jpg","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.jpg", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + + def test_upload_and_parse_txt_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_txt_document") with open("test_data/test.txt", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.txt","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.txt", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + + def test_upload_and_parse_md_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_md_document") with open("test_data/test.md", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.md","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.md", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + def test_upload_and_parse_json_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_json_document") with open("test_data/test.json", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.json","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.json", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + @pytest.mark.skip(reason="") def test_upload_and_parse_eml_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_eml_document") with open("test_data/test.eml", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.eml","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.eml", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] ds.async_parse_documents([doc.id]) + def test_upload_and_parse_html_documents_with_general_parse_method(get_api_key_fixture): API_KEY = get_api_key_fixture rag = RAGFlow(API_KEY, HOST_ADDRESS) ds = rag.create_dataset(name="test_html_document") with open("test_data/test.html", "rb") as file: - blob=file.read() - document_infos = [{"display_name": "test.html","blob": blob}] - docs=ds.upload_documents(document_infos) + blob = file.read() + document_infos = [{"display_name": "test.html", "blob": blob}] + docs = ds.upload_documents(document_infos) doc = docs[0] - ds.async_parse_documents([doc.id]) \ No newline at end of file + ds.async_parse_documents([doc.id]) diff --git a/sdk/python/test/test_sdk_api/t_session.py b/sdk/python/test/test_sdk_api/t_session.py index c4c064b84f4ce3032a4f5f3f75e0e0f518ef9c08..40932fdad08abcd00d08fbc7e580392720728b45 100644 --- a/sdk/python/test/test_sdk_api/t_session.py +++ b/sdk/python/test/test_sdk_api/t_session.py @@ -1,4 +1,20 @@ -from ragflow_sdk import RAGFlow,Agent +# +# Copyright 2025 The InfiniFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from ragflow_sdk import RAGFlow, Agent from common import HOST_ADDRESS import pytest @@ -10,13 +26,13 @@ def test_create_session_with_success(get_api_key_fixture): display_name = "ragflow.txt" with open("test_data/ragflow.txt", "rb") as file: blob = file.read() - document = {"display_name":display_name,"blob":blob} + document = {"display_name": display_name, "blob": blob} documents = [] documents.append(document) - docs= kb.upload_documents(documents) + docs = kb.upload_documents(documents) for doc in docs: doc.add_chunk("This is a test to add chunk") - assistant=rag.create_chat("test_create_session", dataset_ids=[kb.id]) + assistant = rag.create_chat("test_create_session", dataset_ids=[kb.id]) assistant.create_session() @@ -38,7 +54,7 @@ def test_create_conversation_with_success(get_api_key_fixture): question = "What is AI" for ans in session.ask(question): pass - + # assert not ans.content.startswith("**ERROR**"), "Please check this error." @@ -49,13 +65,13 @@ def test_delete_sessions_with_success(get_api_key_fixture): display_name = "ragflow.txt" with open("test_data/ragflow.txt", "rb") as file: blob = file.read() - document = {"display_name":display_name,"blob":blob} + document = {"display_name": display_name, "blob": blob} documents = [] documents.append(document) - docs= kb.upload_documents(documents) + docs = kb.upload_documents(documents) for doc in docs: doc.add_chunk("This is a test to add chunk") - assistant=rag.create_chat("test_delete_session", dataset_ids=[kb.id]) + assistant = rag.create_chat("test_delete_session", dataset_ids=[kb.id]) session = assistant.create_session() assistant.delete_sessions(ids=[session.id]) @@ -85,33 +101,36 @@ def test_list_sessions_with_success(get_api_key_fixture): display_name = "ragflow.txt" with open("test_data/ragflow.txt", "rb") as file: blob = file.read() - document = {"display_name":display_name,"blob":blob} + document = {"display_name": display_name, "blob": blob} documents = [] documents.append(document) - docs= kb.upload_documents(documents) + docs = kb.upload_documents(documents) for doc in docs: doc.add_chunk("This is a test to add chunk") - assistant=rag.create_chat("test_list_session", dataset_ids=[kb.id]) + assistant = rag.create_chat("test_list_session", dataset_ids=[kb.id]) assistant.create_session("test_1") assistant.create_session("test_2") assistant.list_sessions() + @pytest.mark.skip(reason="") def test_create_agent_session_with_success(get_api_key_fixture): API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm" - rag = RAGFlow(API_KEY,HOST_ADDRESS) + rag = RAGFlow(API_KEY, HOST_ADDRESS) Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag) + @pytest.mark.skip(reason="") def test_create_agent_conversation_with_success(get_api_key_fixture): API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm" - rag = RAGFlow(API_KEY,HOST_ADDRESS) + rag = RAGFlow(API_KEY, HOST_ADDRESS) session = Agent.create_session("2e45b5209c1011efa3e90242ac120006", rag) session.ask("What is this job") + @pytest.mark.skip(reason="") def test_list_agent_sessions_with_success(get_api_key_fixture): API_KEY = "ragflow-BkOGNhYjIyN2JiODExZWY5MzVhMDI0Mm" agent_id = "2710f2269b4611ef8fdf0242ac120006" - rag = RAGFlow(API_KEY,HOST_ADDRESS) - Agent.list_sessions(agent_id,rag) + rag = RAGFlow(API_KEY, HOST_ADDRESS) + Agent.list_sessions(agent_id, rag)