from environs import Env env = Env() env.read_env() DEBUG = env.bool('DEBUG', default=False) LOG_LEVEL = env.str('LOG_LEVEL', default='INFO') SECRET_KEY = env.str('SECRET_KEY', default='') if len(SECRET_KEY) < 32: raise ValueError('SECRET_KEY is not set or too short, please set a 32-byte key') API_TOKEN = env.str('API_TOKEN', default='1234567890') SENTRY_DSN = env.str('SENTRY_DSN', default='') DEFAULT_DB_URL = env.str('DEFAULT_DB_URL', default='mysql+pymysql://root:@127.0.0.1:3308/slack_qa_bot') DEFAULT_DB_ASYNC_URL = env.str('DEFAULT_DB_ASYNC_URL', default='mysql+aiomysql://root:@localhost:3308/slack_qa_bot') # used to sign feedback request, should be set as pem format # generate new key pair: # private_key = ecdsa.SigningKey.generate(curve=ecdsa.NIST192p) # public_key = private_key.get_verifying_key() # print(private_key.to_pem().decode()) # print(public_key.to_pem().decode()) ECDSA_PRIVATE_KEY = env.str('ECDSA_PRIVATE_KEY', default='-----BEGIN EC PRIVATE KEY-----\nMF8CAQEEGN+bo7pwJIB5XvPqugnWHz0NMsXKrCKzuaAKBggqhkjOPQMBAaE0AzIA\nBCLofO3mEkEKyMlHI7dq1xVyIybeaI2UMBGGJZ1Oe5QO21w3gNx04XagcWq1G9aR\nwA==\n-----END EC PRIVATE KEY-----') ECDSA_PUBLIC_KEY = env.str('ECDSA_PUBLIC_KEY', default='-----BEGIN PUBLIC KEY-----\nMEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEIuh87eYSQQrIyUcjt2rXFXIjJt5o\njZQwEYYlnU57lA7bXDeA3HThdqBxarUb1pHA\n-----END PUBLIC KEY-----') ### Slack, https://tidbcommunity.slack.com SLACK_APP_TOKEN = env.str('SLACK_APP_TOKEN') # used to send welcome message to new users as operator(@billmay) SLACK_OPERATOR_ACCESS_TOKEN = env.str('SLACK_OPERATOR_ACCESS_TOKEN') SLACK_DM_HELP_TEXT = 'Hey there, folks! Feel free to ask the bot questions by "@TiDB-AI-Assistant [Question]" in the #help-forum. '\ 'The bot will respond to your question within a thread, '\ 'remember to mention "@TiDB-AI-Assistant" in your subsequent questions within the thread or the bot will not reply to your subsequent questions. \n'\ 'We encourage discussion on the public channel to help more community members. Just heads up, direct messages aren\'t supported by TiDB-AI-Assistant at the moment.' SLACK_QA_DAILY_LIMIT = 20 SLACK_REACH_LIMIT_TEXT = f'Greetings, humans! I am a robot. Today, you have reached the maximum limit of {SLACK_QA_DAILY_LIMIT} replies! When posing a question, '\ 'kindly ensure you provide a clear and comprehensive description all at once. '\ 'This will enable me to provide you with more precise and accurate responses. '\ 'See you tomorrow!' SLACK_AI_FEATURE_NOT_ENABLED_TEXT = "TiDB AI Assistant is not enabled in this channel, please contact your admin to enable it, I will leave later." SLACK_NEW_HELP_MESSAGE_ALERT_CHANNEL_IDS = env.list('SLACK_NEW_HELP_MESSAGE_ALERT_CHANNEL_IDS', default=[]) SLACK_NEW_HELP_MESSAGE_FEISHU_WEBHOOK = env.str('SLACK_NEW_HELP_MESSAGE_FEISHU_WEBHOOK', default='') ### Forum, https://ask.pingcap.com FORUM_API_BASE_URL = env.str('FORUM_API_BASE_URL', default='https://ask.pingcap.com') # discourse api key, docs: https://docs.discourse.org FORUM_API_KEY = env.str('FORUM_API_KEY') # discourse api username, will act as this user to post reply FORUM_API_USERNAME = env.str('FORUM_API_USERNAME', default='TiDB-AI-Assistant') # used to verify webhook request FORUM_WEBHOOK_SECRET = env.str('FORUM_WEBHOOK_SECRET') ### Discord, https://discord.gg/PQ9J66rfgW DISCORD_BOT_TOKEN = env.str('DISCORD_BOT_TOKEN') DISCORD_HELP_CHANNEL_IDS = env.list('DISCORD_HELP_CHANNEL_IDS', subcast=int, default=[]) DISCORD_HELP_CHANNEL_NEW_QA_SERVICE_IDS = env.list('DISCORD_HELP_CHANNEL_NEW_QA_SERVICE_IDS', subcast=int, default=[]) DISCORD_HELP_TEXT = 'Hey there, folks! Feel free to ask the bot questions by `@TiDB-AI-Assistant [Question]` in the #help. '\ 'The bot will respond to your question within a thread, '\ 'remember to mention `@TiDB-AI-Assistant` in your subsequent questions within the thread or the bot will not reply to your subsequent questions. \n'\ 'We encourage discussion on the public channel to help more community members. Just heads up, direct messages aren\'t supported by TiDB-AI-Assistant at the moment.' DISCORD_QA_DAILY_LIMIT = 20 DISCORD_REACH_LIMIT_TEXT = f'Greetings, humans! I am a robot. Today, you have reached the maximum limit of {DISCORD_QA_DAILY_LIMIT} replies! When posing a question, '\ 'kindly ensure you provide a clear and comprehensive description all at once. '\ 'This will enable me to provide you with more precise and accurate responses. '\ 'See you tomorrow!' DISCORD_NEW_HELP_MESSAGE_ALERT_CHANNEL_IDS = env.list('DISCORD_NEW_HELP_MESSAGE_ALERT_CHANNEL_IDS', subcast=int, default=[]) DISCORD_NEW_HELP_MESSAGE_FEISHU_WEBHOOK = env.str('DISCORD_NEW_HELP_MESSAGE_FEISHU_WEBHOOK', default='') TIDB_AI_API_BASE = env.str( "TIDB_AI_API_BASE", default="https://tidb.ai/api/v1" ) TIDB_AI_API_KEY = env.str("TIDB_AI_API_KEY", default="") TIDB_AI_SLACK_CHAT_ENGINE = env.str("TIDB_AI_SLACK_CHAT_ENGINE", default="default") TIDB_AI_DISCORD_CHAT_ENGINE = env.str("TIDB_AI_DISCORD_CHAT_ENGINE", default="default") TIDB_AI_FORUM_CHAT_ENGINE = env.str("TIDB_AI_FORUM_CHAT_ENGINE", default="default")