@lobehub/chat 1.114.3 → 1.114.5
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.
- package/.github/scripts/docker-pr-comment.js +89 -0
- package/.github/workflows/docker-database.yml +21 -0
- package/.github/workflows/release.yml +7 -5
- package/.github/workflows/test.yml +9 -7
- package/CHANGELOG.md +50 -0
- package/Dockerfile.database +1 -1
- package/changelog/v1.json +18 -0
- package/codecov.yml +30 -2
- package/docs/development/database-schema.dbml +14 -0
- package/drizzle.config.ts +2 -2
- package/package.json +5 -5
- package/packages/const/src/index.ts +2 -0
- package/{src/utils → packages/const/src/settings}/genUserLLMConfig.test.ts +1 -1
- package/{src/utils → packages/const/src/settings}/genUserLLMConfig.ts +1 -1
- package/packages/const/src/settings/index.ts +0 -2
- package/packages/const/src/settings/llm.ts +1 -1
- package/{src → packages}/database/migrations/0028_oauth_handoffs.sql +1 -1
- package/{src → packages}/database/migrations/0029_add_apikey_manage.sql +1 -1
- package/packages/database/package.json +24 -0
- package/{src/database → packages/database/src}/client/db.ts +2 -2
- package/{src/database → packages/database/src}/core/db-adaptor.ts +3 -3
- package/{src/database → packages/database/src}/core/dbForTest.ts +1 -1
- package/{src/database → packages/database/src}/core/electron.ts +3 -3
- package/{src/database/client → packages/database/src/core}/migrations.json +12 -2
- package/{src/database → packages/database/src}/core/web-server.ts +2 -3
- package/{src/database → packages/database/src}/models/__tests__/_test_template.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/_util.ts +3 -3
- package/{src/database → packages/database/src}/models/__tests__/agent.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/aiModel.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/aiProvider.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/asyncTask.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/chunk.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/file.test.ts +1 -1
- package/{src/database → packages/database/src}/models/__tests__/generation.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/generationBatch.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/generationTopic.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/knowledgeBase.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/message.test.ts +2 -2
- package/{src/database → packages/database/src}/models/__tests__/plugin.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/session.test.ts +2 -2
- package/{src/database → packages/database/src}/models/__tests__/sessionGroup.test.ts +1 -2
- package/{src/database → packages/database/src}/models/__tests__/topic.test.ts +1 -2
- package/{src/database → packages/database/src}/models/_template.ts +1 -2
- package/{src/database → packages/database/src}/models/agent.ts +2 -2
- package/{src/database → packages/database/src}/models/aiModel.ts +1 -1
- package/{src/database → packages/database/src}/models/aiProvider.ts +1 -1
- package/{src/database → packages/database/src}/models/apiKey.ts +1 -1
- package/{src/database → packages/database/src}/models/asyncTask.ts +1 -1
- package/{src/database → packages/database/src}/models/chunk.ts +1 -1
- package/{src/database → packages/database/src}/models/document.ts +1 -1
- package/{src/database → packages/database/src}/models/drizzleMigration.ts +1 -1
- package/{src/database → packages/database/src}/models/embedding.ts +1 -1
- package/{src/database → packages/database/src}/models/file.ts +1 -1
- package/{src/database → packages/database/src}/models/generation.ts +1 -1
- package/{src/database → packages/database/src}/models/generationBatch.ts +1 -1
- package/{src/database → packages/database/src}/models/generationTopic.ts +1 -1
- package/{src/database → packages/database/src}/models/knowledgeBase.ts +1 -1
- package/{src/database → packages/database/src}/models/message.ts +3 -3
- package/{src/database → packages/database/src}/models/oauthHandoff.ts +1 -1
- package/{src/database → packages/database/src}/models/plugin.ts +1 -1
- package/{src/database → packages/database/src}/models/session.ts +3 -3
- package/{src/database → packages/database/src}/models/sessionGroup.ts +2 -2
- package/{src/database → packages/database/src}/models/thread.ts +1 -1
- package/{src/database → packages/database/src}/models/topic.ts +3 -3
- package/{src/database → packages/database/src}/models/user.ts +1 -1
- package/{src/database → packages/database/src}/repositories/aiInfra/index.ts +4 -3
- package/{src/database → packages/database/src}/repositories/dataExporter/index.ts +2 -2
- package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/index.test.ts +2 -2
- package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/index.ts +6 -5
- package/{src/database → packages/database/src}/repositories/dataImporter/index.ts +2 -2
- package/{src/database → packages/database/src}/repositories/tableViewer/index.test.ts +1 -1
- package/{src/database → packages/database/src}/repositories/tableViewer/index.ts +2 -1
- package/{src/database → packages/database/src}/schemas/agent.ts +1 -1
- package/{src/database → packages/database/src}/schemas/aiInfra.ts +3 -2
- package/{src/database → packages/database/src}/schemas/document.ts +2 -2
- package/{src/database → packages/database/src}/schemas/file.ts +1 -1
- package/{src/database → packages/database/src}/schemas/generation.ts +1 -1
- package/{src/database → packages/database/src}/schemas/message.ts +1 -1
- package/{src/database → packages/database/src}/schemas/ragEvals.ts +1 -1
- package/{src/database → packages/database/src}/schemas/relations.ts +1 -2
- package/{src/database → packages/database/src}/schemas/session.ts +1 -2
- package/{src/database → packages/database/src}/schemas/topic.ts +2 -2
- package/{src/database → packages/database/src}/server/models/__tests__/adapter.test.ts +5 -4
- package/{src/database → packages/database/src}/server/models/__tests__/nextauth.test.ts +4 -4
- package/{src/database → packages/database/src}/server/models/__tests__/user.test.ts +1 -2
- package/{src/database → packages/database/src}/server/models/ragEval/dataset.ts +3 -3
- package/{src/database → packages/database/src}/server/models/ragEval/datasetRecord.ts +3 -3
- package/{src/database → packages/database/src}/server/models/ragEval/evaluation.ts +3 -3
- package/{src/database → packages/database/src}/server/models/ragEval/evaluationRecord.ts +2 -2
- package/{src/database → packages/database/src}/utils/idGenerator.ts +4 -1
- package/{vitest.config.server.ts → packages/database/vitest.config.ts} +8 -7
- package/packages/model-runtime/package.json +1 -0
- package/packages/model-runtime/src/bfl/createImage.test.ts +4 -4
- package/packages/model-runtime/src/bfl/createImage.ts +1 -1
- package/packages/model-runtime/src/google/index.test.ts +1 -1
- package/packages/model-runtime/src/google/index.ts +1 -3
- package/packages/model-runtime/src/ollama/index.ts +3 -2
- package/packages/model-runtime/src/utils/anthropicHelpers.test.ts +2 -3
- package/packages/model-runtime/src/utils/anthropicHelpers.ts +1 -2
- package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +1 -1
- package/packages/model-runtime/src/utils/openaiHelpers.test.ts +2 -3
- package/packages/model-runtime/src/utils/openaiHelpers.ts +2 -2
- package/packages/model-runtime/src/utils/streams/bedrock/claude.ts +1 -2
- package/packages/model-runtime/src/utils/streams/bedrock/llama.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/bedrock/llama.ts +1 -2
- package/packages/model-runtime/src/utils/streams/google-ai.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/google-ai.ts +1 -1
- package/packages/model-runtime/src/utils/streams/ollama.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/ollama.ts +1 -1
- package/packages/model-runtime/src/utils/streams/protocol.ts +2 -2
- package/packages/model-runtime/src/utils/streams/vertex-ai.test.ts +1 -2
- package/packages/model-runtime/src/utils/streams/vertex-ai.ts +1 -1
- package/packages/model-runtime/vitest.config.ts +2 -0
- package/packages/types/src/index.ts +5 -0
- package/packages/utils/package.json +17 -0
- package/{src/utils → packages/utils/src}/client/cookie.test.ts +1 -3
- package/{src/utils → packages/utils/src}/client/cookie.ts +1 -1
- package/{src/utils → packages/utils/src}/client/parserPlaceholder.test.ts +2 -2
- package/{src/utils → packages/utils/src}/client/parserPlaceholder.ts +77 -73
- package/{src/utils → packages/utils/src}/client/topic.test.ts +1 -1
- package/{src/utils → packages/utils/src}/compressImage.test.ts +2 -0
- package/{src/utils → packages/utils/src}/fetch/__tests__/fetchSSE.test.ts +3 -4
- package/{src/utils → packages/utils/src}/fetch/fetchSSE.ts +1 -1
- package/{src/utils → packages/utils/src}/getFallbackModelProperty.test.ts +1 -1
- package/packages/utils/src/index.ts +5 -0
- package/{src/utils → packages/utils/src}/locale.ts +2 -1
- package/{src/utils → packages/utils/src}/merge.test.ts +1 -3
- package/{src/utils → packages/utils/src}/parseModels.ts +3 -2
- package/{src/utils → packages/utils/src}/platform.test.ts +1 -1
- package/{src/utils → packages/utils/src}/platform.ts +1 -1
- package/{src/utils → packages/utils/src}/sanitizeUTF8.test.ts +2 -0
- package/{src/utils → packages/utils/src}/server/__tests__/geo.test.ts +1 -1
- package/{src/utils → packages/utils/src}/server/xor.test.ts +1 -2
- package/{src/utils → packages/utils/src}/url.test.ts +1 -1
- package/packages/utils/tests/setup.ts +10 -0
- package/packages/utils/vitest.config.ts +16 -0
- package/scripts/dbmlWorkflow/index.ts +1 -1
- package/scripts/migrateClientDB/compile-migrations.ts +2 -2
- package/scripts/migrateServerDB/index.ts +2 -2
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/CreateDataset/CreateForm.tsx +1 -1
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetDetail/index.tsx +1 -1
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetList/Item.tsx +1 -2
- package/src/app/[variants]/(main)/repos/[id]/evals/dataset/DatasetList/index.tsx +1 -2
- package/src/app/[variants]/(main)/repos/[id]/evals/evaluation/CreateEvaluation/CreateForm.tsx +1 -1
- package/src/app/[variants]/(main)/repos/[id]/evals/evaluation/EvaluationList/index.tsx +1 -1
- package/src/config/aiModels/mistral.ts +2 -0
- package/src/features/AgentSetting/store/index.ts +1 -2
- package/src/server/routers/async/ragEval.ts +1 -1
- package/src/server/routers/lambda/ragEval.ts +9 -9
- package/src/services/config.ts +1 -1
- package/src/services/ragEval.ts +4 -3
- package/src/store/knowledgeBase/slices/ragEval/actions/dataset.ts +6 -6
- package/src/store/knowledgeBase/slices/ragEval/actions/evaluation.ts +1 -1
- package/src/store/serverConfig/store.ts +1 -1
- package/src/utils/client/switchLang.test.ts +2 -2
- package/src/utils/client/switchLang.ts +2 -3
- package/tests/setup.ts +0 -11
- package/tsconfig.json +2 -0
- package/vitest.config.ts +6 -2
- /package/{src → packages}/database/migrations/0000_init.sql +0 -0
- /package/{src → packages}/database/migrations/0001_add_client_id.sql +0 -0
- /package/{src → packages}/database/migrations/0002_amusing_puma.sql +0 -0
- /package/{src → packages}/database/migrations/0003_naive_echo.sql +0 -0
- /package/{src → packages}/database/migrations/0004_add_next_auth.sql +0 -0
- /package/{src → packages}/database/migrations/0005_pgvector.sql +0 -0
- /package/{src → packages}/database/migrations/0006_add_knowledge_base.sql +0 -0
- /package/{src → packages}/database/migrations/0007_fix_embedding_table.sql +0 -0
- /package/{src → packages}/database/migrations/0008_add_rag_evals.sql +0 -0
- /package/{src → packages}/database/migrations/0009_remove_unused_user_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0010_add_accessed_at_and_clean_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0011_add_topic_history_summary.sql +0 -0
- /package/{src → packages}/database/migrations/0012_add_thread.sql +0 -0
- /package/{src → packages}/database/migrations/0013_add_ai_infra.sql +0 -0
- /package/{src → packages}/database/migrations/0014_add_message_reasoning.sql +0 -0
- /package/{src → packages}/database/migrations/0015_add_message_search_metadata.sql +0 -0
- /package/{src → packages}/database/migrations/0016_add_message_index.sql +0 -0
- /package/{src → packages}/database/migrations/0017_add_user_id_to_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0018_add_client_id_for_entities.sql +0 -0
- /package/{src → packages}/database/migrations/0019_add_hotkey_user_settings.sql +0 -0
- /package/{src → packages}/database/migrations/0020_add_oidc.sql +0 -0
- /package/{src → packages}/database/migrations/0021_add_agent_opening_settings.sql +0 -0
- /package/{src → packages}/database/migrations/0022_add_documents.sql +0 -0
- /package/{src → packages}/database/migrations/0023_remove_param_and_doubao.sql +0 -0
- /package/{src → packages}/database/migrations/0024_add_rbac_tables.sql +0 -0
- /package/{src → packages}/database/migrations/0025_add_provider_config.sql +0 -0
- /package/{src → packages}/database/migrations/0026_add_autovacuum_tuning.sql +0 -0
- /package/{src → packages}/database/migrations/0027_ai_image.sql +0 -0
- /package/{src → packages}/database/migrations/meta/0000_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0001_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0002_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0003_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0004_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0005_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0006_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0007_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0008_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0009_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0010_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0011_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0012_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0013_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0014_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0015_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0016_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0017_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0018_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0019_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0020_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0021_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0022_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0023_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0024_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0025_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0026_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0027_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0028_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/0029_snapshot.json +0 -0
- /package/{src → packages}/database/migrations/meta/_journal.json +0 -0
- /package/{src/database → packages/database/src}/client/db.test.ts +0 -0
- /package/{src/database → packages/database/src}/client/pglite.ts +0 -0
- /package/{src/database → packages/database/src}/client/pglite.worker.ts +0 -0
- /package/{src/database → packages/database/src}/client/type.ts +0 -0
- /package/{src/database → packages/database/src}/models/__tests__/fixtures/embedding.ts +0 -0
- /package/{src/database → packages/database/src}/repositories/aiInfra/index.test.ts +0 -0
- /package/{src/database → packages/database/src}/repositories/dataExporter/index.test.ts +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/agents.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/agentsToSessions.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/topic.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/userSettings.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/__tests__/fixtures/with-client-id.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/__tests__/fixtures/messages.json +0 -0
- /package/{src/database → packages/database/src}/repositories/dataImporter/deprecated/__tests__/index.test.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/_helpers.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/apiKey.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/asyncTask.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/index.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/nextauth.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/oidc.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/rag.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/rbac.ts +0 -0
- /package/{src/database → packages/database/src}/schemas/user.ts +0 -0
- /package/{src/database → packages/database/src}/server/index.ts +0 -0
- /package/{src/database → packages/database/src}/server/models/ragEval/index.ts +0 -0
- /package/{src/database → packages/database/src}/type.ts +0 -0
- /package/{src/database → packages/database/src}/utils/genWhere.ts +0 -0
- /package/{src/database → packages/database/src}/utils/idGenerator.test.ts +0 -0
- /package/{tests → packages/database/tests}/setup-db.ts +0 -0
- /package/{src/utils → packages/types/src}/zustand.ts +0 -0
- /package/{src/utils → packages/utils/src}/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{src/utils → packages/utils/src}/_deprecated/__snapshots__/parseModels.test.ts.snap +0 -0
- /package/{src/utils → packages/utils/src}/_deprecated/parseModels.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/_deprecated/parseModels.ts +0 -0
- /package/{src/utils → packages/utils/src}/apiKey.ts +0 -0
- /package/{src/utils → packages/utils/src}/basePath.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/GlobalAgentContextManager.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/downloadFile.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/exportFile.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/topic.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/xor-obfuscation.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/client/xor-obfuscation.ts +0 -0
- /package/{src/utils → packages/utils/src}/clientIP.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/clientIP.ts +0 -0
- /package/{src/utils → packages/utils/src}/clipboard.ts +0 -0
- /package/{src/utils → packages/utils/src}/colorUtils.ts +0 -0
- /package/{src/utils → packages/utils/src}/compass.ts +0 -0
- /package/{src/utils → packages/utils/src}/compressImage.ts +0 -0
- /package/{src/utils → packages/utils/src}/difference.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/difference.ts +0 -0
- /package/{src/utils → packages/utils/src}/electron/desktopRemoteRPCFetch.ts +0 -0
- /package/{src/utils → packages/utils/src}/env.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/__tests__/parseError.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/fetchEventSource/index.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/fetchEventSource/parse.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/headers.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/index.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/parseError.ts +0 -0
- /package/{src/utils → packages/utils/src}/fetch/request.ts +0 -0
- /package/{src/utils → packages/utils/src}/format.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/format.ts +0 -0
- /package/{src/utils → packages/utils/src}/genOG.ts +0 -0
- /package/{src/utils → packages/utils/src}/getFallbackModelProperty.ts +0 -0
- /package/{src/utils → packages/utils/src}/imageToBase64.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/imageToBase64.ts +0 -0
- /package/{src/utils → packages/utils/src}/isChunkingUnsupported.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/isChunkingUnsupported.ts +0 -0
- /package/{src/utils → packages/utils/src}/keyboard.ts +0 -0
- /package/{src/utils → packages/utils/src}/localStorage.ts +0 -0
- /package/{src/utils → packages/utils/src}/locale.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/merge.ts +0 -0
- /package/{src/utils → packages/utils/src}/number.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/number.ts +0 -0
- /package/{src/utils → packages/utils/src}/object.ts +0 -0
- /package/{src/utils → packages/utils/src}/parseMarkdown.ts +0 -0
- /package/{src/utils → packages/utils/src}/parseModels.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/pricing.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/pricing.ts +0 -0
- /package/{src/utils → packages/utils/src}/promptTemplate.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/promptTemplate.ts +0 -0
- /package/{src/utils → packages/utils/src}/safeParseJSON.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/safeParseJSON.ts +0 -0
- /package/{src/utils → packages/utils/src}/sanitizeUTF8.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/__tests__/auth.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/auth.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/correctOIDCUrl.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/geo.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/pageProps.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/responsive.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/routeVariants.ts +0 -0
- /package/{src/utils → packages/utils/src}/server/xor.ts +0 -0
- /package/{src/utils → packages/utils/src}/sleep.ts +0 -0
- /package/{src/utils → packages/utils/src}/storeDebug.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/storeDebug.ts +0 -0
- /package/{src/utils → packages/utils/src}/time.test.ts +0 -0
- /package/{src/utils → packages/utils/src}/time.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/client.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/estimated.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/index.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/server.ts +0 -0
- /package/{src/utils → packages/utils/src}/tokenizer/tokenizer.worker.ts +0 -0
- /package/{src/utils → packages/utils/src}/toolCall.ts +0 -0
- /package/{src/utils → packages/utils/src}/toolManifest.ts +0 -0
- /package/{src/utils → packages/utils/src}/trace.ts +0 -0
- /package/{src/utils → packages/utils/src}/units.ts +0 -0
- /package/{src/utils → packages/utils/src}/uploadFIle.ts +0 -0
- /package/{src/utils → packages/utils/src}/url.ts +0 -0
- /package/{src/utils → packages/utils/src}/uuid.ts +0 -0
@@ -2,8 +2,7 @@
|
|
2
2
|
import { relations } from 'drizzle-orm';
|
3
3
|
import { pgTable, primaryKey, text, uuid, varchar } from 'drizzle-orm/pg-core';
|
4
4
|
|
5
|
-
import { createdAt } from '
|
6
|
-
|
5
|
+
import { createdAt } from './_helpers';
|
7
6
|
import { agents, agentsFiles, agentsKnowledgeBases } from './agent';
|
8
7
|
import { asyncTasks } from './asyncTask';
|
9
8
|
import { documentChunks, documents } from './document';
|
@@ -2,8 +2,7 @@
|
|
2
2
|
import { boolean, integer, pgTable, text, uniqueIndex, varchar } from 'drizzle-orm/pg-core';
|
3
3
|
import { createInsertSchema } from 'drizzle-zod';
|
4
4
|
|
5
|
-
import { idGenerator, randomSlug } from '
|
6
|
-
|
5
|
+
import { idGenerator, randomSlug } from '../utils/idGenerator';
|
7
6
|
import { timestamps } from './_helpers';
|
8
7
|
import { users } from './user';
|
9
8
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
import { boolean, jsonb, pgTable, primaryKey, text, uniqueIndex } from 'drizzle-orm/pg-core';
|
3
3
|
import { createInsertSchema } from 'drizzle-zod';
|
4
4
|
|
5
|
-
import { documents } from '@/database/schemas/document';
|
6
|
-
import { idGenerator } from '@/database/utils/idGenerator';
|
7
5
|
import { ChatTopicMetadata } from '@/types/topic';
|
8
6
|
|
7
|
+
import { idGenerator } from '../utils/idGenerator';
|
9
8
|
import { createdAt, timestamps, timestamptz } from './_helpers';
|
9
|
+
import { documents } from './document';
|
10
10
|
import { sessions } from './session';
|
11
11
|
import { users } from './user';
|
12
12
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { eq } from 'drizzle-orm';
|
2
2
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
3
3
|
|
4
|
-
import {
|
5
|
-
|
4
|
+
import { DrizzleAdapter } from '@/libs/oidc-provider/adapter';
|
5
|
+
|
6
|
+
import { getTestDBInstance } from '../../../core/dbForTest';
|
7
|
+
import { users } from '../../../schemas';
|
6
8
|
import {
|
7
9
|
oidcAccessTokens,
|
8
10
|
oidcClients,
|
@@ -10,8 +12,7 @@ import {
|
|
10
12
|
oidcInteractions,
|
11
13
|
oidcRefreshTokens,
|
12
14
|
oidcSessions,
|
13
|
-
} from '
|
14
|
-
import { DrizzleAdapter } from '@/libs/oidc-provider/adapter';
|
15
|
+
} from '../../../schemas/oidc';
|
15
16
|
|
16
17
|
let serverDB = await getTestDBInstance();
|
17
18
|
|
@@ -8,16 +8,16 @@ import type {
|
|
8
8
|
import { eq } from 'drizzle-orm';
|
9
9
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
10
10
|
|
11
|
-
import {
|
11
|
+
import { LobeNextAuthDbAdapter } from '@/libs/next-auth/adapter';
|
12
|
+
|
13
|
+
import { getTestDBInstance } from '../../../core/dbForTest';
|
12
14
|
import {
|
13
15
|
nextauthAccounts,
|
14
16
|
nextauthAuthenticators,
|
15
17
|
nextauthSessions,
|
16
18
|
nextauthVerificationTokens,
|
17
19
|
users,
|
18
|
-
} from '
|
19
|
-
import { LobeChatDatabase } from '@/database/type';
|
20
|
-
import { LobeNextAuthDbAdapter } from '@/libs/next-auth/adapter';
|
20
|
+
} from '../../../schemas';
|
21
21
|
|
22
22
|
let serverDB = await getTestDBInstance();
|
23
23
|
|
@@ -4,11 +4,10 @@ import { eq } from 'drizzle-orm';
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
5
5
|
|
6
6
|
import { INBOX_SESSION_ID } from '@/const/session';
|
7
|
-
import { getTestDBInstance } from '@/database/core/dbForTest';
|
8
|
-
import { LobeChatDatabase } from '@/database/type';
|
9
7
|
import { KeyVaultsGateKeeper } from '@/server/modules/KeyVaultsEncrypt';
|
10
8
|
import { UserGuide, UserPreference } from '@/types/user';
|
11
9
|
|
10
|
+
import { getTestDBInstance } from '../../../core/dbForTest';
|
12
11
|
import { SessionModel } from '../../../models/session';
|
13
12
|
import { UserModel, UserNotFoundError } from '../../../models/user';
|
14
13
|
import { UserSettingsItem, userSettings, users } from '../../../schemas';
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { RAGEvalDataSetItem } from '@lobechat/types';
|
1
2
|
import { and, desc, eq } from 'drizzle-orm';
|
2
3
|
|
3
|
-
import { NewEvalDatasetsItem, evalDatasets } from '
|
4
|
-
import { LobeChatDatabase } from '
|
5
|
-
import { RAGEvalDataSetItem } from '@/types/eval';
|
4
|
+
import { NewEvalDatasetsItem, evalDatasets } from '../../../schemas';
|
5
|
+
import { LobeChatDatabase } from '../../../type';
|
6
6
|
|
7
7
|
export class EvalDatasetModel {
|
8
8
|
private userId: string;
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { EvalDatasetRecordRefFile } from '@lobechat/types';
|
1
2
|
import { and, eq, inArray } from 'drizzle-orm';
|
2
3
|
|
3
|
-
import { NewEvalDatasetRecordsItem, evalDatasetRecords, files } from '
|
4
|
-
import { LobeChatDatabase } from '
|
5
|
-
import { EvalDatasetRecordRefFile } from '@/types/eval';
|
4
|
+
import { NewEvalDatasetRecordsItem, evalDatasetRecords, files } from '../../../schemas';
|
5
|
+
import { LobeChatDatabase } from '../../../type';
|
6
6
|
|
7
7
|
export class EvalDatasetRecordModel {
|
8
8
|
private userId: string;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { EvalEvaluationStatus, RAGEvalEvaluationItem } from '@lobechat/types';
|
1
2
|
import { SQL, and, count, desc, eq, inArray } from 'drizzle-orm';
|
2
3
|
|
3
4
|
import {
|
@@ -5,9 +6,8 @@ import {
|
|
5
6
|
evalDatasets,
|
6
7
|
evalEvaluation,
|
7
8
|
evaluationRecords,
|
8
|
-
} from '
|
9
|
-
import { LobeChatDatabase } from '
|
10
|
-
import { EvalEvaluationStatus, RAGEvalEvaluationItem } from '@/types/eval';
|
9
|
+
} from '../../../schemas';
|
10
|
+
import { LobeChatDatabase } from '../../../type';
|
11
11
|
|
12
12
|
export class EvalEvaluationModel {
|
13
13
|
private userId: string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { and, eq } from 'drizzle-orm';
|
2
2
|
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { LobeChatDatabase } from '../../../type';
|
4
|
+
import { NewEvaluationRecordsItem, evaluationRecords } from '../../../schemas';
|
5
5
|
|
6
6
|
export class EvaluationRecordModel {
|
7
7
|
private userId: string;
|
@@ -1,6 +1,9 @@
|
|
1
|
+
// generate('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 16); //=> "4f90d13a42"
|
2
|
+
import { customAlphabet } from 'nanoid/non-secure';
|
1
3
|
import { generate } from 'random-words';
|
2
4
|
|
3
|
-
|
5
|
+
export const createNanoId = (size = 8) =>
|
6
|
+
customAlphabet('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', size);
|
4
7
|
|
5
8
|
const prefixes = {
|
6
9
|
agents: 'agt',
|
@@ -5,9 +5,12 @@ export default defineConfig({
|
|
5
5
|
test: {
|
6
6
|
alias: {
|
7
7
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
8
|
-
'@/const': resolve(__dirname, '
|
9
|
-
'@/
|
10
|
-
'
|
8
|
+
'@/const': resolve(__dirname, '../const/src'),
|
9
|
+
'@/utils/errorResponse': resolve(__dirname, '../../src/utils/errorResponse'),
|
10
|
+
'@/utils': resolve(__dirname, '../utils/src'),
|
11
|
+
'@/database': resolve(__dirname, '../database/src'),
|
12
|
+
'@/types': resolve(__dirname, '../types/src'),
|
13
|
+
'@': resolve(__dirname, '../../src'),
|
11
14
|
/* eslint-enable */
|
12
15
|
},
|
13
16
|
coverage: {
|
@@ -15,18 +18,16 @@ export default defineConfig({
|
|
15
18
|
exclude: [
|
16
19
|
// https://github.com/lobehub/lobe-chat/pull/7265
|
17
20
|
...coverageConfigDefaults.exclude,
|
18
|
-
'src/
|
21
|
+
'src/server/core/dbForTest.ts',
|
19
22
|
],
|
20
|
-
include: ['src/
|
23
|
+
include: ['src/models/**/*.ts', 'src/server/**/*.ts'],
|
21
24
|
provider: 'v8',
|
22
25
|
reporter: ['text', 'json', 'lcov', 'text-summary'],
|
23
|
-
reportsDirectory: './coverage/server',
|
24
26
|
},
|
25
27
|
env: {
|
26
28
|
TEST_SERVER_DB: '1',
|
27
29
|
},
|
28
30
|
environment: 'node',
|
29
|
-
include: ['src/database/models/**/**/*.test.ts', 'src/database/server/**/**/*.test.ts'],
|
30
31
|
poolOptions: {
|
31
32
|
forks: {
|
32
33
|
singleFork: true,
|
@@ -7,7 +7,7 @@ import { createBflImage } from './createImage';
|
|
7
7
|
import { BflStatusResponse } from './types';
|
8
8
|
|
9
9
|
// Mock external dependencies
|
10
|
-
vi.mock('
|
10
|
+
vi.mock('@lobechat/utils', () => ({
|
11
11
|
imageUrlToBase64: vi.fn(),
|
12
12
|
}));
|
13
13
|
|
@@ -188,7 +188,7 @@ describe('createBflImage', () => {
|
|
188
188
|
it('should convert single imageUrl to image_prompt base64', async () => {
|
189
189
|
// Arrange
|
190
190
|
const { parseDataUri } = await import('../utils/uriParser');
|
191
|
-
const { imageUrlToBase64 } = await import('
|
191
|
+
const { imageUrlToBase64 } = await import('@lobechat/utils');
|
192
192
|
const { asyncifyPolling } = await import('../utils/asyncifyPolling');
|
193
193
|
|
194
194
|
const mockParseDataUri = vi.mocked(parseDataUri);
|
@@ -291,7 +291,7 @@ describe('createBflImage', () => {
|
|
291
291
|
it('should convert multiple imageUrls for Kontext models', async () => {
|
292
292
|
// Arrange
|
293
293
|
const { parseDataUri } = await import('../utils/uriParser');
|
294
|
-
const { imageUrlToBase64 } = await import('
|
294
|
+
const { imageUrlToBase64 } = await import('@lobechat/utils');
|
295
295
|
const { asyncifyPolling } = await import('../utils/asyncifyPolling');
|
296
296
|
|
297
297
|
const mockParseDataUri = vi.mocked(parseDataUri);
|
@@ -351,7 +351,7 @@ describe('createBflImage', () => {
|
|
351
351
|
it('should limit imageUrls to maximum 4 images', async () => {
|
352
352
|
// Arrange
|
353
353
|
const { parseDataUri } = await import('../utils/uriParser');
|
354
|
-
const { imageUrlToBase64 } = await import('
|
354
|
+
const { imageUrlToBase64 } = await import('@lobechat/utils');
|
355
355
|
const { asyncifyPolling } = await import('../utils/asyncifyPolling');
|
356
356
|
|
357
357
|
const mockParseDataUri = vi.mocked(parseDataUri);
|
@@ -1,7 +1,7 @@
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
1
2
|
import createDebug from 'debug';
|
2
3
|
|
3
4
|
import { RuntimeImageGenParamsValue } from '@/libs/standard-parameters/index';
|
4
|
-
import { imageUrlToBase64 } from '@/utils/imageToBase64';
|
5
5
|
|
6
6
|
import { AgentRuntimeErrorType } from '../error';
|
7
7
|
import { CreateImagePayload, CreateImageResponse } from '../types/image';
|
@@ -1,12 +1,12 @@
|
|
1
1
|
// @vitest-environment edge-runtime
|
2
2
|
import { GenerateContentResponse, Tool } from '@google/genai';
|
3
|
+
import * as imageToBase64Module from '@lobechat/utils';
|
3
4
|
import OpenAI from 'openai';
|
4
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
5
6
|
|
6
7
|
import { OpenAIChatMessage } from '@/libs/model-runtime';
|
7
8
|
import { CreateImagePayload } from '@/libs/model-runtime/types/image';
|
8
9
|
import { ChatStreamPayload } from '@/types/openai/chat';
|
9
|
-
import * as imageToBase64Module from '@/utils/imageToBase64';
|
10
10
|
|
11
11
|
import * as debugStreamModule from '../utils/debugStream';
|
12
12
|
import { LobeGoogleAI } from './index';
|
@@ -9,9 +9,7 @@ import {
|
|
9
9
|
Type as SchemaType,
|
10
10
|
ThinkingConfig,
|
11
11
|
} from '@google/genai';
|
12
|
-
|
13
|
-
import { imageUrlToBase64 } from '@/utils/imageToBase64';
|
14
|
-
import { safeParseJSON } from '@/utils/safeParseJSON';
|
12
|
+
import { imageUrlToBase64, safeParseJSON } from '@lobechat/utils';
|
15
13
|
|
16
14
|
import { LobeRuntimeAI } from '../BaseAI';
|
17
15
|
import { AgentRuntimeErrorType } from '../error';
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import { ChatModelCard } from '@lobechat/types';
|
1
2
|
import { Ollama, Tool } from 'ollama/browser';
|
2
3
|
import { ClientOptions } from 'openai';
|
3
4
|
|
4
|
-
import { ModelRequestOptions, OpenAIChatMessage } from '@/libs/model-runtime';
|
5
|
-
import { ChatModelCard } from '@/types/llm';
|
6
5
|
import { createErrorResponse } from '@/utils/errorResponse';
|
7
6
|
|
8
7
|
import { LobeRuntimeAI } from '../BaseAI';
|
@@ -13,6 +12,8 @@ import {
|
|
13
12
|
Embeddings,
|
14
13
|
EmbeddingsPayload,
|
15
14
|
ModelProvider,
|
15
|
+
ModelRequestOptions,
|
16
|
+
OpenAIChatMessage,
|
16
17
|
PullModelParams,
|
17
18
|
} from '../types';
|
18
19
|
import { AgentRuntimeError } from '../utils/createError';
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
1
2
|
import { OpenAI } from 'openai';
|
2
3
|
import { describe, expect, it, vi } from 'vitest';
|
3
4
|
|
4
|
-
import { imageUrlToBase64 } from '@/utils/imageToBase64';
|
5
|
-
|
6
5
|
import { OpenAIChatMessage, UserMessageContentPart } from '../types/chat';
|
7
6
|
import {
|
8
7
|
buildAnthropicBlock,
|
@@ -20,7 +19,7 @@ vi.mock('./uriParser', () => ({
|
|
20
19
|
type: 'base64',
|
21
20
|
}),
|
22
21
|
}));
|
23
|
-
vi.mock('
|
22
|
+
vi.mock('@lobechat/utils');
|
24
23
|
|
25
24
|
describe('anthropicHelpers', () => {
|
26
25
|
describe('buildAnthropicBlock', () => {
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
2
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
2
3
|
import OpenAI from 'openai';
|
3
4
|
|
4
|
-
import { imageUrlToBase64 } from '@/utils/imageToBase64';
|
5
|
-
|
6
5
|
import { OpenAIChatMessage, UserMessageContentPart } from '../types';
|
7
6
|
import { parseDataUri } from './uriParser';
|
8
7
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { getModelPropertyWithFallback } from '@lobechat/utils';
|
1
2
|
import dayjs from 'dayjs';
|
2
3
|
import utc from 'dayjs/plugin/utc';
|
3
4
|
import createDebug from 'debug';
|
@@ -7,7 +8,6 @@ import { Stream } from 'openai/streaming';
|
|
7
8
|
import { LOBE_DEFAULT_MODEL_LIST } from '@/config/aiModels';
|
8
9
|
import { RuntimeImageGenParamsValue } from '@/libs/standard-parameters/index';
|
9
10
|
import type { ChatModelCard } from '@/types/llm';
|
10
|
-
import { getModelPropertyWithFallback } from '@/utils/getFallbackModelProperty';
|
11
11
|
|
12
12
|
import { LobeRuntimeAI } from '../../BaseAI';
|
13
13
|
import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../../error';
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
1
2
|
import OpenAI from 'openai';
|
2
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
3
4
|
|
4
|
-
import { imageUrlToBase64 } from '@/utils/imageToBase64';
|
5
|
-
|
6
5
|
import {
|
7
6
|
convertImageUrlToFile,
|
8
7
|
convertMessageContent,
|
@@ -12,7 +11,7 @@ import {
|
|
12
11
|
import { parseDataUri } from './uriParser';
|
13
12
|
|
14
13
|
// 模拟依赖
|
15
|
-
vi.mock('
|
14
|
+
vi.mock('@lobechat/utils');
|
16
15
|
vi.mock('./uriParser');
|
17
16
|
|
18
17
|
describe('convertMessageContent', () => {
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { imageUrlToBase64 } from '@lobechat/utils';
|
1
2
|
import OpenAI, { toFile } from 'openai';
|
2
3
|
|
3
4
|
import { disableStreamModels, systemToUserModels } from '@/const/models';
|
4
5
|
import { ChatStreamPayload, OpenAIChatMessage } from '@/libs/model-runtime';
|
5
|
-
import { imageUrlToBase64 } from '@/utils/imageToBase64';
|
6
6
|
|
7
7
|
import { parseDataUri } from './uriParser';
|
8
8
|
|
@@ -103,7 +103,7 @@ export const convertOpenAIResponseInputs = async (
|
|
103
103
|
export const pruneReasoningPayload = (payload: ChatStreamPayload) => {
|
104
104
|
const shouldStream = !disableStreamModels.has(payload.model);
|
105
105
|
const { stream_options, ...cleanedPayload } = payload as any;
|
106
|
-
|
106
|
+
|
107
107
|
return {
|
108
108
|
...cleanedPayload,
|
109
109
|
frequency_penalty: 0,
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { InvokeModelWithResponseStreamResponse } from '@aws-sdk/client-bedrock-runtime';
|
2
|
-
|
3
|
-
import { nanoid } from '@/utils/uuid';
|
2
|
+
import { nanoid } from '@lobechat/utils';
|
4
3
|
|
5
4
|
import { ChatStreamCallbacks } from '../../../types';
|
6
5
|
import { transformAnthropicStream } from '../anthropic';
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { InvokeModelWithResponseStreamResponse } from '@aws-sdk/client-bedrock-runtime';
|
2
|
+
import * as uuidModule from '@lobechat/utils';
|
2
3
|
import { Readable } from 'stream';
|
3
4
|
import { describe, expect, it, vi } from 'vitest';
|
4
5
|
|
5
|
-
import * as uuidModule from '@/utils/uuid';
|
6
|
-
|
7
6
|
import { AWSBedrockLlamaStream } from './llama';
|
8
7
|
|
9
8
|
describe('AWSBedrockLlamaStream', () => {
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { GenerateContentResponse } from '@google/genai';
|
2
|
+
import * as uuidModule from '@lobechat/utils';
|
2
3
|
import { describe, expect, it, vi } from 'vitest';
|
3
4
|
|
4
|
-
import * as uuidModule from '@/utils/uuid';
|
5
|
-
|
6
5
|
import { GoogleGenerativeAIStream } from './google-ai';
|
7
6
|
|
8
7
|
describe('GoogleGenerativeAIStream', () => {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { GenerateContentResponse } from '@google/genai';
|
2
|
+
import { nanoid } from '@lobechat/utils';
|
2
3
|
|
3
4
|
import errorLocale from '@/locales/default/error';
|
4
5
|
import { ModelTokensUsage } from '@/types/message';
|
5
6
|
import { GroundingSearch } from '@/types/search';
|
6
|
-
import { nanoid } from '@/utils/uuid';
|
7
7
|
|
8
8
|
import { ChatStreamCallbacks } from '../../types';
|
9
9
|
import {
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import * as uuidModule from '@lobechat/utils';
|
1
2
|
import { ChatResponse } from 'ollama/browser';
|
2
3
|
import { describe, expect, it, vi } from 'vitest';
|
3
4
|
|
4
|
-
import * as uuidModule from '@/utils/uuid';
|
5
|
-
|
6
5
|
import { OllamaStream } from './ollama';
|
7
6
|
|
8
7
|
describe('OllamaStream', () => {
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import { nanoid, safeParseJSON } from '@lobechat/utils';
|
2
|
+
|
1
3
|
import { CitationItem, ModelSpeed, ModelTokensUsage } from '@/types/message';
|
2
|
-
import { safeParseJSON } from '@/utils/safeParseJSON';
|
3
|
-
import { nanoid } from '@/utils/uuid';
|
4
4
|
|
5
5
|
import { AgentRuntimeErrorType } from '../../error';
|
6
6
|
import { parseToolCalls } from '../../helpers';
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { GenerateContentResponse } from '@google/genai';
|
2
|
+
import { nanoid } from '@lobechat/utils';
|
2
3
|
|
3
4
|
import { ModelTokensUsage } from '@/types/message';
|
4
5
|
import { GroundingSearch } from '@/types/search';
|
5
|
-
import { nanoid } from '@/utils/uuid';
|
6
6
|
|
7
7
|
import { type GoogleAIStreamOptions } from './google-ai';
|
8
8
|
import {
|
@@ -7,6 +7,8 @@ export default defineConfig({
|
|
7
7
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
8
8
|
'@/libs/model-runtime': resolve(__dirname, './src'),
|
9
9
|
'@/types': resolve(__dirname, '../types/src'),
|
10
|
+
'@/utils/errorResponse': resolve(__dirname, '../../src/utils/errorResponse'),
|
11
|
+
'@/utils': resolve(__dirname, '../utils/src'),
|
10
12
|
'@/const': resolve(__dirname, '../const/src'),
|
11
13
|
'@': resolve(__dirname, '../../src'),
|
12
14
|
/* eslint-enable */
|
@@ -1,10 +1,15 @@
|
|
1
1
|
export * from './artifact';
|
2
2
|
export * from './chunk';
|
3
3
|
export * from './clientDB';
|
4
|
+
export * from './eval';
|
4
5
|
export * from './fetch';
|
5
6
|
export * from './knowledgeBase';
|
7
|
+
export * from './llm';
|
6
8
|
export * from './message';
|
9
|
+
export * from './user';
|
10
|
+
export * from './user/settings';
|
7
11
|
// FIXME: I think we need a refactor for the "openai" types
|
8
12
|
// it more likes the UI message payload
|
9
13
|
export * from './openai/chat';
|
10
14
|
export * from './trace';
|
15
|
+
export * from './zustand';
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name": "@lobechat/utils",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"private": true,
|
5
|
+
"main": "./src/index.ts",
|
6
|
+
"scripts": {
|
7
|
+
"test": "vitest",
|
8
|
+
"test:coverage": "vitest --coverage"
|
9
|
+
},
|
10
|
+
"dependencies": {
|
11
|
+
"@lobechat/const": "workspace:*",
|
12
|
+
"@lobechat/types": "workspace:*"
|
13
|
+
},
|
14
|
+
"devDependencies": {
|
15
|
+
"vitest-canvas-mock": "^0.3.3"
|
16
|
+
}
|
17
|
+
}
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import dayjs from 'dayjs';
|
2
2
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
3
3
|
|
4
|
-
import { COOKIE_CACHE_DAYS } from '
|
5
|
-
|
6
|
-
import { setCookie } from './cookie';
|
4
|
+
import { COOKIE_CACHE_DAYS, setCookie } from './cookie';
|
7
5
|
|
8
6
|
describe('setCookie', () => {
|
9
7
|
// Mock document.cookie since we're in a test environment
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { parsePlaceholderVariablesMessages } from './parserPlaceholder';
|
4
4
|
|
5
5
|
// Mock dependencies
|
6
|
-
vi.mock('
|
6
|
+
vi.mock('../uuid', () => ({
|
7
7
|
uuid: () => 'mocked-uuid-12345',
|
8
8
|
}));
|
9
9
|
|