You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #
  2. # Copyright 2024 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. import os
  17. import logging
  18. from api.utils import get_base_config, decrypt_database_config
  19. from api.utils.file_utils import get_project_base_directory
  20. # Server
  21. RAG_CONF_PATH = os.path.join(get_project_base_directory(), "conf")
  22. ES = get_base_config("es", {})
  23. INFINITY = get_base_config("infinity", {"uri": "infinity:23817"})
  24. AZURE = get_base_config("azure", {})
  25. S3 = get_base_config("s3", {})
  26. MINIO = decrypt_database_config(name="minio")
  27. OSS = get_base_config("oss", {})
  28. try:
  29. REDIS = decrypt_database_config(name="redis")
  30. except Exception:
  31. REDIS = {}
  32. pass
  33. DOC_MAXIMUM_SIZE = int(os.environ.get("MAX_CONTENT_LENGTH", 128 * 1024 * 1024))
  34. SVR_QUEUE_NAME = "rag_flow_svr_queue"
  35. SVR_CONSUMER_GROUP_NAME = "rag_flow_svr_task_broker"
  36. PAGERANK_FLD = "pagerank_fea"
  37. TAG_FLD = "tag_feas"
  38. PARALLEL_DEVICES = None
  39. try:
  40. import torch.cuda
  41. PARALLEL_DEVICES = torch.cuda.device_count()
  42. logging.info(f"found {PARALLEL_DEVICES} gpus")
  43. except Exception:
  44. logging.info("can't import package 'torch'")
  45. def print_rag_settings():
  46. logging.info(f"MAX_CONTENT_LENGTH: {DOC_MAXIMUM_SIZE}")
  47. logging.info(f"MAX_FILE_COUNT_PER_USER: {int(os.environ.get('MAX_FILE_NUM_PER_USER', 0))}")
  48. def get_svr_queue_name(priority: int) -> str:
  49. if priority == 0:
  50. return SVR_QUEUE_NAME
  51. return f"{SVR_QUEUE_NAME}_{priority}"
  52. def get_svr_queue_names():
  53. return [get_svr_queue_name(priority) for priority in [1, 0]]