commands.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. import base64
  2. import json
  3. import logging
  4. import secrets
  5. from typing import Optional
  6. import click
  7. from flask import current_app
  8. from werkzeug.exceptions import NotFound
  9. from constants.languages import languages
  10. from core.rag.datasource.vdb.vector_factory import Vector
  11. from core.rag.datasource.vdb.vector_type import VectorType
  12. from core.rag.models.document import Document
  13. from events.app_event import app_was_created
  14. from extensions.ext_database import db
  15. from extensions.ext_redis import redis_client
  16. from libs.helper import email as email_validate
  17. from libs.password import hash_password, password_pattern, valid_password
  18. from libs.rsa import generate_key_pair
  19. from models.account import Tenant
  20. from models.dataset import Dataset, DatasetCollectionBinding, DocumentSegment
  21. from models.dataset import Document as DatasetDocument
  22. from models.model import Account, App, AppAnnotationSetting, AppMode, Conversation, MessageAnnotation
  23. from models.provider import Provider, ProviderModel
  24. from services.account_service import RegisterService, TenantService
  25. @click.command('reset-password', help='Reset the account password.')
  26. @click.option('--email', prompt=True, help='The email address of the account whose password you need to reset')
  27. @click.option('--new-password', prompt=True, help='the new password.')
  28. @click.option('--password-confirm', prompt=True, help='the new password confirm.')
  29. def reset_password(email, new_password, password_confirm):
  30. """
  31. Reset password of owner account
  32. Only available in SELF_HOSTED mode
  33. """
  34. if str(new_password).strip() != str(password_confirm).strip():
  35. click.echo(click.style('sorry. The two passwords do not match.', fg='red'))
  36. return
  37. account = db.session.query(Account). \
  38. filter(Account.email == email). \
  39. one_or_none()
  40. if not account:
  41. click.echo(click.style('sorry. the account: [{}] not exist .'.format(email), fg='red'))
  42. return
  43. try:
  44. valid_password(new_password)
  45. except:
  46. click.echo(
  47. click.style('sorry. The passwords must match {} '.format(password_pattern), fg='red'))
  48. return
  49. # generate password salt
  50. salt = secrets.token_bytes(16)
  51. base64_salt = base64.b64encode(salt).decode()
  52. # encrypt password with salt
  53. password_hashed = hash_password(new_password, salt)
  54. base64_password_hashed = base64.b64encode(password_hashed).decode()
  55. account.password = base64_password_hashed
  56. account.password_salt = base64_salt
  57. db.session.commit()
  58. click.echo(click.style('Congratulations! Password has been reset.', fg='green'))
  59. @click.command('reset-email', help='Reset the account email.')
  60. @click.option('--email', prompt=True, help='The old email address of the account whose email you need to reset')
  61. @click.option('--new-email', prompt=True, help='the new email.')
  62. @click.option('--email-confirm', prompt=True, help='the new email confirm.')
  63. def reset_email(email, new_email, email_confirm):
  64. """
  65. Replace account email
  66. :return:
  67. """
  68. if str(new_email).strip() != str(email_confirm).strip():
  69. click.echo(click.style('Sorry, new email and confirm email do not match.', fg='red'))
  70. return
  71. account = db.session.query(Account). \
  72. filter(Account.email == email). \
  73. one_or_none()
  74. if not account:
  75. click.echo(click.style('sorry. the account: [{}] not exist .'.format(email), fg='red'))
  76. return
  77. try:
  78. email_validate(new_email)
  79. except:
  80. click.echo(
  81. click.style('sorry. {} is not a valid email. '.format(email), fg='red'))
  82. return
  83. account.email = new_email
  84. db.session.commit()
  85. click.echo(click.style('Congratulations!, email has been reset.', fg='green'))
  86. @click.command('reset-encrypt-key-pair', help='Reset the asymmetric key pair of workspace for encrypt LLM credentials. '
  87. 'After the reset, all LLM credentials will become invalid, '
  88. 'requiring re-entry.'
  89. 'Only support SELF_HOSTED mode.')
  90. @click.confirmation_option(prompt=click.style('Are you sure you want to reset encrypt key pair?'
  91. ' this operation cannot be rolled back!', fg='red'))
  92. def reset_encrypt_key_pair():
  93. """
  94. Reset the encrypted key pair of workspace for encrypt LLM credentials.
  95. After the reset, all LLM credentials will become invalid, requiring re-entry.
  96. Only support SELF_HOSTED mode.
  97. """
  98. if current_app.config['EDITION'] != 'SELF_HOSTED':
  99. click.echo(click.style('Sorry, only support SELF_HOSTED mode.', fg='red'))
  100. return
  101. tenants = db.session.query(Tenant).all()
  102. for tenant in tenants:
  103. if not tenant:
  104. click.echo(click.style('Sorry, no workspace found. Please enter /install to initialize.', fg='red'))
  105. return
  106. tenant.encrypt_public_key = generate_key_pair(tenant.id)
  107. db.session.query(Provider).filter(Provider.provider_type == 'custom', Provider.tenant_id == tenant.id).delete()
  108. db.session.query(ProviderModel).filter(ProviderModel.tenant_id == tenant.id).delete()
  109. db.session.commit()
  110. click.echo(click.style('Congratulations! '
  111. 'the asymmetric key pair of workspace {} has been reset.'.format(tenant.id), fg='green'))
  112. @click.command('vdb-migrate', help='migrate vector db.')
  113. @click.option('--scope', default='all', prompt=False, help='The scope of vector database to migrate, Default is All.')
  114. def vdb_migrate(scope: str):
  115. if scope in ['knowledge', 'all']:
  116. migrate_knowledge_vector_database()
  117. if scope in ['annotation', 'all']:
  118. migrate_annotation_vector_database()
  119. def migrate_annotation_vector_database():
  120. """
  121. Migrate annotation datas to target vector database .
  122. """
  123. click.echo(click.style('Start migrate annotation data.', fg='green'))
  124. create_count = 0
  125. skipped_count = 0
  126. total_count = 0
  127. page = 1
  128. while True:
  129. try:
  130. # get apps info
  131. apps = db.session.query(App).filter(
  132. App.status == 'normal'
  133. ).order_by(App.created_at.desc()).paginate(page=page, per_page=50)
  134. except NotFound:
  135. break
  136. page += 1
  137. for app in apps:
  138. total_count = total_count + 1
  139. click.echo(f'Processing the {total_count} app {app.id}. '
  140. + f'{create_count} created, {skipped_count} skipped.')
  141. try:
  142. click.echo('Create app annotation index: {}'.format(app.id))
  143. app_annotation_setting = db.session.query(AppAnnotationSetting).filter(
  144. AppAnnotationSetting.app_id == app.id
  145. ).first()
  146. if not app_annotation_setting:
  147. skipped_count = skipped_count + 1
  148. click.echo('App annotation setting is disabled: {}'.format(app.id))
  149. continue
  150. # get dataset_collection_binding info
  151. dataset_collection_binding = db.session.query(DatasetCollectionBinding).filter(
  152. DatasetCollectionBinding.id == app_annotation_setting.collection_binding_id
  153. ).first()
  154. if not dataset_collection_binding:
  155. click.echo('App annotation collection binding is not exist: {}'.format(app.id))
  156. continue
  157. annotations = db.session.query(MessageAnnotation).filter(MessageAnnotation.app_id == app.id).all()
  158. dataset = Dataset(
  159. id=app.id,
  160. tenant_id=app.tenant_id,
  161. indexing_technique='high_quality',
  162. embedding_model_provider=dataset_collection_binding.provider_name,
  163. embedding_model=dataset_collection_binding.model_name,
  164. collection_binding_id=dataset_collection_binding.id
  165. )
  166. documents = []
  167. if annotations:
  168. for annotation in annotations:
  169. document = Document(
  170. page_content=annotation.question,
  171. metadata={
  172. "annotation_id": annotation.id,
  173. "app_id": app.id,
  174. "doc_id": annotation.id
  175. }
  176. )
  177. documents.append(document)
  178. vector = Vector(dataset, attributes=['doc_id', 'annotation_id', 'app_id'])
  179. click.echo(f"Start to migrate annotation, app_id: {app.id}.")
  180. try:
  181. vector.delete()
  182. click.echo(
  183. click.style(f'Successfully delete vector index for app: {app.id}.',
  184. fg='green'))
  185. except Exception as e:
  186. click.echo(
  187. click.style(f'Failed to delete vector index for app {app.id}.',
  188. fg='red'))
  189. raise e
  190. if documents:
  191. try:
  192. click.echo(click.style(
  193. f'Start to created vector index with {len(documents)} annotations for app {app.id}.',
  194. fg='green'))
  195. vector.create(documents)
  196. click.echo(
  197. click.style(f'Successfully created vector index for app {app.id}.', fg='green'))
  198. except Exception as e:
  199. click.echo(click.style(f'Failed to created vector index for app {app.id}.', fg='red'))
  200. raise e
  201. click.echo(f'Successfully migrated app annotation {app.id}.')
  202. create_count += 1
  203. except Exception as e:
  204. click.echo(
  205. click.style('Create app annotation index error: {} {}'.format(e.__class__.__name__, str(e)),
  206. fg='red'))
  207. continue
  208. click.echo(
  209. click.style(f'Congratulations! Create {create_count} app annotation indexes, and skipped {skipped_count} apps.',
  210. fg='green'))
  211. def migrate_knowledge_vector_database():
  212. """
  213. Migrate vector database datas to target vector database .
  214. """
  215. click.echo(click.style('Start migrate vector db.', fg='green'))
  216. create_count = 0
  217. skipped_count = 0
  218. total_count = 0
  219. config = current_app.config
  220. vector_type = config.get('VECTOR_STORE')
  221. page = 1
  222. while True:
  223. try:
  224. datasets = db.session.query(Dataset).filter(Dataset.indexing_technique == 'high_quality') \
  225. .order_by(Dataset.created_at.desc()).paginate(page=page, per_page=50)
  226. except NotFound:
  227. break
  228. page += 1
  229. for dataset in datasets:
  230. total_count = total_count + 1
  231. click.echo(f'Processing the {total_count} dataset {dataset.id}. '
  232. + f'{create_count} created, {skipped_count} skipped.')
  233. try:
  234. click.echo('Create dataset vdb index: {}'.format(dataset.id))
  235. if dataset.index_struct_dict:
  236. if dataset.index_struct_dict['type'] == vector_type:
  237. skipped_count = skipped_count + 1
  238. continue
  239. collection_name = ''
  240. if vector_type == VectorType.WEAVIATE:
  241. dataset_id = dataset.id
  242. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  243. index_struct_dict = {
  244. "type": VectorType.WEAVIATE,
  245. "vector_store": {"class_prefix": collection_name}
  246. }
  247. dataset.index_struct = json.dumps(index_struct_dict)
  248. elif vector_type == VectorType.QDRANT:
  249. if dataset.collection_binding_id:
  250. dataset_collection_binding = db.session.query(DatasetCollectionBinding). \
  251. filter(DatasetCollectionBinding.id == dataset.collection_binding_id). \
  252. one_or_none()
  253. if dataset_collection_binding:
  254. collection_name = dataset_collection_binding.collection_name
  255. else:
  256. raise ValueError('Dataset Collection Bindings is not exist!')
  257. else:
  258. dataset_id = dataset.id
  259. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  260. index_struct_dict = {
  261. "type": VectorType.QDRANT,
  262. "vector_store": {"class_prefix": collection_name}
  263. }
  264. dataset.index_struct = json.dumps(index_struct_dict)
  265. elif vector_type == VectorType.MILVUS:
  266. dataset_id = dataset.id
  267. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  268. index_struct_dict = {
  269. "type": VectorType.MILVUS,
  270. "vector_store": {"class_prefix": collection_name}
  271. }
  272. dataset.index_struct = json.dumps(index_struct_dict)
  273. elif vector_type == VectorType.RELYT:
  274. dataset_id = dataset.id
  275. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  276. index_struct_dict = {
  277. "type": 'relyt',
  278. "vector_store": {"class_prefix": collection_name}
  279. }
  280. dataset.index_struct = json.dumps(index_struct_dict)
  281. elif vector_type == VectorType.TENCENT:
  282. dataset_id = dataset.id
  283. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  284. index_struct_dict = {
  285. "type": VectorType.TENCENT,
  286. "vector_store": {"class_prefix": collection_name}
  287. }
  288. dataset.index_struct = json.dumps(index_struct_dict)
  289. elif vector_type == VectorType.PGVECTOR:
  290. dataset_id = dataset.id
  291. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  292. index_struct_dict = {
  293. "type": VectorType.PGVECTOR,
  294. "vector_store": {"class_prefix": collection_name}
  295. }
  296. dataset.index_struct = json.dumps(index_struct_dict)
  297. elif vector_type == VectorType.OPENSEARCH:
  298. dataset_id = dataset.id
  299. collection_name = Dataset.gen_collection_name_by_id(dataset_id)
  300. index_struct_dict = {
  301. "type": VectorType.OPENSEARCH,
  302. "vector_store": {"class_prefix": collection_name}
  303. }
  304. dataset.index_struct = json.dumps(index_struct_dict)
  305. else:
  306. raise ValueError(f"Vector store {vector_type} is not supported.")
  307. vector = Vector(dataset)
  308. click.echo(f"Start to migrate dataset {dataset.id}.")
  309. try:
  310. vector.delete()
  311. click.echo(
  312. click.style(f'Successfully delete vector index {collection_name} for dataset {dataset.id}.',
  313. fg='green'))
  314. except Exception as e:
  315. click.echo(
  316. click.style(f'Failed to delete vector index {collection_name} for dataset {dataset.id}.',
  317. fg='red'))
  318. raise e
  319. dataset_documents = db.session.query(DatasetDocument).filter(
  320. DatasetDocument.dataset_id == dataset.id,
  321. DatasetDocument.indexing_status == 'completed',
  322. DatasetDocument.enabled == True,
  323. DatasetDocument.archived == False,
  324. ).all()
  325. documents = []
  326. segments_count = 0
  327. for dataset_document in dataset_documents:
  328. segments = db.session.query(DocumentSegment).filter(
  329. DocumentSegment.document_id == dataset_document.id,
  330. DocumentSegment.status == 'completed',
  331. DocumentSegment.enabled == True
  332. ).all()
  333. for segment in segments:
  334. document = Document(
  335. page_content=segment.content,
  336. metadata={
  337. "doc_id": segment.index_node_id,
  338. "doc_hash": segment.index_node_hash,
  339. "document_id": segment.document_id,
  340. "dataset_id": segment.dataset_id,
  341. }
  342. )
  343. documents.append(document)
  344. segments_count = segments_count + 1
  345. if documents:
  346. try:
  347. click.echo(click.style(
  348. f'Start to created vector index with {len(documents)} documents of {segments_count} segments for dataset {dataset.id}.',
  349. fg='green'))
  350. vector.create(documents)
  351. click.echo(
  352. click.style(f'Successfully created vector index for dataset {dataset.id}.', fg='green'))
  353. except Exception as e:
  354. click.echo(click.style(f'Failed to created vector index for dataset {dataset.id}.', fg='red'))
  355. raise e
  356. db.session.add(dataset)
  357. db.session.commit()
  358. click.echo(f'Successfully migrated dataset {dataset.id}.')
  359. create_count += 1
  360. except Exception as e:
  361. db.session.rollback()
  362. click.echo(
  363. click.style('Create dataset index error: {} {}'.format(e.__class__.__name__, str(e)),
  364. fg='red'))
  365. continue
  366. click.echo(
  367. click.style(f'Congratulations! Create {create_count} dataset indexes, and skipped {skipped_count} datasets.',
  368. fg='green'))
  369. @click.command('convert-to-agent-apps', help='Convert Agent Assistant to Agent App.')
  370. def convert_to_agent_apps():
  371. """
  372. Convert Agent Assistant to Agent App.
  373. """
  374. click.echo(click.style('Start convert to agent apps.', fg='green'))
  375. proceeded_app_ids = []
  376. while True:
  377. # fetch first 1000 apps
  378. sql_query = """SELECT a.id AS id FROM apps a
  379. INNER JOIN app_model_configs am ON a.app_model_config_id=am.id
  380. WHERE a.mode = 'chat'
  381. AND am.agent_mode is not null
  382. AND (
  383. am.agent_mode like '%"strategy": "function_call"%'
  384. OR am.agent_mode like '%"strategy": "react"%'
  385. )
  386. AND (
  387. am.agent_mode like '{"enabled": true%'
  388. OR am.agent_mode like '{"max_iteration": %'
  389. ) ORDER BY a.created_at DESC LIMIT 1000
  390. """
  391. with db.engine.begin() as conn:
  392. rs = conn.execute(db.text(sql_query))
  393. apps = []
  394. for i in rs:
  395. app_id = str(i.id)
  396. if app_id not in proceeded_app_ids:
  397. proceeded_app_ids.append(app_id)
  398. app = db.session.query(App).filter(App.id == app_id).first()
  399. apps.append(app)
  400. if len(apps) == 0:
  401. break
  402. for app in apps:
  403. click.echo('Converting app: {}'.format(app.id))
  404. try:
  405. app.mode = AppMode.AGENT_CHAT.value
  406. db.session.commit()
  407. # update conversation mode to agent
  408. db.session.query(Conversation).filter(Conversation.app_id == app.id).update(
  409. {Conversation.mode: AppMode.AGENT_CHAT.value}
  410. )
  411. db.session.commit()
  412. click.echo(click.style('Converted app: {}'.format(app.id), fg='green'))
  413. except Exception as e:
  414. click.echo(
  415. click.style('Convert app error: {} {}'.format(e.__class__.__name__,
  416. str(e)), fg='red'))
  417. click.echo(click.style('Congratulations! Converted {} agent apps.'.format(len(proceeded_app_ids)), fg='green'))
  418. @click.command('add-qdrant-doc-id-index', help='add qdrant doc_id index.')
  419. @click.option('--field', default='metadata.doc_id', prompt=False, help='index field , default is metadata.doc_id.')
  420. def add_qdrant_doc_id_index(field: str):
  421. click.echo(click.style('Start add qdrant doc_id index.', fg='green'))
  422. config = current_app.config
  423. vector_type = config.get('VECTOR_STORE')
  424. if vector_type != "qdrant":
  425. click.echo(click.style('Sorry, only support qdrant vector store.', fg='red'))
  426. return
  427. create_count = 0
  428. try:
  429. bindings = db.session.query(DatasetCollectionBinding).all()
  430. if not bindings:
  431. click.echo(click.style('Sorry, no dataset collection bindings found.', fg='red'))
  432. return
  433. import qdrant_client
  434. from qdrant_client.http.exceptions import UnexpectedResponse
  435. from qdrant_client.http.models import PayloadSchemaType
  436. from core.rag.datasource.vdb.qdrant.qdrant_vector import QdrantConfig
  437. for binding in bindings:
  438. qdrant_config = QdrantConfig(
  439. endpoint=config.get('QDRANT_URL'),
  440. api_key=config.get('QDRANT_API_KEY'),
  441. root_path=current_app.root_path,
  442. timeout=config.get('QDRANT_CLIENT_TIMEOUT'),
  443. grpc_port=config.get('QDRANT_GRPC_PORT'),
  444. prefer_grpc=config.get('QDRANT_GRPC_ENABLED')
  445. )
  446. try:
  447. client = qdrant_client.QdrantClient(**qdrant_config.to_qdrant_params())
  448. # create payload index
  449. client.create_payload_index(binding.collection_name, field,
  450. field_schema=PayloadSchemaType.KEYWORD)
  451. create_count += 1
  452. except UnexpectedResponse as e:
  453. # Collection does not exist, so return
  454. if e.status_code == 404:
  455. click.echo(click.style(f'Collection not found, collection_name:{binding.collection_name}.', fg='red'))
  456. continue
  457. # Some other error occurred, so re-raise the exception
  458. else:
  459. click.echo(click.style(f'Failed to create qdrant index, collection_name:{binding.collection_name}.', fg='red'))
  460. except Exception as e:
  461. click.echo(click.style('Failed to create qdrant client.', fg='red'))
  462. click.echo(
  463. click.style(f'Congratulations! Create {create_count} collection indexes.',
  464. fg='green'))
  465. @click.command('create-tenant', help='Create account and tenant.')
  466. @click.option('--email', prompt=True, help='The email address of the tenant account.')
  467. @click.option('--language', prompt=True, help='Account language, default: en-US.')
  468. def create_tenant(email: str, language: Optional[str] = None):
  469. """
  470. Create tenant account
  471. """
  472. if not email:
  473. click.echo(click.style('Sorry, email is required.', fg='red'))
  474. return
  475. # Create account
  476. email = email.strip()
  477. if '@' not in email:
  478. click.echo(click.style('Sorry, invalid email address.', fg='red'))
  479. return
  480. account_name = email.split('@')[0]
  481. if language not in languages:
  482. language = 'en-US'
  483. # generate random password
  484. new_password = secrets.token_urlsafe(16)
  485. # register account
  486. account = RegisterService.register(
  487. email=email,
  488. name=account_name,
  489. password=new_password,
  490. language=language
  491. )
  492. TenantService.create_owner_tenant_if_not_exist(account)
  493. click.echo(click.style('Congratulations! Account and tenant created.\n'
  494. 'Account: {}\nPassword: {}'.format(email, new_password), fg='green'))
  495. @click.command('upgrade-db', help='upgrade the database')
  496. def upgrade_db():
  497. click.echo('Preparing database migration...')
  498. lock = redis_client.lock(name='db_upgrade_lock', timeout=60)
  499. if lock.acquire(blocking=False):
  500. try:
  501. click.echo(click.style('Start database migration.', fg='green'))
  502. # run db migration
  503. import flask_migrate
  504. flask_migrate.upgrade()
  505. click.echo(click.style('Database migration successful!', fg='green'))
  506. except Exception as e:
  507. logging.exception(f'Database migration failed, error: {e}')
  508. finally:
  509. lock.release()
  510. else:
  511. click.echo('Database migration skipped')
  512. @click.command('fix-app-site-missing', help='Fix app related site missing issue.')
  513. def fix_app_site_missing():
  514. """
  515. Fix app related site missing issue.
  516. """
  517. click.echo(click.style('Start fix app related site missing issue.', fg='green'))
  518. while True:
  519. try:
  520. sql = """select apps.id as id from apps left join sites on sites.app_id=apps.id
  521. where sites.id is null limit 1000"""
  522. with db.engine.begin() as conn:
  523. rs = conn.execute(db.text(sql))
  524. processed_count = 0
  525. for i in rs:
  526. processed_count += 1
  527. app_id = str(i.id)
  528. app = db.session.query(App).filter(App.id == app_id).first()
  529. tenant = app.tenant
  530. if tenant:
  531. accounts = tenant.get_accounts()
  532. if not accounts:
  533. print("Fix app {} failed.".format(app.id))
  534. continue
  535. account = accounts[0]
  536. print("Fix app {} related site missing issue.".format(app.id))
  537. app_was_created.send(app, account=account)
  538. if not processed_count:
  539. break
  540. except Exception as e:
  541. click.echo(click.style('Fix app related site missing issue failed!', fg='red'))
  542. logging.exception(f'Fix app related site missing issue failed, error: {e}')
  543. continue
  544. click.echo(click.style('Congratulations! Fix app related site missing issue successful!', fg='green'))
  545. def register_commands(app):
  546. app.cli.add_command(reset_password)
  547. app.cli.add_command(reset_email)
  548. app.cli.add_command(reset_encrypt_key_pair)
  549. app.cli.add_command(vdb_migrate)
  550. app.cli.add_command(convert_to_agent_apps)
  551. app.cli.add_command(add_qdrant_doc_id_index)
  552. app.cli.add_command(create_tenant)
  553. app.cli.add_command(upgrade_db)
  554. app.cli.add_command(fix_app_site_missing)