@lobehub/chat 1.114.3 → 1.114.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/.github/scripts/docker-pr-comment.js +89 -0
  2. package/.github/workflows/docker-database.yml +21 -0
  3. package/.github/workflows/release.yml +7 -5
  4. package/.github/workflows/test.yml +9 -7
  5. package/CHANGELOG.md +25 -0
  6. package/Dockerfile.database +1 -1
  7. package/changelog/v1.json +9 -0
  8. package/codecov.yml +30 -2
  9. package/docs/development/database-schema.dbml +14 -0
  10. package/drizzle.config.ts +2 -2
  11. package/package.json +5 -5
  12. package/packages/const/src/index.ts +2 -0
  13. package/{src/utils → packages/const/src/settings}/genUserLLMConfig.test.ts +1 -1
  14. package/{src/utils → packages/const/src/settings}/genUserLLMConfig.ts +1 -1
  15. package/packages/const/src/settings/index.ts +0 -2
  16. package/packages/const/src/settings/llm.ts +1 -1
  17. package/{src → packages}/database/migrations/0028_oauth_handoffs.sql +1 -1
  18. package/{src → packages}/database/migrations/0029_add_apikey_manage.sql +1 -1
  19. package/packages/database/package.json +24 -0
  20. package/{src/database → packages/database/src}/client/db.ts +2 -2
  21. package/{src/database → packages/database/src}/core/db-adaptor.ts +3 -3
  22. package/{src/database → packages/database/src}/core/dbForTest.ts +1 -1
  23. package/{src/database → packages/database/src}/core/electron.ts +3 -3
  24. package/{src/database/client → packages/database/src/core}/migrations.json +12 -2
  25. package/{src/database → packages/database/src}/core/web-server.ts +2 -3
  26. package/{src/database → packages/database/src}/models/__tests__/_test_template.ts +1 -2
  27. package/{src/database → packages/database/src}/models/__tests__/_util.ts +3 -3
  28. package/{src/database → packages/database/src}/models/__tests__/agent.test.ts +1 -2
  29. package/{src/database → packages/database/src}/models/__tests__/aiModel.test.ts +1 -1
  30. package/{src/database → packages/database/src}/models/__tests__/aiProvider.test.ts +1 -1
  31. package/{src/database → packages/database/src}/models/__tests__/asyncTask.test.ts +1 -1
  32. package/{src/database → packages/database/src}/models/__tests__/chunk.test.ts +1 -2
  33. package/{src/database → packages/database/src}/models/__tests__/file.test.ts +1 -1
  34. package/{src/database → packages/database/src}/models/__tests__/generation.test.ts +1 -2
  35. package/{src/database → packages/database/src}/models/__tests__/generationBatch.test.ts +1 -2
  36. package/{src/database → packages/database/src}/models/__tests__/generationTopic.test.ts +1 -2
  37. package/{src/database → packages/database/src}/models/__tests__/knowledgeBase.test.ts +1 -2
  38. package/{src/database → packages/database/src}/models/__tests__/message.test.ts +2 -2
  39. package/{src/database → packages/database/src}/models/__tests__/plugin.test.ts +1 -2
  40. package/{src/database → packages/database/src}/models/__tests__/session.test.ts +2 -2
  41. package/{src/database → packages/database/src}/models/__tests__/sessionGroup.test.ts +1 -2
  42. package/{src/database → packages/database/src}/models/__tests__/topic.test.ts +1 -2
  43. package/{src/database → packages/database/src}/models/_template.ts +1 -2
  44. package/{src/database → packages/database/src}/models/agent.ts +2 -2
  45. package/{src/database → packages/database/src}/models/aiModel.ts +1 -1
  46. package/{src/database → packages/database/src}/models/aiProvider.ts +1 -1
  47. package/{src/database → packages/database/src}/models/apiKey.ts +1 -1
  48. package/{src/database → packages/database/src}/models/asyncTask.ts +1 -1
  49. package/{src/database → packages/database/src}/models/chunk.ts +1 -1
  50. package/{src/database → packages/database/src}/models/document.ts +1 -1
  51. package/{src/database → packages/database/src}/models/drizzleMigration.ts +1 -1
  52. package/{src/database → packages/database/src}/models/embedding.ts +1 -1
  53. package/{src/database → packages/database/src}/models/file.ts +1 -1
  54. package/{src/database → packages/database/src}/models/generation.ts +1 -1
  55. package/{src/database → packages/database/src}/models/generationBatch.ts +1 -1
  56. package/{src/database → packages/database/src}/models/generationTopic.ts +1 -1
  57. package/{src/database → packages/database/src}/models/knowledgeBase.ts +1 -1
  58. package/{src/database → packages/database/src}/models/message.ts +3 -3
  59. package/{src/database → packages/database/src}/models/oauthHandoff.ts +1 -1
  60. package/{src/database → packages/database/src}/models/plugin.ts +1 -1
  61. package/{src/database → packages/database/src}/models/session.ts +3 -3
  62. package/{src/database → packages/database/src}/models/sessionGroup.ts +2 -2
  63. package/{src/database → packages/database/src}/models/thread.ts +1 -1
  64. package/{src/database → packages/database/src}/models/topic.ts +3 -3
  65. package/{src/database → packages/database/src}/models/user.ts +1 -1
  66. package/{src/database → packages/database/src}/repositories/aiInfra/index.ts +4 -3
  67. package/{src/database → packages/database/src}/repositories/dataExporter/index.ts +2 -2
  68. package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/index.test.ts +2 -2
  69. package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/index.ts +6 -5
  70. package/{src/database → packages/database/src}/repositories/dataImporter/index.ts +2 -2
  71. package/{src/database → packages/database/src}/repositories/tableViewer/index.test.ts +1 -1
  72. package/{src/database → packages/database/src}/repositories/tableViewer/index.ts +2 -1
  73. package/{src/database → packages/database/src}/schemas/agent.ts +1 -1
  74. package/{src/database → packages/database/src}/schemas/aiInfra.ts +3 -2
  75. package/{src/database → packages/database/src}/schemas/document.ts +2 -2
  76. package/{src/database → packages/database/src}/schemas/file.ts +1 -1
  77. package/{src/database → packages/database/src}/schemas/generation.ts +1 -1
  78. package/{src/database → packages/database/src}/schemas/message.ts +1 -1
  79. package/{src/database → packages/database/src}/schemas/ragEvals.ts +1 -1
  80. package/{src/database → packages/database/src}/schemas/relations.ts +1 -2
  81. package/{src/database → packages/database/src}/schemas/session.ts +1 -2
  82. package/{src/database → packages/database/src}/schemas/topic.ts +2 -2
  83. package/{src/database → packages/database/src}/server/models/__tests__/adapter.test.ts +5 -4
  84. package/{src/database → packages/database/src}/server/models/__tests__/nextauth.test.ts +4 -4
  85. package/{src/database → packages/database/src}/server/models/__tests__/user.test.ts +1 -2
  86. package/{src/database → packages/database/src}/server/models/ragEval/dataset.ts +3 -3
  87. package/{src/database → packages/database/src}/server/models/ragEval/datasetRecord.ts +3 -3
  88. package/{src/database → packages/database/src}/server/models/ragEval/evaluation.ts +3 -3
  89. package/{src/database → packages/database/src}/server/models/ragEval/evaluationRecord.ts +2 -2
  90. package/{src/database → packages/database/src}/utils/idGenerator.ts +4 -1
  91. package/{vitest.config.server.ts → packages/database/vitest.config.ts} +8 -7
  92. package/packages/model-runtime/package.json +1 -0
  93. package/packages/model-runtime/src/bfl/createImage.test.ts +4 -4
  94. package/packages/model-runtime/src/bfl/createImage.ts +1 -1
  95. package/packages/model-runtime/src/google/index.test.ts +1 -1
  96. package/packages/model-runtime/src/google/index.ts +1 -3
  97. package/packages/model-runtime/src/ollama/index.ts +3 -2
  98. package/packages/model-runtime/src/utils/anthropicHelpers.test.ts +2 -3
  99. package/packages/model-runtime/src/utils/anthropicHelpers.ts +1 -2
  100. package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +1 -1
  101. package/packages/model-runtime/src/utils/openaiHelpers.test.ts +2 -3
  102. package/packages/model-runtime/src/utils/openaiHelpers.ts +2 -2
  103. package/packages/model-runtime/src/utils/streams/bedrock/claude.ts +1 -2
  104. package/packages/model-runtime/src/utils/streams/bedrock/llama.test.ts +1 -2
  105. package/packages/model-runtime/src/utils/streams/bedrock/llama.ts +1 -2
  106. package/packages/model-runtime/src/utils/streams/google-ai.test.ts +1 -2
  107. package/packages/model-runtime/src/utils/streams/google-ai.ts +1 -1
  108. package/packages/model-runtime/src/utils/streams/ollama.test.ts +1 -2
  109. package/packages/model-runtime/src/utils/streams/ollama.ts +1 -1
  110. package/packages/model-runtime/src/utils/streams/protocol.ts +2 -2
  111. package/packages/model-runtime/src/utils/streams/vertex-ai.test.ts +1 -2
  112. package/packages/model-runtime/src/utils/streams/vertex-ai.ts +1 -1
  113. package/packages/model-runtime/vitest.config.ts +2 -0
  114. package/packages/types/src/index.ts +5 -0
  115. package/packages/utils/package.json +17 -0
  116. package/{src/utils → packages/utils/src}/client/cookie.test.ts +1 -3
  117. package/{src/utils → packages/utils/src}/client/cookie.ts +1 -1
  118. package/{src/utils → packages/utils/src}/client/parserPlaceholder.test.ts +2 -2
  119. package/{src/utils → packages/utils/src}/client/parserPlaceholder.ts +77 -73
  120. package/{src/utils → packages/utils/src}/client/topic.test.ts +1 -1
  121. package/{src/utils → packages/utils/src}/compressImage.test.ts +2 -0
  122. package/{src/utils → packages/utils/src}/fetch/__tests__/fetchSSE.test.ts +3 -4
  123. package/{src/utils → packages/utils/src}/fetch/fetchSSE.ts +1 -1
  124. package/{src/utils → packages/utils/src}/getFallbackModelProperty.test.ts +1 -1
  125. package/packages/utils/src/index.ts +5 -0
  126. package/{src/utils → packages/utils/src}/locale.ts +2 -1
  127. package/{src/utils → packages/utils/src}/merge.test.ts +1 -3
  128. package/{src/utils → packages/utils/src}/parseModels.ts +3 -2
  129. package/{src/utils → packages/utils/src}/platform.test.ts +1 -1
  130. package/{src/utils → packages/utils/src}/platform.ts +1 -1
  131. package/{src/utils → packages/utils/src}/sanitizeUTF8.test.ts +2 -0
  132. package/{src/utils → packages/utils/src}/server/__tests__/geo.test.ts +1 -1
  133. package/{src/utils → packages/utils/src}/server/xor.test.ts +1 -2
  134. package/{src/utils → packages/utils/src}/url.test.ts +1 -1
  135. package/packages/utils/tests/setup.ts +10 -0
  136. package/packages/utils/vitest.config.ts +16 -0
  137. package/scripts/dbmlWorkflow/index.ts +1 -1
  138. package/scripts/migrateClientDB/compile-migrations.ts +2 -2
  139. package/scripts/migrateServerDB/index.ts +2 -2
  140. package/src/app/[variants]/(main)/repos/[id]/evals/dataset/CreateDataset/CreateForm.tsx +1 -1
  141. package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetDetail/index.tsx +1 -1
  142. package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetList/Item.tsx +1 -2
  143. package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetList/index.tsx +1 -2
  144. package/src/app/[variants]/(main)/repos/[id]/evals/evaluation/CreateEvaluation/CreateForm.tsx +1 -1
  145. package/src/app/[variants]/(main)/repos/[id]/evals/evaluation/EvaluationList/index.tsx +1 -1
  146. package/src/features/AgentSetting/store/index.ts +1 -2
  147. package/src/server/routers/async/ragEval.ts +1 -1
  148. package/src/server/routers/lambda/ragEval.ts +9 -9
  149. package/src/services/config.ts +1 -1
  150. package/src/services/ragEval.ts +4 -3
  151. package/src/store/knowledgeBase/slices/ragEval/actions/dataset.ts +6 -6
  152. package/src/store/knowledgeBase/slices/ragEval/actions/evaluation.ts +1 -1
  153. package/src/store/serverConfig/store.ts +1 -1
  154. package/src/utils/client/switchLang.test.ts +2 -2
  155. package/src/utils/client/switchLang.ts +2 -3
  156. package/tests/setup.ts +0 -11
  157. package/tsconfig.json +2 -0
  158. package/vitest.config.ts +6 -2
  159. /package/{src → packages}/database/migrations/0000_init.sql +0 -0
  160. /package/{src → packages}/database/migrations/0001_add_client_id.sql +0 -0
  161. /package/{src → packages}/database/migrations/0002_amusing_puma.sql +0 -0
  162. /package/{src → packages}/database/migrations/0003_naive_echo.sql +0 -0
  163. /package/{src → packages}/database/migrations/0004_add_next_auth.sql +0 -0
  164. /package/{src → packages}/database/migrations/0005_pgvector.sql +0 -0
  165. /package/{src → packages}/database/migrations/0006_add_knowledge_base.sql +0 -0
  166. /package/{src → packages}/database/migrations/0007_fix_embedding_table.sql +0 -0
  167. /package/{src → packages}/database/migrations/0008_add_rag_evals.sql +0 -0
  168. /package/{src → packages}/database/migrations/0009_remove_unused_user_tables.sql +0 -0
  169. /package/{src → packages}/database/migrations/0010_add_accessed_at_and_clean_tables.sql +0 -0
  170. /package/{src → packages}/database/migrations/0011_add_topic_history_summary.sql +0 -0
  171. /package/{src → packages}/database/migrations/0012_add_thread.sql +0 -0
  172. /package/{src → packages}/database/migrations/0013_add_ai_infra.sql +0 -0
  173. /package/{src → packages}/database/migrations/0014_add_message_reasoning.sql +0 -0
  174. /package/{src → packages}/database/migrations/0015_add_message_search_metadata.sql +0 -0
  175. /package/{src → packages}/database/migrations/0016_add_message_index.sql +0 -0
  176. /package/{src → packages}/database/migrations/0017_add_user_id_to_tables.sql +0 -0
  177. /package/{src → packages}/database/migrations/0018_add_client_id_for_entities.sql +0 -0
  178. /package/{src → packages}/database/migrations/0019_add_hotkey_user_settings.sql +0 -0
  179. /package/{src → packages}/database/migrations/0020_add_oidc.sql +0 -0
  180. /package/{src → packages}/database/migrations/0021_add_agent_opening_settings.sql +0 -0
  181. /package/{src → packages}/database/migrations/0022_add_documents.sql +0 -0
  182. /package/{src → packages}/database/migrations/0023_remove_param_and_doubao.sql +0 -0
  183. /package/{src → packages}/database/migrations/0024_add_rbac_tables.sql +0 -0
  184. /package/{src → packages}/database/migrations/0025_add_provider_config.sql +0 -0
  185. /package/{src → packages}/database/migrations/0026_add_autovacuum_tuning.sql +0 -0
  186. /package/{src → packages}/database/migrations/0027_ai_image.sql +0 -0
  187. /package/{src → packages}/database/migrations/meta/0000_snapshot.json +0 -0
  188. /package/{src → packages}/database/migrations/meta/0001_snapshot.json +0 -0
  189. /package/{src → packages}/database/migrations/meta/0002_snapshot.json +0 -0
  190. /package/{src → packages}/database/migrations/meta/0003_snapshot.json +0 -0
  191. /package/{src → packages}/database/migrations/meta/0004_snapshot.json +0 -0
  192. /package/{src → packages}/database/migrations/meta/0005_snapshot.json +0 -0
  193. /package/{src → packages}/database/migrations/meta/0006_snapshot.json +0 -0
  194. /package/{src → packages}/database/migrations/meta/0007_snapshot.json +0 -0
  195. /package/{src → packages}/database/migrations/meta/0008_snapshot.json +0 -0
  196. /package/{src → packages}/database/migrations/meta/0009_snapshot.json +0 -0
  197. /package/{src → packages}/database/migrations/meta/0010_snapshot.json +0 -0
  198. /package/{src → packages}/database/migrations/meta/0011_snapshot.json +0 -0
  199. /package/{src → packages}/database/migrations/meta/0012_snapshot.json +0 -0
  200. /package/{src → packages}/database/migrations/meta/0013_snapshot.json +0 -0
  201. /package/{src → packages}/database/migrations/meta/0014_snapshot.json +0 -0
  202. /package/{src → packages}/database/migrations/meta/0015_snapshot.json +0 -0
  203. /package/{src → packages}/database/migrations/meta/0016_snapshot.json +0 -0
  204. /package/{src → packages}/database/migrations/meta/0017_snapshot.json +0 -0
  205. /package/{src → packages}/database/migrations/meta/0018_snapshot.json +0 -0
  206. /package/{src → packages}/database/migrations/meta/0019_snapshot.json +0 -0
  207. /package/{src → packages}/database/migrations/meta/0020_snapshot.json +0 -0
  208. /package/{src → packages}/database/migrations/meta/0021_snapshot.json +0 -0
  209. /package/{src → packages}/database/migrations/meta/0022_snapshot.json +0 -0
  210. /package/{src → packages}/database/migrations/meta/0023_snapshot.json +0 -0
  211. /package/{src → packages}/database/migrations/meta/0024_snapshot.json +0 -0
  212. /package/{src → packages}/database/migrations/meta/0025_snapshot.json +0 -0
  213. /package/{src → packages}/database/migrations/meta/0026_snapshot.json +0 -0
  214. /package/{src → packages}/database/migrations/meta/0027_snapshot.json +0 -0
  215. /package/{src → packages}/database/migrations/meta/0028_snapshot.json +0 -0
  216. /package/{src → packages}/database/migrations/meta/0029_snapshot.json +0 -0
  217. /package/{src → packages}/database/migrations/meta/_journal.json +0 -0
  218. /package/{src/database → packages/database/src}/client/db.test.ts +0 -0
  219. /package/{src/database → packages/database/src}/client/pglite.ts +0 -0
  220. /package/{src/database → packages/database/src}/client/pglite.worker.ts +0 -0
  221. /package/{src/database → packages/database/src}/client/type.ts +0 -0
  222. /package/{src/database → packages/database/src}/models/__tests__/fixtures/embedding.ts +0 -0
  223. /package/{src/database → packages/database/src}/repositories/aiInfra/index.test.ts +0 -0
  224. /package/{src/database → packages/database/src}/repositories/dataExporter/index.test.ts +0 -0
  225. /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/agents.json +0 -0
  226. /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/agentsToSessions.json +0 -0
  227. /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/topic.json +0 -0
  228. /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/userSettings.json +0 -0
  229. /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/with-client-id.json +0 -0
  230. /package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/__tests__/fixtures/messages.json +0 -0
  231. /package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/__tests__/index.test.ts +0 -0
  232. /package/{src/database → packages/database/src}/schemas/_helpers.ts +0 -0
  233. /package/{src/database → packages/database/src}/schemas/apiKey.ts +0 -0
  234. /package/{src/database → packages/database/src}/schemas/asyncTask.ts +0 -0
  235. /package/{src/database → packages/database/src}/schemas/index.ts +0 -0
  236. /package/{src/database → packages/database/src}/schemas/nextauth.ts +0 -0
  237. /package/{src/database → packages/database/src}/schemas/oidc.ts +0 -0
  238. /package/{src/database → packages/database/src}/schemas/rag.ts +0 -0
  239. /package/{src/database → packages/database/src}/schemas/rbac.ts +0 -0
  240. /package/{src/database → packages/database/src}/schemas/user.ts +0 -0
  241. /package/{src/database → packages/database/src}/server/index.ts +0 -0
  242. /package/{src/database → packages/database/src}/server/models/ragEval/index.ts +0 -0
  243. /package/{src/database → packages/database/src}/type.ts +0 -0
  244. /package/{src/database → packages/database/src}/utils/genWhere.ts +0 -0
  245. /package/{src/database → packages/database/src}/utils/idGenerator.test.ts +0 -0
  246. /package/{tests → packages/database/tests}/setup-db.ts +0 -0
  247. /package/{src/utils → packages/types/src}/zustand.ts +0 -0
  248. /package/{src/utils → packages/utils/src}/__snapshots__/parseModels.test.ts.snap +0 -0
  249. /package/{src/utils → packages/utils/src}/_deprecated/__snapshots__/parseModels.test.ts.snap +0 -0
  250. /package/{src/utils → packages/utils/src}/_deprecated/parseModels.test.ts +0 -0
  251. /package/{src/utils → packages/utils/src}/_deprecated/parseModels.ts +0 -0
  252. /package/{src/utils → packages/utils/src}/apiKey.ts +0 -0
  253. /package/{src/utils → packages/utils/src}/basePath.ts +0 -0
  254. /package/{src/utils → packages/utils/src}/client/GlobalAgentContextManager.ts +0 -0
  255. /package/{src/utils → packages/utils/src}/client/downloadFile.ts +0 -0
  256. /package/{src/utils → packages/utils/src}/client/exportFile.ts +0 -0
  257. /package/{src/utils → packages/utils/src}/client/topic.ts +0 -0
  258. /package/{src/utils → packages/utils/src}/client/xor-obfuscation.test.ts +0 -0
  259. /package/{src/utils → packages/utils/src}/client/xor-obfuscation.ts +0 -0
  260. /package/{src/utils → packages/utils/src}/clientIP.test.ts +0 -0
  261. /package/{src/utils → packages/utils/src}/clientIP.ts +0 -0
  262. /package/{src/utils → packages/utils/src}/clipboard.ts +0 -0
  263. /package/{src/utils → packages/utils/src}/colorUtils.ts +0 -0
  264. /package/{src/utils → packages/utils/src}/compass.ts +0 -0
  265. /package/{src/utils → packages/utils/src}/compressImage.ts +0 -0
  266. /package/{src/utils → packages/utils/src}/difference.test.ts +0 -0
  267. /package/{src/utils → packages/utils/src}/difference.ts +0 -0
  268. /package/{src/utils → packages/utils/src}/electron/desktopRemoteRPCFetch.ts +0 -0
  269. /package/{src/utils → packages/utils/src}/env.ts +0 -0
  270. /package/{src/utils → packages/utils/src}/fetch/__tests__/parseError.test.ts +0 -0
  271. /package/{src/utils → packages/utils/src}/fetch/fetchEventSource/index.ts +0 -0
  272. /package/{src/utils → packages/utils/src}/fetch/fetchEventSource/parse.ts +0 -0
  273. /package/{src/utils → packages/utils/src}/fetch/headers.ts +0 -0
  274. /package/{src/utils → packages/utils/src}/fetch/index.ts +0 -0
  275. /package/{src/utils → packages/utils/src}/fetch/parseError.ts +0 -0
  276. /package/{src/utils → packages/utils/src}/fetch/request.ts +0 -0
  277. /package/{src/utils → packages/utils/src}/format.test.ts +0 -0
  278. /package/{src/utils → packages/utils/src}/format.ts +0 -0
  279. /package/{src/utils → packages/utils/src}/genOG.ts +0 -0
  280. /package/{src/utils → packages/utils/src}/getFallbackModelProperty.ts +0 -0
  281. /package/{src/utils → packages/utils/src}/imageToBase64.test.ts +0 -0
  282. /package/{src/utils → packages/utils/src}/imageToBase64.ts +0 -0
  283. /package/{src/utils → packages/utils/src}/isChunkingUnsupported.test.ts +0 -0
  284. /package/{src/utils → packages/utils/src}/isChunkingUnsupported.ts +0 -0
  285. /package/{src/utils → packages/utils/src}/keyboard.ts +0 -0
  286. /package/{src/utils → packages/utils/src}/localStorage.ts +0 -0
  287. /package/{src/utils → packages/utils/src}/locale.test.ts +0 -0
  288. /package/{src/utils → packages/utils/src}/merge.ts +0 -0
  289. /package/{src/utils → packages/utils/src}/number.test.ts +0 -0
  290. /package/{src/utils → packages/utils/src}/number.ts +0 -0
  291. /package/{src/utils → packages/utils/src}/object.ts +0 -0
  292. /package/{src/utils → packages/utils/src}/parseMarkdown.ts +0 -0
  293. /package/{src/utils → packages/utils/src}/parseModels.test.ts +0 -0
  294. /package/{src/utils → packages/utils/src}/pricing.test.ts +0 -0
  295. /package/{src/utils → packages/utils/src}/pricing.ts +0 -0
  296. /package/{src/utils → packages/utils/src}/promptTemplate.test.ts +0 -0
  297. /package/{src/utils → packages/utils/src}/promptTemplate.ts +0 -0
  298. /package/{src/utils → packages/utils/src}/safeParseJSON.test.ts +0 -0
  299. /package/{src/utils → packages/utils/src}/safeParseJSON.ts +0 -0
  300. /package/{src/utils → packages/utils/src}/sanitizeUTF8.ts +0 -0
  301. /package/{src/utils → packages/utils/src}/server/__tests__/auth.test.ts +0 -0
  302. /package/{src/utils → packages/utils/src}/server/auth.ts +0 -0
  303. /package/{src/utils → packages/utils/src}/server/correctOIDCUrl.ts +0 -0
  304. /package/{src/utils → packages/utils/src}/server/geo.ts +0 -0
  305. /package/{src/utils → packages/utils/src}/server/pageProps.ts +0 -0
  306. /package/{src/utils → packages/utils/src}/server/responsive.ts +0 -0
  307. /package/{src/utils → packages/utils/src}/server/routeVariants.ts +0 -0
  308. /package/{src/utils → packages/utils/src}/server/xor.ts +0 -0
  309. /package/{src/utils → packages/utils/src}/sleep.ts +0 -0
  310. /package/{src/utils → packages/utils/src}/storeDebug.test.ts +0 -0
  311. /package/{src/utils → packages/utils/src}/storeDebug.ts +0 -0
  312. /package/{src/utils → packages/utils/src}/time.test.ts +0 -0
  313. /package/{src/utils → packages/utils/src}/time.ts +0 -0
  314. /package/{src/utils → packages/utils/src}/tokenizer/client.ts +0 -0
  315. /package/{src/utils → packages/utils/src}/tokenizer/estimated.ts +0 -0
  316. /package/{src/utils → packages/utils/src}/tokenizer/index.ts +0 -0
  317. /package/{src/utils → packages/utils/src}/tokenizer/server.ts +0 -0
  318. /package/{src/utils → packages/utils/src}/tokenizer/tokenizer.worker.ts +0 -0
  319. /package/{src/utils → packages/utils/src}/toolCall.ts +0 -0
  320. /package/{src/utils → packages/utils/src}/toolManifest.ts +0 -0
  321. /package/{src/utils → packages/utils/src}/trace.ts +0 -0
  322. /package/{src/utils → packages/utils/src}/units.ts +0 -0
  323. /package/{src/utils → packages/utils/src}/uploadFIle.ts +0 -0
  324. /package/{src/utils → packages/utils/src}/url.ts +0 -0
  325. /package/{src/utils → packages/utils/src}/uuid.ts +0 -0
