Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #
  2. # Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. class Base:
  17. def __init__(self, rag, res_dict):
  18. self.rag = rag
  19. for k, v in res_dict.items():
  20. if isinstance(v, dict):
  21. self.__dict__[k] = Base(rag, v)
  22. else:
  23. self.__dict__[k] = v
  24. def to_json(self):
  25. pr = {}
  26. for name in dir(self):
  27. value = getattr(self, name)
  28. if not name.startswith('__') and not callable(value) and name != "rag":
  29. if isinstance(value, Base):
  30. pr[name] = value.to_json()
  31. else:
  32. pr[name] = value
  33. return pr
  34. def post(self, path, json=None, stream=False, files=None):
  35. res = self.rag.post(path, json, stream=stream,files=files)
  36. return res
  37. def get(self, path, params=None):
  38. res = self.rag.get(path, params)
  39. return res
  40. def rm(self, path, json):
  41. res = self.rag.delete(path, json)
  42. return res
  43. def put(self,path, json):
  44. res = self.rag.put(path,json)
  45. return res
  46. def __str__(self):
  47. return str(self.to_json())