mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-02 16:27:48 +08:00
Fix/13142 auto metadata (#13217)
### What problem does this PR solve? Close #13142 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import Optional
|
||||
from typing import Optional, Any
|
||||
|
||||
import requests
|
||||
|
||||
@ -58,6 +58,7 @@ class RAGFlow:
|
||||
permission: str = "me",
|
||||
chunk_method: str = "naive",
|
||||
parser_config: Optional[DataSet.ParserConfig] = None,
|
||||
auto_metadata_config: Optional[dict[str, Any]] = None,
|
||||
) -> DataSet:
|
||||
payload = {
|
||||
"name": name,
|
||||
@ -69,6 +70,8 @@ class RAGFlow:
|
||||
}
|
||||
if parser_config is not None:
|
||||
payload["parser_config"] = parser_config.to_json()
|
||||
if auto_metadata_config is not None:
|
||||
payload["auto_metadata_config"] = auto_metadata_config
|
||||
|
||||
res = self.post("/datasets", payload)
|
||||
res = res.json()
|
||||
@ -108,6 +111,26 @@ class RAGFlow:
|
||||
return result_list
|
||||
raise Exception(res["message"])
|
||||
|
||||
def get_auto_metadata(self, dataset_id: str) -> dict[str, Any]:
|
||||
"""
|
||||
Retrieve auto-metadata configuration for a dataset via SDK.
|
||||
"""
|
||||
res = self.get(f"/datasets/{dataset_id}/auto_metadata")
|
||||
res = res.json()
|
||||
if res.get("code") == 0:
|
||||
return res["data"]
|
||||
raise Exception(res["message"])
|
||||
|
||||
def update_auto_metadata(self, dataset_id: str, **config: Any) -> dict[str, Any]:
|
||||
"""
|
||||
Update auto-metadata configuration for a dataset via SDK.
|
||||
"""
|
||||
res = self.put(f"/datasets/{dataset_id}/auto_metadata", config)
|
||||
res = res.json()
|
||||
if res.get("code") == 0:
|
||||
return res["data"]
|
||||
raise Exception(res["message"])
|
||||
|
||||
def create_chat(self, name: str, avatar: str = "", dataset_ids=None, llm: Chat.LLM | None = None, prompt: Chat.Prompt | None = None) -> Chat:
|
||||
if dataset_ids is None:
|
||||
dataset_ids = []
|
||||
|
||||
Reference in New Issue
Block a user