@@ -1,35 +1,35 @@
1
1
  import { template } from 'lodash-es';
2
2
 
3
- import { uuid } from '@/utils/uuid';
4
-
5
3
  import { useUserStore } from '@/store/user';
6
4
  import { userProfileSelectors } from '@/store/user/selectors';
7
5
 
6
+ import { uuid } from '../uuid';
7
+
8
8
  const placeholderVariablesRegex = /{{(.*?)}}/g;
9
9
 
10
10
  /* eslint-disable sort-keys-fix/sort-keys-fix */
11
11
  export const VARIABLE_GENERATORS = {
12
12
  /**
13
- * 时间类模板变量
14
- *
15
- * | Value | Example |
16
- * |-------|---------|
17
- * | `{{date}}` | 12/25/2023 |
18
- * | `{{datetime}}` | 12/25/2023, 2:30:45 PM |
19
- * | `{{day}}` | 25 |
20
- * | `{{hour}}` | 14 |
21
- * | `{{iso}}` | 2023-12-25T14:30:45.123Z |
22
- * | `{{locale}}` | zh-CN |
23
- * | `{{minute}}` | 30 |
24
- * | `{{month}}` | 12 |
25
- * | `{{second}}` | 45 |
26
- * | `{{time}}` | 2:30:45 PM |
27
- * | `{{timestamp}}` | 1703538645123 |
28
- * | `{{timezone}}` | America/New_York |
29
- * | `{{weekday}}` | Monday |
30
- * | `{{year}}` | 2023 |
31
- *
32
- */
13
+ * 时间类模板变量
14
+ *
15
+ * | Value | Example |
16
+ * |-------|---------|
17
+ * | `{{date}}` | 12/25/2023 |
18
+ * | `{{datetime}}` | 12/25/2023, 2:30:45 PM |
19
+ * | `{{day}}` | 25 |
20
+ * | `{{hour}}` | 14 |
21
+ * | `{{iso}}` | 2023-12-25T14:30:45.123Z |
22
+ * | `{{locale}}` | zh-CN |
23
+ * | `{{minute}}` | 30 |
24
+ * | `{{month}}` | 12 |
25
+ * | `{{second}}` | 45 |
26
+ * | `{{time}}` | 2:30:45 PM |
27
+ * | `{{timestamp}}` | 1703538645123 |
28
+ * | `{{timezone}}` | America/New_York |
29
+ * | `{{weekday}}` | Monday |
30
+ * | `{{year}}` | 2023 |
31
+ *
32
+ */
33
33
  date: () => new Date().toLocaleDateString(),
34
34
  datetime: () => new Date().toLocaleString(),
35
35
  day: () => new Date().getDate().toString().padStart(2, '0'),
@@ -46,65 +46,71 @@ export const VARIABLE_GENERATORS = {
46
46
  year: () => new Date().getFullYear().toString(),
47
47
 
48
48
  /**
49
- * 用户信息类模板变量
50
- *
51
- * | Value | Example |
52
- * |-------|---------|
53
- * | `{{email}}` | demo@lobehub.com |
54
- * | `{{nickname}}` | 社区版用户 |
55
- * | `{{username}}` | LobeChat |
56
- *
57
- */
49
+ * 用户信息类模板变量
50
+ *
51
+ * | Value | Example |
52
+ * |-------|---------|
53
+ * | `{{email}}` | demo@lobehub.com |
54
+ * | `{{nickname}}` | 社区版用户 |
55
+ * | `{{username}}` | LobeChat |
56
+ *
57
+ */
58
58
  email: () => userProfileSelectors.email(useUserStore.getState()) ?? '',
59
59
  nickname: () => userProfileSelectors.nickName(useUserStore.getState()) ?? '',
60
- username: () => userProfileSelectors.displayUserName(useUserStore.getState()) ?? userProfileSelectors.fullName(useUserStore.getState()) ?? '',
60
+ username: () =>
61
+ userProfileSelectors.displayUserName(useUserStore.getState()) ??
62
+ userProfileSelectors.fullName(useUserStore.getState()) ??
63
+ '',
61
64
 
62
65
  /**
63
- * 随机值类模板变量
64
- *
65
- * | Value | Example |
66
- * |-------|---------|
67
- * | `{{random}}` | 100041 |
68
- * | `{{random_bool}}` | true |
69
- * | `{{random_float}}` | 76.02 |
70
- * | `{{random_hex}}` | de0dbd |
71
- * | `{{random_int}}` | 68 |
72
- * | `{{random_string}}` | wqn9zfrqe7h |
73
- *
74
- */
66
+ * 随机值类模板变量
67
+ *
68
+ * | Value | Example |
69
+ * |-------|---------|
70
+ * | `{{random}}` | 100041 |
71
+ * | `{{random_bool}}` | true |
72
+ * | `{{random_float}}` | 76.02 |
73
+ * | `{{random_hex}}` | de0dbd |
74
+ * | `{{random_int}}` | 68 |
75
+ * | `{{random_string}}` | wqn9zfrqe7h |
76
+ *
77
+ */
75
78
  random: () => Math.floor(Math.random() * 1_000_000 + 1).toString(),
76
79
  random_bool: () => (Math.random() > 0.5 ? 'true' : 'false'),
77
80
  random_float: () => (Math.random() * 100).toFixed(2),
78
- random_hex: () => Math.floor(Math.random() * 16_777_215).toString(16).padStart(6, '0'),
81
+ random_hex: () =>
82
+ Math.floor(Math.random() * 16_777_215)
83
+ .toString(16)
84
+ .padStart(6, '0'),
79
85
  random_int: () => Math.floor(Math.random() * 100 + 1).toString(),
80
86
  random_string: () => Math.random().toString(36).slice(2, 15),
81
87
  random_digit: () => Math.floor(Math.random() * 10).toString(),
82
88
 
83
89
  /**
84
- * UUID 类模板变量
85
- *
86
- * | Value | Example |
87
- * |-------|---------|
88
- * | `{{uuid}}` | dd90b35-669f-4e87-beb8-ac6877f6995d |
89
- * | `{{uuid_short}}` | dd90b35 |
90
- *
91
- */
90
+ * UUID 类模板变量
91
+ *
92
+ * | Value | Example |
93
+ * |-------|---------|
94
+ * | `{{uuid}}` | dd90b35-669f-4e87-beb8-ac6877f6995d |
95
+ * | `{{uuid_short}}` | dd90b35 |
96
+ *
97
+ */
92
98
  uuid: () => uuid(),
93
99
  uuid_short: () => uuid().split('-')[0],
94
100
 
95
101
  /**
96
- * 平台类模板变量
97
- *
98
- * | Value | Example |
99
- * |-------|---------|
100
- * | `{{language}}` | zh-CN |
101
- * | `{{platform}}` | MacIntel |
102
- * | `{{user_agent}}` | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0 |
103
- *
104
- */
105
- language: () => typeof navigator !== 'undefined' ? navigator.language : '',
106
- platform: () => typeof navigator !== 'undefined' ? navigator.platform : '',
107
- user_agent: () => typeof navigator !== 'undefined' ? navigator.userAgent : '',
102
+ * 平台类模板变量
103
+ *
104
+ * | Value | Example |
105
+ * |-------|---------|
106
+ * | `{{language}}` | zh-CN |
107
+ * | `{{platform}}` | MacIntel |
108
+ * | `{{user_agent}}` | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0 |
109
+ *
110
+ */
111
+ language: () => (typeof navigator !== 'undefined' ? navigator.language : ''),
112
+ platform: () => (typeof navigator !== 'undefined' ? navigator.platform : ''),
113
+ user_agent: () => (typeof navigator !== 'undefined' ? navigator.userAgent : ''),
108
114
  } as Record<string, () => string>;
109
115
 
110
116
  /**
@@ -114,7 +120,7 @@ export const VARIABLE_GENERATORS = {
114
120
  */
115
121
  const extractPlaceholderVariables = (text: string): string[] => {
116
122
  const matches = [...text.matchAll(placeholderVariablesRegex)];
117
- return matches.map(m => m[1].trim());
123
+ return matches.map((m) => m[1].trim());
118
124
  };
119
125
 
120
126
  /**
@@ -132,7 +138,7 @@ export const parsePlaceholderVariables = (text: string, depth = 2): string => {
132
138
  const variables = Object.fromEntries(
133
139
  extractPlaceholderVariables(result)
134
140
  .map((key) => [key, VARIABLE_GENERATORS[key]?.()])
135
- .filter(([, value]) => value !== undefined)
141
+ .filter(([, value]) => value !== undefined),
136
142
  );
137
143
 
138
144
  const replaced = template(result, { interpolate: placeholderVariablesRegex })(variables);
@@ -153,7 +159,7 @@ export const parsePlaceholderVariables = (text: string, depth = 2): string => {
153
159
  * @returns 处理后的消息数组
154
160
  */
155
161
  export const parsePlaceholderVariablesMessages = (messages: any[]): any[] =>
156
- messages.map(message => {
162
+ messages.map((message) => {
157
163
  if (!message?.content) return message;
158
164
 
159
165
  const { content } = message;
@@ -167,11 +173,9 @@ export const parsePlaceholderVariablesMessages = (messages: any[]): any[] =>
167
173
  if (Array.isArray(content)) {
168
174
  return {
169
175
  ...message,
170
- content: content.map(item =>
171
- item?.type === 'text'
172
- ? { ...item, text: parsePlaceholderVariables(item.text) }
173
- : item
174
- )
176
+ content: content.map((item) =>
177
+ item?.type === 'text' ? { ...item, text: parsePlaceholderVariables(item.text) } : item,
178
+ ),
175
179
  };
176
180
  }
177
181
 
@@ -1,5 +1,5 @@
1
1
  import dayjs from 'dayjs';
2
- import { beforeAll, describe, expect, it } from 'vitest';
2
+ import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
3
3
 
4
4
  import { ChatTopic } from '@/types/topic';
5
5
 
@@ -1,3 +1,5 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+
1
3
  import compressImage from './compressImage';
2
4
 
3
5
  const getContextSpy = vi.spyOn(global.HTMLCanvasElement.prototype, 'getContext');
@@ -1,9 +1,8 @@
1
+ import { MESSAGE_CANCEL_FLAT } from '@lobechat/const';
2
+ import { ChatMessageError } from '@lobechat/types';
1
3
  import { afterEach, describe, expect, it, vi } from 'vitest';
2
4
 
3
- import { MESSAGE_CANCEL_FLAT } from '@/const/message';
4
- import { ChatMessageError } from '@/types/message';
5
- import { sleep } from '@/utils/sleep';
6
-
5
+ import { sleep } from '../../sleep';
7
6
  import { FetchEventSourceInit } from '../fetchEventSource';
8
7
  import { fetchEventSource } from '../fetchEventSource';
9
8
  import { fetchSSE } from '../fetchSSE';
@@ -15,8 +15,8 @@ import {
15
15
  } from '@/types/message';
16
16
  import { ChatImageChunk } from '@/types/message/image';
17
17
  import { GroundingSearch } from '@/types/search';
18
- import { nanoid } from '@/utils/uuid';
19
18
 
19
+ import { nanoid } from '../uuid';
20
20
  import { fetchEventSource } from './fetchEventSource';
21
21
  import { getMessageError } from './parseError';
22
22
 
@@ -1,4 +1,4 @@
1
- import { vi } from 'vitest';
1
+ import { describe, expect, it, vi } from 'vitest';
2
2
 
3
3
  import { getModelPropertyWithFallback } from './getFallbackModelProperty';
4
4
 
@@ -0,0 +1,5 @@
1
+ export * from './client/cookie';
2
+ export * from './getFallbackModelProperty';
3
+ export * from './imageToBase64';
4
+ export * from './safeParseJSON';
5
+ export * from './uuid';
@@ -2,7 +2,8 @@ import { resolveAcceptLanguage } from 'resolve-accept-language';
2
2
 
3
3
  import { DEFAULT_LANG } from '@/const/locale';
4
4
  import { Locales, locales, normalizeLocale } from '@/locales/resources';
5
- import { RouteVariants } from '@/utils/server/routeVariants';
5
+
6
+ import { RouteVariants } from './server/routeVariants';
6
7
 
7
8
  export const getAntdLocale = async (lang?: string) => {
8
9
  let normalLang: any = normalizeLocale(lang);
@@ -1,6 +1,4 @@
1
- import { expect } from 'vitest';
2
-
3
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { describe, expect, it } from 'vitest';
4
2
 
5
3
  import { mergeArrayById } from './merge';
6
4
 
@@ -1,8 +1,9 @@
1
1
  import { produce } from 'immer';
2
2
 
3
3
  import { AiFullModelCard, AiModelType } from '@/types/aiModel';
4
- import { getModelPropertyWithFallback } from '@/utils/getFallbackModelProperty';
5
- import { merge } from '@/utils/merge';
4
+
5
+ import { getModelPropertyWithFallback } from './getFallbackModelProperty';
6
+ import { merge } from './merge';
6
7
 
7
8
  /**
8
9
  * Parse model string to add or remove models.
@@ -1,4 +1,4 @@
1
- import { describe, expect, it, vi } from 'vitest';
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
2
 
3
3
  import { isArc, isSonomaOrLaterSafari } from './platform';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import UAParser from 'ua-parser-js';
2
2
 
3
- import { isOnServerSide } from '@/utils/env';
3
+ import { isOnServerSide } from './env';
4
4
 
5
5
  export const getParser = () => {
6
6
  if (isOnServerSide) return new UAParser('Node');
@@ -1,3 +1,5 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
1
3
  import { sanitizeUTF8 } from './sanitizeUTF8';
2
4
 
3
5
  describe('UTF-8 Sanitization', () => {
@@ -1,7 +1,7 @@
1
1
  import { geolocation } from '@vercel/functions';
2
2
  import { getCountry } from 'countries-and-timezones';
3
3
  import { NextRequest } from 'next/server';
4
- import { describe, expect, it, vi } from 'vitest';
4
+ import { afterEach, describe, expect, it, vi } from 'vitest';
5
5
 
6
6
  import { parseDefaultThemeFromCountry } from '../geo';
7
7
 
@@ -1,7 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { obfuscatePayloadWithXOR } from '@/utils/client/xor-obfuscation';
4
-
3
+ import { obfuscatePayloadWithXOR } from '../client/xor-obfuscation';
5
4
  import { getXorPayload } from './xor';
6
5
 
7
6
  describe('getXorPayload', () => {
@@ -1,4 +1,4 @@
1
- import { vi } from 'vitest';
1
+ import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import { pathString } from './url';
4
4
  import { inferContentTypeFromImageUrl, inferFileExtensionFromImageUrl, isLocalUrl } from './url';
@@ -0,0 +1,10 @@
1
+ // only inject in the dom environment
2
+ if (
3
+ // not node runtime
4
+ typeof window !== 'undefined' &&
5
+ // not edge runtime
6
+ typeof (globalThis as any).EdgeRuntime !== 'string'
7
+ ) {
8
+ // test with canvas
9
+ import('vitest-canvas-mock');
10
+ }
@@ -0,0 +1,16 @@
1
+ import { join, resolve } from 'node:path';
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ alias: {
7
+ /* eslint-disable sort-keys-fix/sort-keys-fix */
8
+ '@/types': resolve(__dirname, '../types/src'),
9
+ '@/const': resolve(__dirname, '../const/src'),
10
+ '@': resolve(__dirname, '../../src'),
11
+ /* eslint-enable */
12
+ },
13
+ environment: 'happy-dom',
14
+ setupFiles: join(__dirname, './tests/setup.ts'),
15
+ },
16
+ });
@@ -1,7 +1,7 @@
1
1
  import { pgGenerate } from 'drizzle-dbml-generator';
2
2
  import { join } from 'node:path';
3
3
 
4
- import * as schema from '../../src/database/schemas';
4
+ import * as schema from '../../packages/database/src/schemas';
5
5
 
6
6
  const out = join(__dirname, '../../docs/development/database-schema.dbml');
7
7
  const relational = true;
@@ -2,12 +2,12 @@ import { readMigrationFiles } from 'drizzle-orm/migrator';
2
2
  import { writeFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
 
5
- const dbBase = join(__dirname, '../../src/database');
5
+ const dbBase = join(__dirname, '../../packages/database');
6
6
  const migrationsFolder = join(dbBase, './migrations');
7
7
  const migrations = readMigrationFiles({ migrationsFolder: migrationsFolder });
8
8
 
9
9
  writeFileSync(
10
- join(dbBase, './client/migrations.json'),
10
+ join(dbBase, './src/core/migrations.json'),
11
11
  JSON.stringify(migrations, null, 2), // null, 2 adds indentation for better readability
12
12
  );
13
13
 
@@ -10,12 +10,12 @@ import { DB_FAIL_INIT_HINT, PGVECTOR_HINT } from './errorHint';
10
10
  // dotenv_config_path parameter that's passed to Node.js
11
11
  dotenv.config();
12
12
 
13
- const migrationsFolder = join(__dirname, '../../src/database/migrations');
13
+ const migrationsFolder = join(__dirname, '../../packages/database/migrations');
14
14
 
15
15
  const isDesktop = process.env.NEXT_PUBLIC_IS_DESKTOP_APP === '1';
16
16
 
17
17
  const runMigrations = async () => {
18
- const { serverDB } = await import('../../src/database/server');
18
+ const { serverDB } = await import('../../packages/database/src/server');
19
19
 
20
20
  if (process.env.DATABASE_DRIVER === 'node') {
21
21
  await nodeMigrate(serverDB, { migrationsFolder });
@@ -1,9 +1,9 @@
1
+ import { CreateNewEvalDatasets } from '@lobechat/types';
1
2
  import { Button, Form, Input } from '@lobehub/ui';
2
3
  import { memo, useState } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
4
5
 
5
6
  import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
6
- import { CreateNewEvalDatasets } from '@/types/eval';
7
7
 
8
8
  interface CreateFormProps {
9
9
  knowledgeBaseId: string;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { ProColumns, ProTable } from '@ant-design/pro-components';
4
+ import { EvalDatasetRecordRefFile } from '@lobechat/types';
4
5
  import { ActionIcon, Button, Text } from '@lobehub/ui';
5
6
  import { Upload } from 'antd';
6
7
  import { createStyles } from 'antd-style';
@@ -12,7 +13,6 @@ import { Center, Flexbox } from 'react-layout-kit';
12
13
  import FileIcon from '@/components/FileIcon';
13
14
  import { ragEvalService } from '@/services/ragEval';
14
15
  import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
15
- import { EvalDatasetRecordRefFile } from '@/types/eval';
16
16
 
17
17
  const createRequest = (activeDatasetId: number) => async () => {
18
18
  const records = await ragEvalService.getDatasetRecords(activeDatasetId);
@@ -1,10 +1,9 @@
1
+ import { RAGEvalDataSetItem } from '@lobechat/types';
1
2
  import { createStyles } from 'antd-style';
2
3
  import { parseAsInteger, useQueryState } from 'nuqs';
3
4
  import { memo } from 'react';
4
5
  import { Flexbox } from 'react-layout-kit';
5
6
 
6
- import { RAGEvalDataSetItem } from '@/types/eval';
7
-
8
7
  const useStyles = createStyles(({ css, token }) => ({
9
8
  active: css`
10
9
  background: ${token.colorFillTertiary};
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import { RAGEvalDataSetItem } from '@lobechat/types';
3
4
  import { ActionIcon } from '@lobehub/ui';
4
5
  import { PlusIcon } from 'lucide-react';
5
6
  import { memo } from 'react';
@@ -7,8 +8,6 @@ import { useTranslation } from 'react-i18next';
7
8
  import { Flexbox } from 'react-layout-kit';
8
9
  import { Virtuoso } from 'react-virtuoso';
9
10
 
10
- import { RAGEvalDataSetItem } from '@/types/eval';
11
-
12
11
  import Item from './Item';
13
12
 
14
13
  interface DatasetListProps {
@@ -1,9 +1,9 @@
1
+ import { CreateNewEvalEvaluation } from '@lobechat/types';
1
2
  import { Button, Form, Input, Select, TextArea } from '@lobehub/ui';
2
3
  import { memo, useState } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
4
5
 
5
6
  import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
6
- import { CreateNewEvalEvaluation } from '@/types/eval';
7
7
 
8
8
  interface CreateFormProps {
9
9
  knowledgeBaseId: string;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
4
+ import { EvalEvaluationStatus, RAGEvalEvaluationItem } from '@lobechat/types';
4
5
  import { ActionIcon, Button, ButtonProps, Icon } from '@lobehub/ui';
5
6
  import { App } from 'antd';
6
7
  import { createStyles } from 'antd-style';
@@ -12,7 +13,6 @@ import { Flexbox } from 'react-layout-kit';
12
13
 
13
14
  import { ragEvalService } from '@/services/ragEval';
14
15
  import { useKnowledgeBaseStore } from '@/store/knowledgeBase';
15
- import { EvalEvaluationStatus, RAGEvalEvaluationItem } from '@/types/eval';
16
16
 
17
17
  import CreateEvaluationButton from '../CreateEvaluation';
18
18
 
@@ -1,12 +1,11 @@
1
1
  'use client';
2
2
 
3
+ import { StoreApiWithSelector } from '@lobechat/types';
3
4
  import { createContext } from 'zustand-utils';
4
5
  import { subscribeWithSelector } from 'zustand/middleware';
5
6
  import { shallow } from 'zustand/shallow';
6
7
  import { createWithEqualityFn } from 'zustand/traditional';
7
8
 
8
- import { StoreApiWithSelector } from '@/utils/zustand';
9
-
10
9
  import { Store, store } from './action';
11
10
 
12
11
  export type { State } from './initialState';
@@ -1,5 +1,6 @@
1
1
  import { ModelProvider } from '@lobechat/model-runtime';
2
2
  import { chainAnswerWithContext } from '@lobechat/prompts';
3
+ import { EvalEvaluationStatus } from '@lobechat/types';
3
4
  import { TRPCError } from '@trpc/server';
4
5
  import OpenAI from 'openai';
5
6
  import { z } from 'zod';
@@ -17,7 +18,6 @@ import { asyncAuthedProcedure, asyncRouter as router } from '@/libs/trpc/async';
17
18
  import { initModelRuntimeWithUserPayload } from '@/server/modules/ModelRuntime';
18
19
  import { ChunkService } from '@/server/services/chunk';
19
20
  import { AsyncTaskError } from '@/types/asyncTask';
20
- import { EvalEvaluationStatus } from '@/types/eval';
21
21
 
22
22
  const ragEvalProcedure = asyncAuthedProcedure.use(async (opts) => {
23
23
  const { ctx } = opts;
@@ -1,4 +1,13 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
+ import {
3
+ EvalDatasetRecord,
4
+ EvalEvaluationStatus,
5
+ InsertEvalDatasetRecord,
6
+ RAGEvalDataSetItem,
7
+ insertEvalDatasetRecordSchema,
8
+ insertEvalDatasetsSchema,
9
+ insertEvalEvaluationSchema,
10
+ } from '@lobechat/types';
2
11
  import { TRPCError } from '@trpc/server';
3
12
  import dayjs from 'dayjs';
4
13
  import JSONL from 'jsonl-parse-stringify';
@@ -17,15 +26,6 @@ import { authedProcedure, router } from '@/libs/trpc/lambda';
17
26
  import { keyVaults, serverDatabase } from '@/libs/trpc/lambda/middleware';
18
27
  import { createAsyncCaller } from '@/server/routers/async';
19
28
  import { FileService } from '@/server/services/file';
20
- import {
21
- EvalDatasetRecord,
22
- EvalEvaluationStatus,
23
- InsertEvalDatasetRecord,
24
- RAGEvalDataSetItem,
25
- insertEvalDatasetRecordSchema,
26
- insertEvalDatasetsSchema,
27
- insertEvalEvaluationSchema,
28
- } from '@/types/eval';
29
29
 
30
30
  const ragEvalProcedure = authedProcedure
31
31
  .use(serverDatabase)
@@ -94,7 +94,7 @@ class ConfigService {
94
94
  data: any,
95
95
  mode: 'pglite' | 'postgres',
96
96
  ): Promise<ImportPgDataStructure> => {
97
- const { default: json } = await import('@/database/client/migrations.json');
97
+ const { default: json } = await import('@/database/core/migrations.json');
98
98
  const latestHash = json.at(-1)?.hash;
99
99
  if (!latestHash) {
100
100
  throw new Error('Not find database sql hash');
@@ -1,5 +1,3 @@
1
- import { lambdaClient } from '@/libs/trpc/client';
2
- import { uploadService } from '@/services/upload';
3
1
  import {
4
2
  CreateNewEvalDatasets,
5
3
  CreateNewEvalEvaluation,
@@ -7,7 +5,10 @@ import {
7
5
  RAGEvalDataSetItem,
8
6
  RAGEvalEvaluationItem,
9
7
  insertEvalDatasetsSchema,
10
- } from '@/types/eval';
8
+ } from '@lobechat/types';
9
+
10
+ import { lambdaClient } from '@/libs/trpc/client';
11
+ import { uploadService } from '@/services/upload';
11
12
 
12
13
  class RAGEvalService {
13
14
  // Dataset
@@ -1,3 +1,9 @@
1
+ import {
2
+ CreateNewEvalDatasets,
3
+ EvalDatasetRecord,
4
+ RAGEvalDataSetItem,
5
+ insertEvalDatasetRecordSchema,
6
+ } from '@lobechat/types';
1
7
  import { SWRResponse, mutate } from 'swr';
2
8
  import { StateCreator } from 'zustand/vanilla';
3
9
 
@@ -5,12 +11,6 @@ import { notification } from '@/components/AntdStaticMethods';
5
11
  import { useClientDataSWR } from '@/libs/swr';
6
12
  import { ragEvalService } from '@/services/ragEval';
7
13
  import { KnowledgeBaseStore } from '@/store/knowledgeBase/store';
8
- import {
9
- CreateNewEvalDatasets,
10
- EvalDatasetRecord,
11
- RAGEvalDataSetItem,
12
- insertEvalDatasetRecordSchema,
13
- } from '@/types/eval';
14
14
 
15
15
  const FETCH_DATASET_LIST_KEY = 'FETCH_DATASET_LIST';
16
16
  const FETCH_DATASET_RECORD_KEY = 'FETCH_DATASET_RECORD_KEY';
@@ -1,10 +1,10 @@
1
+ import { CreateNewEvalEvaluation, RAGEvalDataSetItem } from '@lobechat/types';
1
2
  import { SWRResponse, mutate } from 'swr';
2
3
  import { StateCreator } from 'zustand/vanilla';
3
4
 
4
5
  import { useClientDataSWR } from '@/libs/swr';
5
6
  import { ragEvalService } from '@/services/ragEval';
6
7
  import { KnowledgeBaseStore } from '@/store/knowledgeBase/store';
7
- import { CreateNewEvalEvaluation, RAGEvalDataSetItem } from '@/types/eval';
8
8
 
9
9
  const FETCH_EVALUATION_LIST_KEY = 'FETCH_EVALUATION_LIST_KEY';
10
10