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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. from api.utils.log_utils import LoggerFactory, getLogger
  21. # Server
  22. RAG_CONF_PATH = os.path.join(get_project_base_directory(), "conf")
  23. SUBPROCESS_STD_LOG_NAME = "std.log"
  24. ES = get_base_config("es", {})
  25. AZURE = get_base_config("azure", {})
  26. S3 = get_base_config("s3", {})
  27. MINIO = decrypt_database_config(name="minio")
  28. try:
  29. REDIS = decrypt_database_config(name="redis")
  30. except Exception as e:
  31. REDIS = {}
  32. pass
  33. DOC_MAXIMUM_SIZE = int(os.environ.get("MAX_CONTENT_LENGTH", 128 * 1024 * 1024))
  34. # Logger
  35. LoggerFactory.set_directory(
  36. os.path.join(
  37. get_project_base_directory(),
  38. "logs",
  39. "rag"))
  40. # {CRITICAL: 50, FATAL:50, ERROR:40, WARNING:30, WARN:30, INFO:20, DEBUG:10, NOTSET:0}
  41. LoggerFactory.LEVEL = 30
  42. es_logger = getLogger("es")
  43. minio_logger = getLogger("minio")
  44. s3_logger = getLogger("s3")
  45. azure_logger = getLogger("azure")
  46. cron_logger = getLogger("cron_logger")
  47. chunk_logger = getLogger("chunk_logger")
  48. database_logger = getLogger("database")
  49. formatter = logging.Formatter("%(asctime)-15s %(levelname)-8s (%(process)d) %(message)s")
  50. for logger in [es_logger, minio_logger, s3_logger, azure_logger, cron_logger, chunk_logger, database_logger]:
  51. logger.setLevel(logging.INFO)
  52. for handler in logger.handlers:
  53. handler.setFormatter(fmt=formatter)
  54. SVR_QUEUE_NAME = "rag_flow_svr_queue"
  55. SVR_QUEUE_RETENTION = 60*60
  56. SVR_QUEUE_MAX_LEN = 1024
  57. SVR_CONSUMER_NAME = "rag_flow_svr_consumer"
  58. SVR_CONSUMER_GROUP_NAME = "rag_flow_svr_consumer_group"