Introduced beartype (#3460)

### What problem does this PR solve?

Introduced [beartype](https://github.com/beartype/beartype) for runtime
type-checking.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Zhichang Yu
2024-11-18 17:38:17 +08:00
committed by GitHub
parent 3824c1fec0
commit 4413683898
32 changed files with 125 additions and 134 deletions

View File

@ -1,7 +1,6 @@
import json
from .base import Base
from .chunk import Chunk
from typing import List
class Document(Base):
@ -63,14 +62,14 @@ class Document(Base):
raise Exception(res.get("message"))
def add_chunk(self, content: str,important_keywords:List[str]=[]):
def add_chunk(self, content: str,important_keywords: list[str] = []):
res = self.post(f'/datasets/{self.dataset_id}/documents/{self.id}/chunks', {"content":content,"important_keywords":important_keywords})
res = res.json()
if res.get("code") == 0:
return Chunk(self.rag,res["data"].get("chunk"))
raise Exception(res.get("message"))
def delete_chunks(self,ids:List[str] = None):
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: