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.

init_data.py 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #
  2. # Copyright 2019 The RAG Flow 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 time
  17. import uuid
  18. from web_server.db import LLMType
  19. from web_server.db.db_models import init_database_tables as init_web_db
  20. from web_server.db.services import UserService
  21. from web_server.db.services.llm_service import LLMFactoriesService, LLMService
  22. def init_superuser():
  23. user_info = {
  24. "id": uuid.uuid1().hex,
  25. "password": "admin",
  26. "nickname": "admin",
  27. "is_superuser": True,
  28. "email": "kai.hu@infiniflow.org",
  29. "creator": "system",
  30. "status": "1",
  31. }
  32. UserService.save(**user_info)
  33. def init_llm_factory():
  34. factory_infos = [{
  35. "name": "OpenAI",
  36. "logo": "",
  37. "tags": "LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION",
  38. "status": "1",
  39. },{
  40. "name": "通义千问",
  41. "logo": "",
  42. "tags": "LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION",
  43. "status": "1",
  44. },{
  45. "name": "智普AI",
  46. "logo": "",
  47. "tags": "LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION",
  48. "status": "1",
  49. },{
  50. "name": "文心一言",
  51. "logo": "",
  52. "tags": "LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION",
  53. "status": "1",
  54. },
  55. ]
  56. llm_infos = [{
  57. "fid": factory_infos[0]["name"],
  58. "llm_name": "gpt-3.5-turbo",
  59. "tags": "LLM,CHAT,4K",
  60. "model_type": LLMType.CHAT.value
  61. },{
  62. "fid": factory_infos[0]["name"],
  63. "llm_name": "gpt-3.5-turbo-16k-0613",
  64. "tags": "LLM,CHAT,16k",
  65. "model_type": LLMType.CHAT.value
  66. },{
  67. "fid": factory_infos[0]["name"],
  68. "llm_name": "text-embedding-ada-002",
  69. "tags": "TEXT EMBEDDING,8K",
  70. "model_type": LLMType.EMBEDDING.value
  71. },{
  72. "fid": factory_infos[0]["name"],
  73. "llm_name": "whisper-1",
  74. "tags": "SPEECH2TEXT",
  75. "model_type": LLMType.SPEECH2TEXT.value
  76. },{
  77. "fid": factory_infos[0]["name"],
  78. "llm_name": "gpt-4",
  79. "tags": "LLM,CHAT,8K",
  80. "model_type": LLMType.CHAT.value
  81. },{
  82. "fid": factory_infos[0]["name"],
  83. "llm_name": "gpt-4-32k",
  84. "tags": "LLM,CHAT,32K",
  85. "model_type": LLMType.CHAT.value
  86. },{
  87. "fid": factory_infos[0]["name"],
  88. "llm_name": "gpt-4-vision-preview",
  89. "tags": "LLM,CHAT,IMAGE2TEXT",
  90. "model_type": LLMType.IMAGE2TEXT.value
  91. },{
  92. "fid": factory_infos[1]["name"],
  93. "llm_name": "qwen-turbo",
  94. "tags": "LLM,CHAT,8K",
  95. "model_type": LLMType.CHAT.value
  96. },{
  97. "fid": factory_infos[1]["name"],
  98. "llm_name": "qwen-plus",
  99. "tags": "LLM,CHAT,32K",
  100. "model_type": LLMType.CHAT.value
  101. },{
  102. "fid": factory_infos[1]["name"],
  103. "llm_name": "text-embedding-v2",
  104. "tags": "TEXT EMBEDDING,2K",
  105. "model_type": LLMType.EMBEDDING.value
  106. },{
  107. "fid": factory_infos[1]["name"],
  108. "llm_name": "paraformer-realtime-8k-v1",
  109. "tags": "SPEECH2TEXT",
  110. "model_type": LLMType.SPEECH2TEXT.value
  111. },{
  112. "fid": factory_infos[1]["name"],
  113. "llm_name": "qwen_vl_chat_v1",
  114. "tags": "LLM,CHAT,IMAGE2TEXT",
  115. "model_type": LLMType.IMAGE2TEXT.value
  116. },
  117. ]
  118. for info in factory_infos:
  119. LLMFactoriesService.save(**info)
  120. for info in llm_infos:
  121. LLMService.save(**info)
  122. def init_web_data():
  123. start_time = time.time()
  124. if not UserService.get_all().count():
  125. init_superuser()
  126. if not LLMService.get_all().count():init_llm_factory()
  127. print("init web data success:{}".format(time.time() - start_time))
  128. if __name__ == '__main__':
  129. init_web_db()
  130. init_web_data()