mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
Compare commits
501 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1eaf28e498 | |||
| 5bfb876340 | |||
| 273e0277d1 | |||
| 4fb18ac6a8 | |||
| 74c8ef2686 | |||
| e35e3787c0 | |||
| c0e5a1d6e3 | |||
| abba6a9eff | |||
| 4ea45b18d0 | |||
| a21e71833b | |||
| dd9bbdc362 | |||
| 1a443e8d8a | |||
| 4a00672f9b | |||
| 3db2a39585 | |||
| 9a4939cca9 | |||
| 5c8b48efee | |||
| 6d3e5d1a80 | |||
| 67401c07aa | |||
| cf81abc909 | |||
| 13e936fbe0 | |||
| 8636fe45e3 | |||
| 1a77d9f9c6 | |||
| 8616977253 | |||
| 1e17da19d9 | |||
| 4349ad955d | |||
| 7d619cc0c1 | |||
| af003c5efa | |||
| d54113036a | |||
| 652e0ff415 | |||
| 800528d459 | |||
| b050bd7b9f | |||
| 0719f18af1 | |||
| c2dfed6f7b | |||
| 02566b1a95 | |||
| 8f9464acf8 | |||
| a21472724b | |||
| 20ef12443d | |||
| 4a24df9155 | |||
| dbec6b6776 | |||
| d9a4361994 | |||
| 1251548120 | |||
| 6b0f8eddb5 | |||
| 18e4c04fb9 | |||
| 785d5d7647 | |||
| c665646534 | |||
| ebd924c371 | |||
| b52183cdbf | |||
| 78a2f9e874 | |||
| 8f274aeba9 | |||
| 9146362c9b | |||
| 1c61b21133 | |||
| c14d165124 | |||
| 69817182a0 | |||
| 4099dfd955 | |||
| 48ad272f90 | |||
| 9352a9c80e | |||
| f02d43b8d3 | |||
| 6808099ce9 | |||
| 08347bbe01 | |||
| 47ec2d81dc | |||
| 541d0f46b2 | |||
| af3daa4022 | |||
| 58d34ff53f | |||
| b5389e44a2 | |||
| e827f286e6 | |||
| 7f60544950 | |||
| 116af84640 | |||
| 764fd4fa78 | |||
| f37ec1d4c2 | |||
| a94e8810a3 | |||
| 45b7a43170 | |||
| 7dc000e10c | |||
| f25fda6de2 | |||
| d2ff75cc05 | |||
| 8de927a419 | |||
| fe9d4afa05 | |||
| 54704b1247 | |||
| 65d2c0c2ea | |||
| 9f99b0bc2a | |||
| a78fc1fd24 | |||
| 4e0e99e503 | |||
| a0074fc280 | |||
| 6c01f21cec | |||
| 8f4a98fed0 | |||
| 70f52a3c1f | |||
| 8711ea244c | |||
| 255a89c9f3 | |||
| b8c4c4e927 | |||
| 54c0ac4426 | |||
| b7e7186229 | |||
| 0d1086fe55 | |||
| 9f044edd07 | |||
| 1762dc9148 | |||
| 2e928cd587 | |||
| 0ea738222d | |||
| 25a5be639a | |||
| e137b33c8d | |||
| 47c6e7fc17 | |||
| 046138b32c | |||
| c018f3d05b | |||
| 96ff5aa461 | |||
| 9f29869fd2 | |||
| e3afca3678 | |||
| b47bb5b3aa | |||
| cee555a0f0 | |||
| 28f84d5cb4 | |||
| d0063f809a | |||
| 5a4b0fd344 | |||
| 47874ac6c7 | |||
| dfdcdce298 | |||
| 72443783a1 | |||
| c21c14e715 | |||
| 46f2a28ee7 | |||
| 11ceb8b346 | |||
| 01103e7d1f | |||
| 37f7028c4c | |||
| d1f68c5b9f | |||
| 9568eafd76 | |||
| 66562170ac | |||
| ed42753fe5 | |||
| cc67b5443d | |||
| 20e026c9f1 | |||
| 240c7b7f4f | |||
| b73d0972b2 | |||
| d942a635b3 | |||
| a47ec04f20 | |||
| 20eb99534c | |||
| 96b9c9705a | |||
| 3f42ee3dfe | |||
| 0f9755bbd7 | |||
| 87ae85f7c7 | |||
| 04764ad1cb | |||
| e8044e3eca | |||
| e9412f146c | |||
| 6c72681b26 | |||
| 31d2cb8fd7 | |||
| 1cf371f418 | |||
| ebc205a8ae | |||
| 78eaead0d2 | |||
| 45fa4e01ae | |||
| 504b14dd3f | |||
| d753169b69 | |||
| cfb2246492 | |||
| 3a0b0d2173 | |||
| 7f1b631c35 | |||
| eca41d33bf | |||
| c8dea6322d | |||
| 2c677e597a | |||
| a1f7bff302 | |||
| e00ee6c6d1 | |||
| f89b73059d | |||
| 642dc3b6c9 | |||
| e33c84bcae | |||
| fd84da415b | |||
| dacfffdb63 | |||
| c38079d36f | |||
| cf0272cc1b | |||
| 35da7651b7 | |||
| b2c1209eb7 | |||
| 5e814e017d | |||
| 9a804b5df5 | |||
| 0d4264e9ad | |||
| 419557a2df | |||
| 8ba662c9de | |||
| 43a455549c | |||
| 58f1a52eb9 | |||
| 4b134968bf | |||
| 937dd85c6b | |||
| bed591c559 | |||
| 9089e2683e | |||
| 7fe17e4028 | |||
| 6ace931e52 | |||
| 76de2a20c1 | |||
| 4ee1d292ff | |||
| b6aad3b1bc | |||
| b980c3d702 | |||
| 987fbf2adf | |||
| 790af5ff40 | |||
| 3eaeb6c531 | |||
| aa841a3879 | |||
| a49422b322 | |||
| e3728750af | |||
| 26a743f3bd | |||
| bfbf38d106 | |||
| f8eb891d3b | |||
| 52ec64dfd4 | |||
| e6fc02eb9d | |||
| 575e334d7f | |||
| a4ed5a053f | |||
| dbb49337b4 | |||
| 8be822b0b7 | |||
| 5a999c0fbc | |||
| 9abeb7b545 | |||
| 8751141c7c | |||
| 3519cb20d9 | |||
| e135e2bb87 | |||
| a494af8e7f | |||
| ea819a3421 | |||
| b00e6d7817 | |||
| 58378fd10f | |||
| c0736ead54 | |||
| 9e0621f873 | |||
| 082898825c | |||
| 7832287abd | |||
| 5fe229c600 | |||
| 6b9337b8ae | |||
| b3856026d2 | |||
| 8dbcbd8c4b | |||
| a5b6aadc1f | |||
| 3690724751 | |||
| 6f87034303 | |||
| ae28f1794c | |||
| 68783fd2f7 | |||
| 9e43c1d6e0 | |||
| 4d5246acd8 | |||
| f813d0c429 | |||
| 1a75f4a6b5 | |||
| f4c3002b55 | |||
| e3aacfcdce | |||
| 67ad3c42cc | |||
| df2d001336 | |||
| a66856dc83 | |||
| e7036af61e | |||
| 86ff95ff15 | |||
| 926577302e | |||
| 38d9d98b97 | |||
| e2448eb091 | |||
| 5747239625 | |||
| d3544f90d3 | |||
| 3e537cd01d | |||
| 72e77b497c | |||
| 285e2f35f7 | |||
| 9b8435b024 | |||
| c7c4ab55b1 | |||
| 350e66a320 | |||
| f534d19338 | |||
| b15e90e1ae | |||
| 55079fc321 | |||
| 1080ff33aa | |||
| 837065f08a | |||
| 305e910e98 | |||
| 7e291c23f7 | |||
| 7634f511bf | |||
| 5e611f2fba | |||
| 411f88eca1 | |||
| 0e38ce159e | |||
| 27bcf18c4c | |||
| 298cd4f8c9 | |||
| 7bd25d96fe | |||
| 3d7ce4a18a | |||
| 56f55da260 | |||
| f456e91d7b | |||
| 2fa57ff557 | |||
| 3d671740a3 | |||
| 970ece0498 | |||
| c5ed5fdf2e | |||
| e8db8b9b99 | |||
| 759f30e5b7 | |||
| 43ef47c522 | |||
| d013a166ce | |||
| 86fc3912e0 | |||
| 6d438262b0 | |||
| e58864f361 | |||
| 9c2b411493 | |||
| da2c0a2c57 | |||
| 14ac6d1515 | |||
| 8b9fced111 | |||
| eea96605cf | |||
| 612866dea1 | |||
| a9c660c26e | |||
| 4813b6df27 | |||
| 0a1dcf943e | |||
| 9eec81c551 | |||
| b13563cb34 | |||
| ef79721828 | |||
| 20a53cbd34 | |||
| a76ad2344d | |||
| 58e19f856c | |||
| d1c5645517 | |||
| 0884747bb3 | |||
| 8169eae189 | |||
| 650e552aa8 | |||
| 11b27e5bf7 | |||
| a6367a5166 | |||
| 1224f4e4a7 | |||
| 1e1dbb7829 | |||
| 49fd419b72 | |||
| bad009a43c | |||
| 987e87ad8b | |||
| b36d8c7466 | |||
| 2590d72ae3 | |||
| c6038c0670 | |||
| 4ccf4c341b | |||
| c922ff2d68 | |||
| c15791d852 | |||
| 7ffb30713e | |||
| 18d2e6d50b | |||
| 2a5f8d712f | |||
| 82f5abf83b | |||
| 332e06ee6b | |||
| f1cddf9802 | |||
| 2525740b9d | |||
| a6b2a19b0e | |||
| 63760f9059 | |||
| 043e7da368 | |||
| f594fe16b1 | |||
| 0924d98f5e | |||
| dac5a6f22d | |||
| 44ffe14b9f | |||
| ddba451027 | |||
| bd5fb75efc | |||
| d7294ddebc | |||
| b0e163cb2b | |||
| 9f7677d560 | |||
| 999a63f648 | |||
| d8531ab120 | |||
| 099965a78f | |||
| 7c7de40007 | |||
| 5b043d81b1 | |||
| f326e8989e | |||
| 604234029c | |||
| a6d929bc2d | |||
| 54b6062c2e | |||
| 5d538a235a | |||
| 33050d6abe | |||
| 00822ef502 | |||
| 136bc5a917 | |||
| 3e1b360186 | |||
| cc882be4ef | |||
| ce623bb280 | |||
| e56e475331 | |||
| 41d7efcf54 | |||
| 58b73ecc95 | |||
| b25b5a0657 | |||
| c65eb095ba | |||
| 323425bd90 | |||
| 4cb831c15a | |||
| b7111be400 | |||
| 548c4e2ac2 | |||
| 1dc82d0184 | |||
| 09ce90a35a | |||
| 2071d27335 | |||
| c4fd337288 | |||
| 276e7d7bb4 | |||
| dbcec3d07e | |||
| 85f9ca5c40 | |||
| 34f88cdaab | |||
| 5d4ed11ad6 | |||
| 9250540912 | |||
| 0220e81a92 | |||
| d9024085ed | |||
| 2f3bf0fedf | |||
| 30bb028a09 | |||
| 3ac3b8304e | |||
| d6a3a26e4d | |||
| e09817e7a6 | |||
| df5d0d07f9 | |||
| eafe75bc20 | |||
| 23dcf4c617 | |||
| 3fa2573207 | |||
| 68727985d1 | |||
| d3dad7973d | |||
| 64b969ec35 | |||
| 3336dca328 | |||
| 8737f675f4 | |||
| 836546f235 | |||
| 7164b4c9ab | |||
| 82abf6d7d0 | |||
| 4b3f8d4abb | |||
| 5989a022dd | |||
| de9d479f28 | |||
| f900f7ce4e | |||
| d847e44ef7 | |||
| 4872cc1c41 | |||
| 27a4b34612 | |||
| dbeca5da70 | |||
| b836d0398d | |||
| ccdbbb927e | |||
| 8d479074fd | |||
| 5cbf9136ff | |||
| 17472aa7a5 | |||
| 0778fb5548 | |||
| 2eeab57c1e | |||
| a397a4eed7 | |||
| 885fbbe024 | |||
| 26c2dd68de | |||
| be388b8433 | |||
| afd05a2364 | |||
| 74d9bb5b6a | |||
| c9a65f78c5 | |||
| 9832bf758b | |||
| 9a6657e52e | |||
| 45f05a0169 | |||
| 29137c74d1 | |||
| 1eb64328e8 | |||
| 0efe28d122 | |||
| 33611397b2 | |||
| 0a398a8f82 | |||
| 1a2aa249fb | |||
| 6100d21038 | |||
| ccc733dac5 | |||
| c7e94e7446 | |||
| d4eb117b0c | |||
| 915c0ff5d7 | |||
| a47347d95a | |||
| c9163bc9e8 | |||
| 8dedc2d3e1 | |||
| af1f71572f | |||
| 7e68cc5b5a | |||
| 91e081885c | |||
| 3ae5134984 | |||
| df97d76c36 | |||
| 95246c5ee2 | |||
| 133fd564f1 | |||
| 9ec3315595 | |||
| d07e2acae8 | |||
| 499a9ca53e | |||
| 9f1069a51f | |||
| c576b971ad | |||
| 1a71188a1d | |||
| 79c81bb954 | |||
| 1ee6724168 | |||
| f36f6f7724 | |||
| 6d214d7bef | |||
| 4d7a060268 | |||
| 64a5d51f87 | |||
| 88c8c2dc12 | |||
| ce4969698b | |||
| 3c408e444b | |||
| ffa9b1b909 | |||
| fcc32d5e0a | |||
| 07a9b341b4 | |||
| b4b00f7c70 | |||
| 78a6483630 | |||
| ab043d45f2 | |||
| 1b8b86d8a5 | |||
| 927055871b | |||
| 7562bf4acf | |||
| 2564ebd6d5 | |||
| a00fd9d236 | |||
| 24a5e0d419 | |||
| a7b9bcd78f | |||
| 5689dd8656 | |||
| 519e03e87a | |||
| 6ac6ca59da | |||
| 4d164ae083 | |||
| 5cab2ee5b5 | |||
| 65dddfa47f | |||
| dfa2a2c279 | |||
| d82e7bb9b0 | |||
| 3fbbfc6d96 | |||
| faefe71c9a | |||
| 30a4734577 | |||
| 9e7bea6d88 | |||
| d0ceab9dd6 | |||
| 09055595e4 | |||
| 86a28d9615 | |||
| 164c8b344e | |||
| 9b354af18c | |||
| 62f5a1b93c | |||
| 2e9ad20675 | |||
| 15e15e84ca | |||
| 05cb6bb7de | |||
| a1c66c81fc | |||
| c1ddb6fa23 | |||
| 439fb6eb9d | |||
| 27d48e89e9 | |||
| 54b08fd139 | |||
| 8e2d47d595 | |||
| 75bde54d95 | |||
| b69e75cfca | |||
| 1d466e514f | |||
| a51b33f154 | |||
| 485e6cf47e | |||
| b0d59f8b1b | |||
| 8ceb25f8c2 | |||
| 1fae49042d | |||
| 96ae8034fb | |||
| b3120167ce | |||
| 51ad3998e4 | |||
| 6435935f10 | |||
| 45f71478c4 | |||
| 0a724aae32 | |||
| 1cf4355e94 | |||
| 74a702a5ff | |||
| 6c83807218 | |||
| e5eb7a280d | |||
| a21c05bf64 | |||
| 1e61e79034 | |||
| 4556bdf1c2 | |||
| dbc4b10837 | |||
| 0f10efcb5d | |||
| 68aad95c04 | |||
| 7b12e54646 | |||
| e10a433610 | |||
| 327a56474e | |||
| abb93a6f79 | |||
| d861bb0421 | |||
| 7f00b530fa | |||
| 4cefafd5c5 | |||
| 135c9bea7f |
@@ -0,0 +1,183 @@
|
||||
---
|
||||
description: Complete guide for adding a new AI provider documentation to LobeChat
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Adding New AI Provider Documentation
|
||||
|
||||
This document provides a step-by-step guide for adding documentation for a new AI provider to LobeChat, based on the complete workflow used for adding providers like BFL (Black Forest Labs) and FAL.
|
||||
|
||||
## Overview
|
||||
|
||||
Adding a new provider requires creating both user-facing documentation and technical configuration files. The process involves:
|
||||
|
||||
1. Creating usage documentation (EN + CN)
|
||||
2. Adding environment variable documentation (EN + CN)
|
||||
3. Updating Docker configuration files
|
||||
4. Updating .env.example file
|
||||
5. Preparing image resources
|
||||
|
||||
## Step 1: Create Provider Usage Documentation
|
||||
|
||||
Create user-facing documentation that explains how to use the new provider.
|
||||
|
||||
### Required Files
|
||||
|
||||
Create both English and Chinese versions:
|
||||
- `docs/usage/providers/{provider-name}.mdx` (English)
|
||||
- `docs/usage/providers/{provider-name}.zh-CN.mdx` (Chinese)
|
||||
|
||||
### Documentation Structure
|
||||
|
||||
Follow the structure and format used in existing provider documentation. For reference, see:
|
||||
- `docs/usage/providers/fal.mdx` (English template)
|
||||
- `docs/usage/providers/fal.zh-CN.mdx` (Chinese template)
|
||||
|
||||
### Key Requirements
|
||||
|
||||
- **Images**: Prepare 5-6 screenshots showing the process
|
||||
- **Cover Image**: Create or obtain a cover image for the provider
|
||||
- **Accurate URLs**: Use real registration and dashboard URLs
|
||||
- **Service Type**: Specify whether it's for image generation, text generation, etc.
|
||||
- **Pricing Warning**: Include pricing information callout
|
||||
|
||||
### Important Notes
|
||||
|
||||
- **🔒 API Key Security**: Never include real API keys in documentation. Always use placeholder format (e.g., `bfl-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`)
|
||||
- **🖼️ Image Hosting**: Use LobeHub's CDN for all images: `hub-apac-1.lobeobjects.space`
|
||||
|
||||
## Step 2: Update Environment Variables Documentation
|
||||
|
||||
Add the new provider's environment variables to the self-hosting documentation.
|
||||
|
||||
### Files to Update
|
||||
|
||||
- `docs/self-hosting/environment-variables/model-provider.mdx` (English)
|
||||
- `docs/self-hosting/environment-variables/model-provider.zh-CN.mdx` (Chinese)
|
||||
|
||||
### Content to Add
|
||||
|
||||
Add two sections for each provider:
|
||||
|
||||
```markdown
|
||||
### `{PROVIDER}_API_KEY`
|
||||
|
||||
- Type: Required
|
||||
- Description: This is the API key you applied for in the {Provider Name} service.
|
||||
- Default: -
|
||||
- Example: `{api-key-format-example}`
|
||||
|
||||
### `{PROVIDER}_MODEL_LIST`
|
||||
|
||||
- Type: Optional
|
||||
- Description: Used to control the {Provider Name} model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model. Separate multiple entries with commas. The definition syntax follows the same rules as other providers' model lists.
|
||||
- Default: `-`
|
||||
- Example: `-all,+{model-id-1},+{model-id-2}={display-name}`
|
||||
|
||||
The above example disables all models first, then enables `{model-id-1}` and `{model-id-2}` (displayed as `{display-name}`).
|
||||
|
||||
[model-list]: /docs/self-hosting/advanced/model-list
|
||||
```
|
||||
|
||||
### Important Notes
|
||||
|
||||
- **API Key Format**: Use proper UUID format for examples (e.g., `12345678-1234-1234-1234-123456789abc`)
|
||||
- **Real Model IDs**: Use actual model IDs from the codebase, not placeholders
|
||||
- **Consistent Naming**: Follow the pattern `{PROVIDER}_API_KEY` and `{PROVIDER}_MODEL_LIST`
|
||||
|
||||
## Step 3: Update Docker Configuration Files
|
||||
|
||||
Add environment variables to all Docker configuration files to ensure the provider works in containerized deployments.
|
||||
|
||||
### Files to Update
|
||||
|
||||
All Dockerfile variants must be updated:
|
||||
- `Dockerfile`
|
||||
- `Dockerfile.database`
|
||||
- `Dockerfile.pglite`
|
||||
|
||||
### Changes Required
|
||||
|
||||
Add the new provider's environment variables at the **end** of the ENV section, just before the final line:
|
||||
|
||||
```dockerfile
|
||||
# Previous providers...
|
||||
# 302.AI
|
||||
AI302_API_KEY="" AI302_MODEL_LIST="" \
|
||||
# {New Provider 1}
|
||||
{PROVIDER1}_API_KEY="" {PROVIDER1}_MODEL_LIST="" \
|
||||
# {New Provider 2}
|
||||
{PROVIDER2}_API_KEY="" {PROVIDER2}_MODEL_LIST=""
|
||||
```
|
||||
|
||||
### Important Rules
|
||||
|
||||
- **Position**: Add new providers at the **end** of the list
|
||||
- **Ordering**: When adding multiple providers, use alphabetical order (e.g., FAL before BFL)
|
||||
- **Consistency**: Maintain identical ordering across all Dockerfile variants
|
||||
- **Format**: Follow the pattern `{PROVIDER}_API_KEY="" {PROVIDER}_MODEL_LIST="" \`
|
||||
|
||||
## Step 4: Update .env.example File
|
||||
|
||||
Add example configuration entries to help users understand how to configure the provider locally.
|
||||
|
||||
### File to Update
|
||||
|
||||
- `.env.example`
|
||||
|
||||
### Content to Add
|
||||
|
||||
Add new sections before the "Market Service" section:
|
||||
|
||||
```bash
|
||||
### {Provider Name} ###
|
||||
|
||||
# {PROVIDER}_API_KEY={provider-prefix}-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
```
|
||||
|
||||
### Format Guidelines
|
||||
|
||||
- **Section Header**: Use `### {Provider Name} ###` format
|
||||
- **Commented Example**: Use `#` to comment out the example
|
||||
- **Key Format**: Use appropriate prefix for the provider (e.g., `bfl-`, `fal-`, `sk-`)
|
||||
- **Position**: Add before the Market Service section
|
||||
- **Spacing**: Maintain consistent spacing with existing entries
|
||||
|
||||
## Step 5: Image Resources
|
||||
|
||||
Prepare all necessary image resources for the documentation.
|
||||
|
||||
### Required Images
|
||||
|
||||
1. **Cover Image**: Provider logo or branded image
|
||||
2. **API Dashboard Screenshots**: 3-4 screenshots showing API key creation process
|
||||
3. **LobeChat Configuration Screenshots**: 2-3 screenshots showing provider setup in LobeChat
|
||||
|
||||
### Image Guidelines
|
||||
|
||||
- **Quality**: Use high-resolution screenshots
|
||||
- **Consistency**: Maintain consistent styling across all screenshots
|
||||
- **Privacy**: Remove or blur any sensitive information
|
||||
- **Format**: Use PNG format for screenshots
|
||||
- **Hosting**: Use LobeHub's CDN (`hub-apac-1.lobeobjects.space`) for all images
|
||||
|
||||
## Checklist
|
||||
|
||||
Before submitting your provider documentation:
|
||||
|
||||
- [ ] Created both English and Chinese usage documentation
|
||||
- [ ] Added environment variable documentation (EN + CN)
|
||||
- [ ] Updated all 3 Dockerfile variants with consistent ordering
|
||||
- [ ] Updated .env.example with proper key format
|
||||
- [ ] Prepared all required screenshots and images
|
||||
- [ ] Used actual model IDs from the codebase
|
||||
- [ ] Verified no real API keys are included in documentation
|
||||
- [ ] Used LobeHub CDN for all image hosting
|
||||
- [ ] Tested the documentation for clarity and accuracy
|
||||
|
||||
## Reference
|
||||
|
||||
This guide was created based on the implementation of BFL (Black Forest Labs) provider documentation. For a complete example, refer to:
|
||||
- Commits: `d2da03e1a` (documentation) and `6a2e95868` (environment variables)
|
||||
- Files: `docs/usage/providers/bfl.mdx`, `docs/usage/providers/bfl.zh-CN.mdx`
|
||||
- PR: Current branch `tj/feat/bfl-docs`
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
description: 包含添加 debug 日志请求时
|
||||
globs:
|
||||
description: 包含添加 console.log 日志请求时
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# Debug 包使用指南
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
---
|
||||
description: Debug 调试指南
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# Debug 调试指南
|
||||
|
||||
## 💡 调试流程概览
|
||||
|
||||
当遇到问题时,请按照以下优先级进行处理:
|
||||
|
||||
1. **快速判断** - 对于熟悉的错误,直接提供解决方案
|
||||
2. **信息收集** - 使用工具搜索相关代码和配置
|
||||
3. **网络搜索** - 查找现有解决方案
|
||||
4. **定位调试** - 添加日志进行问题定位
|
||||
5. **临时方案** - 如果找不到根本解决方案,提供临时解决方案
|
||||
6. **解决实施** - 提供可维护的最终解决方案
|
||||
|
||||
## 🔍 错误信息分析
|
||||
|
||||
### 错误来源识别
|
||||
|
||||
错误信息可能来自:
|
||||
|
||||
- **Terminal 输出** - 构建、运行时错误
|
||||
- **浏览器控制台** - 前端 JavaScript 错误
|
||||
- **开发工具** - ESLint、TypeScript、测试框架等
|
||||
- **服务器日志** - API、数据库连接等后端错误
|
||||
- **截图或文本** - 用户直接提供的错误信息
|
||||
|
||||
## 🛠️ 信息收集工具
|
||||
|
||||
### 代码搜索工具
|
||||
|
||||
使用以下工具收集相关信息,并根据场景选择最合适的工具:
|
||||
|
||||
- **`codebase_search` (语义搜索)**
|
||||
- **何时使用**: 当你不确定具体的代码实现,想要寻找相关概念、功能或逻辑时。
|
||||
- **示例**: `查询"文件上传"功能的实现`
|
||||
- **`grep_search` (精确/正则搜索)**
|
||||
- **何时使用**: 当你知道要查找的确切字符串、函数名、变量名或一个特定的模式时。
|
||||
- **示例**: `查找所有使用了 'useState' 的地方`
|
||||
- **`file_search` (文件搜索)**
|
||||
- **何时使用**: 当你知道文件名的一部分,需要快速定位文件时。
|
||||
- **示例**: `查找 'Button.tsx' 组件`
|
||||
- **`read_file` (内容读取)**
|
||||
- **何时使用**: 在定位到具体文件后,用于查看其完整内容和上下文。
|
||||
- **`web_search` (网络搜索)**
|
||||
- **何时使用**: 当错误信息可能与第三方库、API 或常见问题相关时,用于获取外部信息。
|
||||
|
||||
### 环境与依赖检查
|
||||
|
||||
- **检查 `package.json`**: 查看 `scripts` 了解项目如何运行、构建和测试。查看 `dependencies` 和 `devDependencies` 确认库版本,版本冲突有时是问题的根源。
|
||||
- **运行测试**: 使用 `ni vitest` 运行单元测试和集成测试,这可以快速定位功能回归或组件错误。
|
||||
|
||||
### 项目特定搜索目标
|
||||
|
||||
针对 lobe-chat 项目,重点关注:
|
||||
|
||||
- **配置文件**: [package.json](mdc:package.json), [next.config.mjs](mdc:next.config.mjs)
|
||||
- **核心功能**: `src/features/` 下的相关模块
|
||||
- **状态管理**: `src/store/` 下的 Zustand stores
|
||||
- **数据库**: `src/database/` 和 `src/migrations/`
|
||||
- **类型定义**: `src/types/` 下的类型文件
|
||||
- **服务层**: `src/services/` 下的 API 服务
|
||||
- **启动流程**: [apps/desktop/src/main/core/App.ts](mdc:apps/desktop/src/main/core/App.ts) - 了解应用启动流程
|
||||
|
||||
## 🌐 网络搜索策略
|
||||
|
||||
### 搜索顺序优先级
|
||||
|
||||
1. **和问题相关的项目的 github issue**
|
||||
|
||||
2. **技术社区**
|
||||
- Stack Overflow
|
||||
- GitHub Discussions
|
||||
- Reddit
|
||||
|
||||
3. **官方文档**
|
||||
- 使用 `mcp_context7_resolve-library-id` 和 `mcp_context7_get-library-docs` 工具
|
||||
- 查阅官方文档网站
|
||||
|
||||
### 搜索关键词策略
|
||||
|
||||
- **错误信息**: 完整的错误消息
|
||||
- **技术栈**: "Next.js 15" + "error message"
|
||||
- **上下文**: 添加功能相关的关键词
|
||||
|
||||
## 🔧 问题定位与结构化思考
|
||||
|
||||
如果问题比较复杂,我们要按照先定位问题,再解决问题的大方向进行。
|
||||
|
||||
### 结构化思考工具
|
||||
|
||||
对于复杂或多步骤的调试任务,使用 `mcp_sequential-thinking_sequentialthinking` 工具来结构化思考过程。这有助于:
|
||||
|
||||
- **分解问题**: 将大问题拆解成可管理的小步骤。
|
||||
- **清晰追踪**: 记录每一步的发现和决策,避免遗漏。
|
||||
- **自我修正**: 在过程中评估和调整调试路径。
|
||||
|
||||
### 日志调试
|
||||
|
||||
在问题产生的路径上添加日志,可以简单使用 `console.log` 或者参考 [debug-usage.mdc](mdc:.cursor/rules/debug-usage.mdc) 使用 `debug` 模块。添加完日志后,请求我运行相关的代码并提供关键输出和错误信息。
|
||||
|
||||
### 引导式交互调试
|
||||
|
||||
虽然我无法直接操作浏览器开发者工具,但我可以引导你进行交互式调试:
|
||||
|
||||
1. **设置断点**: 我会告诉你可以在哪些关键代码行设置断点。
|
||||
2. **检查变量**: 我会请你在断点处检查特定变量的值或 `props`/`state`。
|
||||
3. **分析调用栈**: 我会请你提供调用栈信息,以帮助理解代码执行流程。
|
||||
|
||||
## 💡 临时解决方案策略
|
||||
|
||||
当无法找到根本解决方案时,提供临时解决方案:
|
||||
|
||||
### 临时方案准则
|
||||
|
||||
- **快速修复** - 优先让功能可用
|
||||
- **最小修改** - 减少对现有代码的影响
|
||||
- **清晰标记** - 明确标注这是临时方案
|
||||
- **后续计划** - 说明后续如何找到更好的解决方案
|
||||
|
||||
### 临时方案模板
|
||||
|
||||
```markdown
|
||||
## 临时解决方案 ⚠️
|
||||
|
||||
**问题**: [简要描述问题]
|
||||
|
||||
**临时修复**:
|
||||
[具体的临时修复步骤]
|
||||
|
||||
**风险说明**:
|
||||
|
||||
- [可能的副作用或限制]
|
||||
- [需要注意的事项]
|
||||
|
||||
**后续计划**:
|
||||
|
||||
- [ ] 深入调研根本原因
|
||||
- [ ] 寻找更优雅的解决方案
|
||||
- [ ] 监控是否有其他影响
|
||||
```
|
||||
|
||||
## ✅ 解决方案准则
|
||||
|
||||
### 方案质量标准
|
||||
|
||||
提供的解决方案应该:
|
||||
|
||||
- **✅ 低侵入性** - 最小化对现有代码的修改
|
||||
- **✅ 可维护性** - 易于理解和后续维护
|
||||
- **✅ 类型安全** - 符合 TypeScript 规范
|
||||
- **✅ 最佳实践** - 遵循项目的编码规范
|
||||
- **✅ 测试友好** - 便于编写和运行测试
|
||||
- **❌ 避免长期 Hack** - 临时方案可以 hack,但要明确标注
|
||||
|
||||
### 解决方案模板
|
||||
|
||||
```markdown
|
||||
## 问题原因
|
||||
|
||||
[简要说明问题产生的根本原因]
|
||||
|
||||
## 解决方案
|
||||
|
||||
[详细的解决步骤]
|
||||
|
||||
## 代码修改
|
||||
|
||||
[具体的代码变更]
|
||||
|
||||
## 验证方法
|
||||
|
||||
[如何验证问题已解决]
|
||||
|
||||
## 预防措施
|
||||
|
||||
[如何避免类似问题再次发生]
|
||||
```
|
||||
|
||||
## 🔄 迭代调试流程
|
||||
|
||||
如果初次解决方案无效:
|
||||
|
||||
1. **重新收集信息** - 基于新的错误信息搜索
|
||||
2. **深入代码分析** - 查看更多相关代码文件
|
||||
3. **运行相关测试** - 编写或运行一个失败的测试来稳定复现问题。
|
||||
4. **扩大搜索范围** - 搜索更广泛的相关问题
|
||||
5. **请求更多日志** - 添加更详细的调试信息
|
||||
6. **提供临时方案** - 如果根本解决方案复杂,先提供临时修复
|
||||
7. **分解问题** - 将复杂问题拆解为更小的子问题
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
description: Explain how group chat works in LobeHub (Multi-agent orchestratoin)
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
This rule explains how group chat (multi-agent orchestration) works. Not confused with session group, which is a organization method to manage session.
|
||||
|
||||
## Key points
|
||||
|
||||
- A supervisor will devide who and how will speak next
|
||||
- Each agent will speak just like in single chat (if was asked to speak)
|
||||
- Not coufused with session group
|
||||
|
||||
## Related Files
|
||||
|
||||
- src/store/chat/slices/message/supervisor.ts
|
||||
- src/store/chat/slices/aiChat/actions/generateAIGroupChat.ts
|
||||
- src/prompts/groupChat/index.ts (All prompts here)
|
||||
|
||||
## Snippets
|
||||
|
||||
```tsx
|
||||
// Detect whether in group chat
|
||||
const isGroupSession = useSessionStore(sessionSelectors.isCurrentSessionGroupSession);
|
||||
|
||||
// Member actions
|
||||
const addAgentsToGroup = useChatGroupStore((s) => s.addAgentsToGroup);
|
||||
const removeAgentFromGroup = useChatGroupStore((s) => s.removeAgentFromGroup);
|
||||
const persistReorder = useChatGroupStore((s) => s.reorderGroupMembers);
|
||||
|
||||
// Get group info
|
||||
const groupConfig = useChatGroupStore(chatGroupSelectors.currentGroupConfig);
|
||||
const currentGroupMemebers = useSessionStore(sessionSelectors.currentGroupAgents);
|
||||
```
|
||||
+95
-93
@@ -2,117 +2,115 @@
|
||||
globs: *.tsx
|
||||
alwaysApply: false
|
||||
---
|
||||
# LobeChat 国际化指南
|
||||
# LobeChat Internationalization Guide
|
||||
|
||||
## 架构概览
|
||||
## Key Points
|
||||
|
||||
LobeChat 使用 react-i18next 进行国际化,采用良好的命名空间架构:
|
||||
- Default language: Chinese (zh-CN) as the source language
|
||||
- Supported languages: 18 languages including English, Japanese, Korean, Arabic, etc.
|
||||
- Framework: react-i18next with Next.js app router
|
||||
- Translation automation: @lobehub/i18n-cli for automatic translation, config file: .i18nrc.js
|
||||
- Never manually modify any json file. You can only modify files in `default` folder
|
||||
|
||||
- 默认语言:中文(zh-CN),作为源语言
|
||||
- 支持语言:18 种语言,包括英语、日语、韩语、阿拉伯语等
|
||||
- 框架:react-i18next 配合 Next.js app router
|
||||
- 翻译自动化:@lobehub/i18n-cli 用于自动翻译,配置文件:.i18nrc.js
|
||||
|
||||
## 目录结构
|
||||
## Directory Structure
|
||||
|
||||
```
|
||||
src/locales/
|
||||
├── default/ # 源语言文件(zh-CN)
|
||||
│ ├── index.ts # 命名空间导出
|
||||
│ ├── common.ts # 通用翻译
|
||||
│ ├── chat.ts # 聊天相关翻译
|
||||
│ ├── setting.ts # 设置翻译
|
||||
│ └── ... # 其他命名空间文件
|
||||
└── resources.ts # 类型定义和语言配置
|
||||
├── default/ # Source language files (zh-CN)
|
||||
│ ├── index.ts # Namespace exports
|
||||
│ ├── common.ts # Common translations
|
||||
│ ├── chat.ts # Chat-related translations
|
||||
│ ├── setting.ts # Settings translations
|
||||
│ └── ... # Other namespace files
|
||||
└── resources.ts # Type definitions and language configuration
|
||||
|
||||
locales/ # 翻译文件
|
||||
├── en-US/ # 英语翻译
|
||||
│ ├── common.json # 通用翻译
|
||||
│ ├── chat.json # 聊天翻译
|
||||
│ ├── setting.json # 设置翻译
|
||||
│ └── ... # 其他命名空间 JSON 文件
|
||||
├── ja-JP/ # 日语翻译
|
||||
locales/ # Translation files
|
||||
├── en-US/ # English translations
|
||||
│ ├── common.json # Common translations
|
||||
│ ├── chat.json # Chat translations
|
||||
│ ├── setting.json # Settings translations
|
||||
│ └── ... # Other namespace JSON files
|
||||
├── ja-JP/ # Japanese translations
|
||||
│ ├── common.json
|
||||
│ ├── chat.json
|
||||
│ └── ...
|
||||
└── ... # 其他语言文件夹
|
||||
└── ... # Other language folders
|
||||
```
|
||||
|
||||
## 添加新翻译的工作流程
|
||||
## Workflow for Adding New Translations
|
||||
|
||||
### 1. 添加新的翻译键
|
||||
### 1. Adding New Translation Keys
|
||||
|
||||
第一步:在 src/locales/default 目录下的相应命名空间文件中添加翻译键
|
||||
Step 1: Add translation keys in the corresponding namespace files under src/locales/default directory
|
||||
|
||||
```typescript
|
||||
// 示例:src/locales/default/common.ts
|
||||
// Example: src/locales/default/common.ts
|
||||
export default {
|
||||
// ... 现有键
|
||||
newFeature: {
|
||||
title: "新功能标题",
|
||||
description: "功能描述文案",
|
||||
button: "操作按钮",
|
||||
},
|
||||
// ... existing keys
|
||||
newFeature: {
|
||||
title: '新功能标题',
|
||||
description: '功能描述文案',
|
||||
button: '操作按钮',
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
第二步:如果创建新命名空间,需要在 src/locales/default/index.ts 中导出
|
||||
Step 2: If creating a new namespace, export it in src/locales/default/index.ts
|
||||
|
||||
```typescript
|
||||
import newNamespace from "./newNamespace";
|
||||
import newNamespace from './newNamespace';
|
||||
|
||||
const resources = {
|
||||
// ... 现有命名空间
|
||||
newNamespace,
|
||||
// ... existing namespaces
|
||||
newNamespace,
|
||||
} as const;
|
||||
```
|
||||
|
||||
### 2. 翻译过程
|
||||
### 2. Translation Process
|
||||
|
||||
开发模式:
|
||||
Development mode:
|
||||
|
||||
一般情况下不需要你帮我跑自动翻译工具,跑一次很久,需要的时候我会自己跑。
|
||||
但是为了立马能看到效果,还是需要先翻译 `locales/zh-CN/namespace.json`,不需要翻译其它语言。
|
||||
Generally, you don't need to help me run the automatic translation tool as it takes a long time. I'll run it myself when needed. However, to see immediate results, you still need to translate `locales/zh-CN/namespace.json` first, no need to translate other languages.
|
||||
|
||||
生产模式:
|
||||
Production mode:
|
||||
|
||||
```bash
|
||||
# 为所有语言生成翻译
|
||||
# Generate translations for all languages
|
||||
npm run i18n
|
||||
```
|
||||
|
||||
## 在组件中使用
|
||||
## Usage in Components
|
||||
|
||||
### 基本用法
|
||||
### Basic Usage
|
||||
|
||||
```tsx
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const MyComponent = () => {
|
||||
const { t } = useTranslation("common");
|
||||
const { t } = useTranslation('common');
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t("newFeature.title")}</h1>
|
||||
<p>{t("newFeature.description")}</p>
|
||||
<button>{t("newFeature.button")}</button>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<h1>{t('newFeature.title')}</h1>
|
||||
<p>{t('newFeature.description')}</p>
|
||||
<button>{t('newFeature.button')}</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### 带参数的用法
|
||||
### Usage with Parameters
|
||||
|
||||
```tsx
|
||||
const { t } = useTranslation("common");
|
||||
const { t } = useTranslation('common');
|
||||
|
||||
<p>{t("welcome.message", { name: "John" })}</p>;
|
||||
<p>{t('welcome.message', { name: 'John' })}</p>;
|
||||
|
||||
// 对应的语言文件:
|
||||
// welcome: { message: '欢迎 {{name}} 使用!' }
|
||||
// Corresponding language file:
|
||||
// welcome: { message: 'Welcome {{name}}!' }
|
||||
```
|
||||
|
||||
### 多个命名空间
|
||||
### Multiple Namespaces
|
||||
|
||||
```tsx
|
||||
const { t } = useTranslation(['common', 'chat']);
|
||||
@@ -121,59 +119,63 @@ const { t } = useTranslation(['common', 'chat']);
|
||||
<span>{t('chat:typing')}</span>
|
||||
```
|
||||
|
||||
## 类型安全
|
||||
## Type Safety
|
||||
|
||||
项目使用 TypeScript 实现类型安全的翻译,类型从 src/locales/resources.ts 自动生成:
|
||||
The project uses TypeScript to implement type-safe translations, with types automatically generated from src/locales/resources.ts:
|
||||
|
||||
```typescript
|
||||
import type { DefaultResources, NS, Locales } from "@/locales/resources";
|
||||
import type { DefaultResources, Locales, NS } from '@/locales/resources';
|
||||
|
||||
// 可用类型:
|
||||
// - NS: 可用命名空间键 ('common' | 'chat' | 'setting' | ...)
|
||||
// - Locales: 支持的语言代码 ('en-US' | 'zh-CN' | 'ja-JP' | ...)
|
||||
// Available types:
|
||||
// - NS: Available namespace keys ('common' | 'chat' | 'setting' | ...)
|
||||
// - Locales: Supported language codes ('en-US' | 'zh-CN' | 'ja-JP' | ...)
|
||||
|
||||
const namespace: NS = "common";
|
||||
const locale: Locales = "en-US";
|
||||
const namespace: NS = 'common';
|
||||
const locale: Locales = 'en-US';
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
## Best Practices
|
||||
|
||||
### 1. 命名空间组织
|
||||
### 1. Namespace Organization
|
||||
|
||||
- common: 共享 UI 元素(按钮、标签、操作)
|
||||
- chat: 聊天特定功能
|
||||
- setting: 配置和设置
|
||||
- error: 错误消息和处理
|
||||
- [feature]: 功能特定或页面特定的命名空间
|
||||
- components: 可复用组件文案
|
||||
- common: Shared UI elements (buttons, labels, actions)
|
||||
- chat: Chat-specific functionality
|
||||
- setting: Configuration and settings
|
||||
- error: Error messages and handling
|
||||
- [feature]: Feature-specific or page-specific namespaces
|
||||
- components: Reusable component text
|
||||
|
||||
### 2. 键命名约定
|
||||
### 2. Key Naming Conventions
|
||||
|
||||
```typescript
|
||||
// ✅ 好:层次结构
|
||||
// ✅ Good: Hierarchical structure
|
||||
export default {
|
||||
modal: {
|
||||
confirm: {
|
||||
title: "确认操作",
|
||||
message: "确定要执行此操作吗?",
|
||||
actions: {
|
||||
confirm: "确认",
|
||||
cancel: "取消",
|
||||
},
|
||||
},
|
||||
modal: {
|
||||
confirm: {
|
||||
title: '确认操作',
|
||||
message: '确定要执行此操作吗?',
|
||||
actions: {
|
||||
confirm: '确认',
|
||||
cancel: '取消',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// ❌ 避免:扁平结构
|
||||
// ❌ Avoid: Flat structure
|
||||
export default {
|
||||
modalConfirmTitle: "确认操作",
|
||||
modalConfirmMessage: "确定要执行此操作吗?",
|
||||
modalConfirmTitle: '确认操作',
|
||||
modalConfirmMessage: '确定要执行此操作吗?',
|
||||
};
|
||||
```
|
||||
|
||||
## 故障排除
|
||||
## Troubleshooting
|
||||
|
||||
### 缺少翻译键
|
||||
### Missing Translation Keys
|
||||
|
||||
- Check if the key exists in src/locales/default/namespace.ts
|
||||
- Ensure the namespace is correctly imported in the component
|
||||
- Ensure new namespaces are exported in src/locales/default/index.ts
|
||||
|
||||
- 检查键是否存在于 src/locales/default/namespace.ts 中
|
||||
- 确保在组件中正确导入命名空间
|
||||
|
||||
@@ -10,7 +10,7 @@ Emoji logo: 🤯
|
||||
|
||||
## Project Technologies Stack
|
||||
|
||||
read [package.json](mdc:package.json) to know all npm packages you can use. read [folder-structure.mdx](mdc:docs/development/basic/folder-structure.mdx) to learn project structure.
|
||||
read [package.json](mdc:package.json) to know all npm packages you can use.
|
||||
|
||||
The project uses the following technologies:
|
||||
|
||||
@@ -18,13 +18,13 @@ The project uses the following technologies:
|
||||
- Next.js 15 for frontend and backend, using app router instead of pages router
|
||||
- react 19, using hooks, functional components, react server components
|
||||
- TypeScript programming language
|
||||
- antd, @lobehub/ui for component framework
|
||||
- antd, `@lobehub/ui` for component framework
|
||||
- antd-style for css-in-js framework
|
||||
- react-layout-kit for flex layout
|
||||
- react-i18next for i18n
|
||||
- lucide-react, @ant-design/icons for icons
|
||||
- @lobehub/icons for AI provider/model logo icon
|
||||
- @formkit/auto-animate for react list animation
|
||||
- lucide-react, `@ant-design/icons` for icons
|
||||
- `@lobehub/icons` for AI provider/model logo icon
|
||||
- `@formkit/auto-animate` for react list animation
|
||||
- zustand for global state management
|
||||
- nuqs for type-safe search params state manager
|
||||
- SWR for react data fetch
|
||||
@@ -42,17 +42,3 @@ The project uses the following technologies:
|
||||
- Cursor AI for code editing and AI coding assistance
|
||||
|
||||
Note: All tools and libraries used are the latest versions. The application only needs to be compatible with the latest browsers;
|
||||
|
||||
## Often used npm scripts and commands
|
||||
|
||||
```bash
|
||||
# !: don't any build script to check weather code can work after modify
|
||||
# type check
|
||||
bun run type-check
|
||||
|
||||
# install dependencies
|
||||
pnpm install
|
||||
|
||||
# run tests
|
||||
npx vitest run --config vitest.config.ts '[file-path-pattern]'
|
||||
```
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
---
|
||||
description: Project directory structure overview
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# LobeChat Project Structure
|
||||
|
||||
## Directory Structure
|
||||
|
||||
note: some files are not shown for simplicity.
|
||||
|
||||
```plaintext
|
||||
lobe-chat/
|
||||
├── apps/ # Applications directory
|
||||
│ └── desktop/ # Electron desktop application
|
||||
│ ├── src/ # Desktop app source code
|
||||
│ └── resources/ # Desktop app resources
|
||||
├── docs/ # Project documentation
|
||||
│ ├── development/ # Development docs
|
||||
│ ├── self-hosting/ # Self-hosting docs
|
||||
│ └── usage/ # Usage guides
|
||||
├── locales/ # Internationalization files (multiple locales)
|
||||
│ ├── en-US/ # English (example)
|
||||
│ └── zh-CN/ # Simplified Chinese (example)
|
||||
├── packages/ # Monorepo packages directory
|
||||
│ ├── const/ # Constants definition package
|
||||
│ ├── database/ # Database related package
|
||||
│ ├── electron-client-ipc/ # Electron renderer ↔ main IPC client
|
||||
│ ├── electron-server-ipc/ # Electron main process IPC server
|
||||
│ ├── model-bank/ # Built-in model presets/catalog exports
|
||||
│ ├── model-runtime/ # AI model runtime package
|
||||
│ ├── types/ # TypeScript type definitions
|
||||
│ ├── utils/ # Utility functions package
|
||||
│ ├── file-loaders/ # File processing packages
|
||||
│ ├── prompts/ # AI prompt management
|
||||
│ └── web-crawler/ # Web crawling functionality
|
||||
├── public/ # Static assets
|
||||
│ ├── icons/ # Application icons
|
||||
│ ├── images/ # Image resources
|
||||
│ └── screenshots/ # Application screenshots
|
||||
├── scripts/ # Build and tool scripts
|
||||
├── src/ # Main application source code (see below)
|
||||
├── .cursor/ # Cursor AI configuration
|
||||
├── docker-compose/ # Docker configuration
|
||||
├── package.json # Project dependencies
|
||||
├── pnpm-workspace.yaml # pnpm monorepo configuration
|
||||
├── next.config.ts # Next.js configuration
|
||||
├── drizzle.config.ts # Drizzle ORM configuration
|
||||
└── tsconfig.json # TypeScript configuration
|
||||
```
|
||||
|
||||
## Core Source Directory (`src/`)
|
||||
|
||||
```plaintext
|
||||
src/
|
||||
├── app/ # Next.js App Router routes
|
||||
│ ├── (backend)/ # Backend API routes
|
||||
│ │ ├── api/ # REST API endpoints
|
||||
│ │ │ ├── auth/ # Authentication endpoints
|
||||
│ │ │ └── webhooks/ # Webhook handlers for various auth providers
|
||||
│ │ ├── middleware/ # Request middleware
|
||||
│ │ ├── oidc/ # OpenID Connect endpoints
|
||||
│ │ ├── trpc/ # tRPC API routes
|
||||
│ │ │ ├── async/ # Async tRPC endpoints
|
||||
│ │ │ ├── desktop/ # Desktop runtime endpoints
|
||||
│ │ │ ├── edge/ # Edge runtime endpoints
|
||||
│ │ │ ├── lambda/ # Lambda runtime endpoints
|
||||
│ │ │ └── tools/ # Tools-specific endpoints
|
||||
│ │ └── webapi/ # Web API endpoints
|
||||
│ │ ├── chat/ # Chat-related APIs for various providers
|
||||
│ │ ├── models/ # Model management APIs
|
||||
│ │ ├── plugin/ # Plugin system APIs
|
||||
│ │ ├── stt/ # Speech-to-text APIs
|
||||
│ │ ├── text-to-image/ # Image generation APIs
|
||||
│ │ └── tts/ # Text-to-speech APIs
|
||||
│ ├── [variants]/ # Page route variants
|
||||
│ │ ├── (main)/ # Main application routes
|
||||
│ │ │ ├── chat/ # Chat interface and workspace
|
||||
│ │ │ ├── discover/ # Discover page (assistants, models, providers)
|
||||
│ │ │ ├── files/ # File management interface
|
||||
│ │ │ ├── image/ # Image generation interface
|
||||
│ │ │ ├── profile/ # User profile and stats
|
||||
│ │ │ ├── repos/ # Knowledge base repositories
|
||||
│ │ │ └── settings/ # Application settings
|
||||
│ │ └── @modal/ # Modal routes
|
||||
│ └── manifest.ts # PWA configuration
|
||||
├── components/ # Global shared components
|
||||
│ ├── Analytics/ # Analytics tracking components
|
||||
│ ├── Error/ # Error handling components
|
||||
│ └── Loading/ # Loading state components
|
||||
├── config/ # Application configuration
|
||||
│ ├── featureFlags/ # Feature flags & experiments
|
||||
│ └── modelProviders/ # Model provider configurations
|
||||
├── features/ # Feature components (UI Layer)
|
||||
│ ├── AgentSetting/ # Agent configuration and management
|
||||
│ ├── ChatInput/ # Chat input with file upload and tools
|
||||
│ ├── Conversation/ # Message display and interaction
|
||||
│ ├── FileManager/ # File upload and knowledge base
|
||||
│ └── PluginStore/ # Plugin marketplace and management
|
||||
├── hooks/ # Custom React hooks
|
||||
├── layout/ # Global layout components
|
||||
│ ├── AuthProvider/ # Authentication provider
|
||||
│ └── GlobalProvider/ # Global state provider
|
||||
├── libs/ # External library integrations
|
||||
│ ├── analytics/ # Analytics services integration
|
||||
│ ├── next-auth/ # NextAuth.js configuration
|
||||
│ └── oidc-provider/ # OIDC provider implementation
|
||||
├── locales/ # Internationalization resources
|
||||
│ └── default/ # Default language definitions
|
||||
├── migrations/ # Client-side data migrations
|
||||
├── server/ # Server-side code
|
||||
│ ├── modules/ # Server modules
|
||||
│ ├── routers/ # tRPC routers
|
||||
│ └── services/ # Server services
|
||||
├── services/ # Service layer (per-domain, client/server split)
|
||||
│ ├── user/ # User services
|
||||
│ │ ├── client.ts # Client DB (PGLite) implementation
|
||||
│ │ └── server.ts # Server DB implementation (via tRPC)
|
||||
│ ├── aiModel/ # AI model services
|
||||
│ ├── session/ # Session services
|
||||
│ └── message/ # Message services
|
||||
├── store/ # Zustand state management
|
||||
│ ├── agent/ # Agent state
|
||||
│ ├── chat/ # Chat state
|
||||
│ └── user/ # User state
|
||||
├── styles/ # Global styles
|
||||
├── tools/ # Built-in tool system
|
||||
│ ├── artifacts/ # Code artifacts and preview
|
||||
│ └── web-browsing/ # Web search and browsing
|
||||
├── types/ # TypeScript type definitions
|
||||
└── utils/ # Utility functions
|
||||
├── client/ # Client-side utilities
|
||||
└── server/ # Server-side utilities
|
||||
```
|
||||
|
||||
## Key Monorepo Packages
|
||||
|
||||
```plaintext
|
||||
packages/
|
||||
├── const/ # Global constants and configurations
|
||||
├── database/ # Database schemas and models
|
||||
│ ├── src/models/ # Data models (CRUD operations)
|
||||
│ ├── src/schemas/ # Drizzle database schemas
|
||||
│ ├── src/repositories/ # Complex query layer
|
||||
│ └── migrations/ # Database migration files
|
||||
├── model-runtime/ # AI model runtime
|
||||
│ └── src/
|
||||
│ ├── openai/ # OpenAI provider integration
|
||||
│ ├── anthropic/ # Anthropic provider integration
|
||||
│ ├── google/ # Google AI provider integration
|
||||
│ ├── ollama/ # Ollama local model integration
|
||||
│ ├── types/ # Runtime type definitions
|
||||
│ └── utils/ # Runtime utilities
|
||||
├── types/ # Shared TypeScript type definitions
|
||||
│ └── src/
|
||||
│ ├── agent/ # Agent-related types
|
||||
│ ├── message/ # Message and chat types
|
||||
│ ├── user/ # User and session types
|
||||
│ └── tool/ # Tool and plugin types
|
||||
├── utils/ # Shared utility functions
|
||||
│ └── src/
|
||||
│ ├── client/ # Client-side utilities
|
||||
│ ├── server/ # Server-side utilities
|
||||
│ ├── fetch/ # HTTP request utilities
|
||||
│ └── tokenizer/ # Token counting utilities
|
||||
├── file-loaders/ # File loaders (PDF, DOCX, etc.)
|
||||
├── prompts/ # AI prompt management
|
||||
└── web-crawler/ # Web crawling functionality
|
||||
```
|
||||
|
||||
## Architecture Map
|
||||
|
||||
- Presentation: `src/features`, `src/components`, `src/layout` — UI composition, global providers
|
||||
- State: `src/store` — Zustand slices, selectors, middleware
|
||||
- Client Services: `src/services/<domain>/{client|server}.ts` — client: PGLite; server: tRPC bridge
|
||||
- API Routers: `src/app/(backend)/webapi` (REST), `src/app/(backend)/trpc/{edge|lambda|async|desktop|tools}`; Lambda router triggers Async router for long-running tasks (e.g., image)
|
||||
- Server Services: `src/server/services` (business logic), `src/server/modules` (infra adapters)
|
||||
- Data Access: `packages/database/src/{schemas,models,repositories}` — Schema (Drizzle), Model (CRUD), Repository (complex queries)
|
||||
- Integrations: `src/libs` — analytics, auth, trpc, logging, runtime helpers
|
||||
|
||||
## Data Flow Architecture
|
||||
|
||||
### Unified Flow Pattern
|
||||
|
||||
```
|
||||
UI Layer → State Management → Client Service → [Environment Branch] → Database
|
||||
↓ ↓ ↓ ↓ ↓
|
||||
React Zustand Environment Local/Remote PGLite/
|
||||
Components Store Adaptation Routing PostgreSQL
|
||||
```
|
||||
|
||||
### Environment-Specific Routing
|
||||
|
||||
| Mode | UI | Service Route | Database |
|
||||
| --------------- | -------- | ---------------------- | ------------------- |
|
||||
| **Browser/PWA** | React | Direct Model Access | PGLite (Local) |
|
||||
| **Server** | React | tRPC → Server Services | PostgreSQL (Remote) |
|
||||
| **Desktop** | Electron | tRPC → Local Node.js | PGLite/PostgreSQL\* |
|
||||
|
||||
_\*Depends on cloud sync configuration_
|
||||
|
||||
### Key Characteristics
|
||||
|
||||
- **Type Safety**: End-to-end type safety via tRPC and Drizzle ORM
|
||||
- **Local/Remote Dual Mode**: PGLite enables user data ownership and local control
|
||||
|
||||
## Quick Map
|
||||
|
||||
- App Routes: `src/app` — UI routes (App Router) and backend routes under `(backend)`
|
||||
- Web API: `src/app/(backend)/webapi` — REST-like endpoints
|
||||
- tRPC Routers: `src/server/routers` — typed RPC endpoints by runtime
|
||||
- Client Services: `src/services` — environment-adaptive client-side business logic
|
||||
- Server Services: `src/server/services` — platform-agnostic business logic
|
||||
- Database: `packages/database` — schemas/models/repositories/migrations
|
||||
- State: `src/store` — Zustand stores and slices
|
||||
- Integrations: `src/libs` — analytics/auth/trpc/logging/runtime helpers
|
||||
- Tools: `src/tools` — built-in tool system
|
||||
|
||||
## Common Tasks
|
||||
|
||||
- Add Web API route: `src/app/(backend)/webapi/<module>/route.ts`
|
||||
- Add tRPC endpoint: `src/server/routers/{edge|lambda|desktop}/...`
|
||||
- Add client/server service: `src/services/<domain>/{client|server}.ts` (client: PGLite; server: tRPC)
|
||||
- Add server service: `src/server/services/<domain>`
|
||||
- Add a new model/provider: `src/config/modelProviders/<provider>.ts` + `packages/model-bank/src/aiModels/<provider>.ts` + `packages/model-runtime/src/<provider>/index.ts`
|
||||
- Add DB schema/model/repository: `packages/database/src/{schemas|models|repositories}`
|
||||
- Add Zustand slice: `src/store/<domain>/slices`
|
||||
|
||||
## Env Modes
|
||||
|
||||
- `NEXT_PUBLIC_CLIENT_DB`: selects client DB mode (e.g., `pglite`) vs server-backed
|
||||
- `NEXT_PUBLIC_IS_DESKTOP_APP`: enables desktop-specific routes and behavior
|
||||
- `NEXT_PUBLIC_SERVICE_MODE`: controls service routing preference (client/server)
|
||||
|
||||
## Boundaries
|
||||
|
||||
- Keep client logic in `src/services`; server-only logic stays in `src/server/services`
|
||||
- Don’t mix Web API (`webapi/`) with tRPC (`src/server/routers/`)
|
||||
- Place business UI under `src/features`, global reusable UI under `src/components`
|
||||
@@ -9,6 +9,7 @@ alwaysApply: false
|
||||
- 如果要写复杂样式的话用 antd-style ,简单的话可以用 style 属性直接写内联样式
|
||||
- 如果需要 flex 布局或者居中布局应该使用 react-layout-kit 的 Flexbox 和 Center 组件
|
||||
- 选择组件时优先顺序应该是 src/components > 安装的组件 package > lobe-ui > antd
|
||||
- 使用 selector 访问 zustand store 的数据,而不是直接从 store 获取
|
||||
|
||||
## antd-style token system
|
||||
|
||||
@@ -85,9 +86,9 @@ const Card: FC<CardProps> = ({ title, content }) => {
|
||||
|
||||
## Lobe UI 包含的组件
|
||||
|
||||
- 不知道 @lobehub/ui 的组件怎么用,有哪些属性,就自己搜下这个项目其它地方怎么用的,不要瞎猜,大部分组件都是在 antd 的基础上扩展了属性
|
||||
- 不知道 `@lobehub/ui` 的组件怎么用,有哪些属性,就自己搜下这个项目其它地方怎么用的,不要瞎猜,大部分组件都是在 antd 的基础上扩展了属性
|
||||
- 具体用法不懂可以联网搜索,例如 ActionIcon 就爬取 https://ui.lobehub.com/components/action-icon
|
||||
- 可以阅读 node_modules/@lobehub/ui/es/index.js 了解有哪些组件,每个组件的属性是什么
|
||||
- 可以阅读 `node_modules/@lobehub/ui/es/index.js` 了解有哪些组件,每个组件的属性是什么
|
||||
|
||||
- General
|
||||
- ActionIcon
|
||||
|
||||
@@ -5,6 +5,8 @@ alwaysApply: false
|
||||
|
||||
## 🗃️ 数据库 Model 测试指南
|
||||
|
||||
测试 `packages/database` 下的数据库 Model 层。
|
||||
|
||||
### 测试环境选择 💡
|
||||
|
||||
数据库 Model 层通过环境变量控制数据库类型,在两种测试环境下有不同的数据库后端:客户端环境 (PGLite) 和 服务端环境 (PostgreSQL)
|
||||
@@ -17,10 +19,10 @@ alwaysApply: false
|
||||
|
||||
```bash
|
||||
# 1. 先在客户端环境测试(快速验证)
|
||||
npx vitest run --config vitest.config.ts src/database/models/__tests__/myModel.test.ts
|
||||
cd packages/database && TEST_SERVER_DB=0 bunx vitest run --silent='passed-only' src/database/models/__tests__/myModel.test.ts
|
||||
|
||||
# 2. 再在服务端环境测试(兼容性验证)
|
||||
npx vitest run --config vitest.config.server.ts src/database/models/__tests__/myModel.test.ts
|
||||
# 2. 再在服务端环境测试(兼容性验证), 需要设置环境变量 `TEST_SERVER_DB=1`
|
||||
cd packages/database && TEST_SERVER_DB=1 bunx vitest run --silent='passed-only' src/database/models/__tests__/myModel.test.ts #
|
||||
```
|
||||
|
||||
### 创建新 Model 测试的最佳实践 📋
|
||||
|
||||
@@ -5,11 +5,11 @@ alwaysApply: false
|
||||
|
||||
# 测试指南 - LobeChat Testing Guide
|
||||
|
||||
## 🧪 测试环境概览
|
||||
## 测试环境概览
|
||||
|
||||
LobeChat 项目使用 Vitest 测试库,配置了两种不同的测试环境:
|
||||
|
||||
### 客户端测试环境 (DOM Environment)
|
||||
### 客户端数据库测试环境 (DOM Environment)
|
||||
|
||||
- **配置文件**: [vitest.config.ts](mdc:vitest.config.ts)
|
||||
- **环境**: Happy DOM (浏览器环境模拟)
|
||||
@@ -17,60 +17,71 @@ LobeChat 项目使用 Vitest 测试库,配置了两种不同的测试环境:
|
||||
- **用途**: 测试前端组件、客户端逻辑、React 组件等
|
||||
- **设置文件**: [tests/setup.ts](mdc:tests/setup.ts)
|
||||
|
||||
### 服务端测试环境 (Node Environment)
|
||||
### 服务端数据库测试环境 (Node Environment)
|
||||
|
||||
- **配置文件**: [vitest.config.server.ts](mdc:vitest.config.server.ts)
|
||||
目前只有 `packages/database` 下的测试可以通过配置 `TEST_SERVER_DB=1` 环境变量来使用服务端数据库测试
|
||||
|
||||
- **配置文件**: [packages/database/vitest.config.mts](mdc:packages/database/vitest.config.mts) 并且设置环境变量 `TEST_SERVER_DB=1`
|
||||
- **环境**: Node.js
|
||||
- **数据库**: 真实的 PostgreSQL 数据库
|
||||
- **并发限制**: 单线程运行 (`singleFork: true`)
|
||||
- **用途**: 测试数据库模型、服务端逻辑、API 端点等
|
||||
- **设置文件**: [tests/setup-db.ts](mdc:tests/setup-db.ts)
|
||||
- **设置文件**: [packages/database/tests/setup-db.ts](mdc:packages/database/tests/setup-db.ts)
|
||||
|
||||
## 🚀 测试运行命令
|
||||
## 测试运行命令
|
||||
|
||||
**🚨 性能警告**: 项目包含 3000+ 测试用例,完整运行需要约 10 分钟。务必使用文件过滤或测试名称过滤。
|
||||
** 性能警告**: 项目包含 3000+ 测试用例,完整运行需要约 10 分钟。务必使用文件过滤或测试名称过滤。
|
||||
|
||||
### ✅ 正确的命令格式
|
||||
### 正确的命令格式
|
||||
|
||||
```bash
|
||||
# 运行所有客户端/服务端测试
|
||||
npx vitest run --config vitest.config.ts # 客户端测试
|
||||
npx vitest run --config vitest.config.server.ts # 服务端测试
|
||||
bunx vitest run --silent='passed-only' # 客户端测试
|
||||
cd packages/database && TEST_SERVER_DB=1 bunx vitest run --silent='passed-only' # 服务端测试
|
||||
|
||||
# 运行特定测试文件 (支持模糊匹配)
|
||||
npx vitest run --config vitest.config.ts user.test.ts
|
||||
bunx vitest run --silent='passed-only' user.test.ts
|
||||
|
||||
# 运行特定测试用例名称 (使用 -t 参数)
|
||||
npx vitest run --config vitest.config.ts -t "test case name"
|
||||
bunx vitest run --silent='passed-only' -t "test case name"
|
||||
|
||||
# 组合使用文件和测试名称过滤
|
||||
npx vitest run --config vitest.config.ts filename.test.ts -t "specific test"
|
||||
bunx vitest run --silent='passed-only' filename.test.ts -t "specific test"
|
||||
|
||||
# 生成覆盖率报告 (使用 --coverage 参数)
|
||||
npx vitest run --config vitest.config.ts --coverage
|
||||
bunx vitest run --silent='passed-only' --coverage
|
||||
```
|
||||
|
||||
### ❌ 避免的命令格式
|
||||
### 避免的命令格式
|
||||
|
||||
```bash
|
||||
# ❌ 这些命令会运行所有 3000+ 测试用例,耗时约 10 分钟!
|
||||
# 这些命令会运行所有 3000+ 测试用例,耗时约 10 分钟!
|
||||
npm test
|
||||
npm test some-file.test.ts
|
||||
|
||||
# ❌ 不要使用裸 vitest (会进入 watch 模式)
|
||||
# 不要使用裸 vitest (会进入 watch 模式)
|
||||
vitest test-file.test.ts
|
||||
```
|
||||
|
||||
## 🔧 测试修复原则
|
||||
## 测试修复原则
|
||||
|
||||
### 核心原则 ⚠️
|
||||
### 核心原则
|
||||
|
||||
1. **充分阅读测试代码**: 在修复测试之前,必须完整理解测试的意图和实现
|
||||
2. **测试优先修复**: 如果是测试本身写错了,修改测试而不是实现代码
|
||||
3. **专注单一问题**: 只修复指定的测试,不要添加额外测试或功能
|
||||
4. **不自作主张**: 不要因为发现其他问题就直接修改,先提出再讨论
|
||||
1. **收集足够的上下文**
|
||||
在修复测试之前,务必做到:
|
||||
- 完整理解测试的意图和实现
|
||||
- 强烈建议阅读当前的 git diff 和 PR diff
|
||||
|
||||
### 测试协作最佳实践 🤝
|
||||
2. **测试优先修复**
|
||||
如果是测试本身写错了,应优先修改测试,而不是实现代码。
|
||||
|
||||
3. **专注单一问题**
|
||||
只修复指定的测试,不要顺带添加额外测试。
|
||||
|
||||
4. **不自作主张**
|
||||
发现其他问题时,不要直接修改,需先提出并讨论。
|
||||
|
||||
### 测试协作最佳实践
|
||||
|
||||
基于实际开发经验总结的重要协作原则:
|
||||
|
||||
@@ -84,10 +95,10 @@ vitest test-file.test.ts
|
||||
- **避免陷阱**: 不要陷入"不断尝试相同或类似方法"的循环
|
||||
|
||||
```typescript
|
||||
// ❌ 错误做法:连续失败后继续盲目尝试
|
||||
// 错误做法:连续失败后继续盲目尝试
|
||||
// 第3次、第4次仍在用相似的方法修复同一个问题
|
||||
|
||||
// ✅ 正确做法:失败1-2次后总结问题
|
||||
// 正确做法:失败1-2次后总结问题
|
||||
/*
|
||||
问题总结:
|
||||
1. 尝试过的方法:修改 mock 数据结构
|
||||
@@ -106,7 +117,7 @@ vitest test-file.test.ts
|
||||
- **保持稳定性**: 测试名称应该在代码重构后仍然有意义
|
||||
|
||||
```typescript
|
||||
// ❌ 错误的测试命名
|
||||
// 错误的测试命名
|
||||
describe('User component coverage', () => {
|
||||
it('covers line 45-50 in getUserData', () => {
|
||||
// 为了覆盖第45-50行而写的测试
|
||||
@@ -117,7 +128,7 @@ describe('User component coverage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ✅ 正确的测试命名
|
||||
// 正确的测试命名
|
||||
describe('<UserAvatar />', () => {
|
||||
it('should render fallback icon when image url is not provided', () => {
|
||||
// 测试具体的业务场景,自然会覆盖相关代码分支
|
||||
@@ -131,8 +142,8 @@ describe('<UserAvatar />', () => {
|
||||
|
||||
**覆盖率提升的正确思路**:
|
||||
|
||||
- ✅ 通过设计各种业务场景(正常流程、边缘情况、错误处理)来自然提升覆盖率
|
||||
- ❌ 不要为了达到覆盖率数字而写测试,更不要在测试中注释"为了覆盖 xxx 行"
|
||||
- 通过设计各种业务场景(正常流程、边缘情况、错误处理)来自然提升覆盖率
|
||||
- 不要为了达到覆盖率数字而写测试,更不要在测试中注释"为了覆盖 xxx 行"
|
||||
|
||||
#### 3. 测试组织结构
|
||||
|
||||
@@ -143,7 +154,7 @@ describe('<UserAvatar />', () => {
|
||||
- **避免碎片化**: 不要为了单个测试用例就创建新的顶级 `describe` 块
|
||||
|
||||
```typescript
|
||||
// ❌ 错误的组织方式:创建过多顶级块
|
||||
// 错误的组织方式:创建过多顶级块
|
||||
describe('<UserProfile />', () => {
|
||||
it('should render user name', () => {});
|
||||
});
|
||||
@@ -158,7 +169,7 @@ describe('UserProfile edge cases', () => {
|
||||
it('should handle missing avatar', () => {});
|
||||
});
|
||||
|
||||
// ✅ 正确的组织方式:合并相关测试
|
||||
// 正确的组织方式:合并相关测试
|
||||
describe('<UserProfile />', () => {
|
||||
it('should render user name', () => {});
|
||||
|
||||
@@ -214,9 +225,9 @@ describe('<UserProfile />', () => {
|
||||
**修复方法**: 更新了测试文件中的 mock 数据结构,使其与最新的 API 响应格式保持一致。具体修改了 `user.test.ts` 中的 `mockUserData` 对象结构。
|
||||
```
|
||||
|
||||
## 🎯 测试编写最佳实践
|
||||
## 测试编写最佳实践
|
||||
|
||||
### Mock 数据策略:追求"低成本的真实性" 📋
|
||||
### Mock 数据策略:追求"低成本的真实性"
|
||||
|
||||
**核心原则**: 测试数据应默认追求真实性,只有在引入"高昂的测试成本"时才进行简化。
|
||||
|
||||
@@ -228,10 +239,10 @@ describe('<UserProfile />', () => {
|
||||
- **网络请求**:HTTP 调用、数据库连接
|
||||
- **系统调用**:获取系统时间、环境变量等
|
||||
|
||||
#### ✅ 推荐做法:Mock 依赖,保留真实数据
|
||||
#### 推荐做法:Mock 依赖,保留真实数据
|
||||
|
||||
```typescript
|
||||
// ✅ 好的做法:Mock I/O 操作,但使用真实的文件内容格式
|
||||
// 好的做法:Mock I/O 操作,但使用真实的文件内容格式
|
||||
describe('parseContentType', () => {
|
||||
beforeEach(() => {
|
||||
// Mock 文件读取操作(避免真实 I/O)
|
||||
@@ -249,7 +260,7 @@ describe('parseContentType', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ❌ 过度简化:使用不真实的数据
|
||||
// 过度简化:使用不真实的数据
|
||||
describe('parseContentType', () => {
|
||||
it('should detect PDF content type correctly', () => {
|
||||
// 这种简化数据没有测试价值
|
||||
@@ -259,78 +270,116 @@ describe('parseContentType', () => {
|
||||
});
|
||||
```
|
||||
|
||||
#### 🎯 真实标识符的价值
|
||||
#### 真实标识符的价值
|
||||
|
||||
```typescript
|
||||
// ✅ 使用真实的提供商标识符
|
||||
it('should parse OpenAI model list correctly', () => {
|
||||
const result = parseModelString('openai', '+gpt-4,+gpt-3.5-turbo');
|
||||
expect(result.add).toHaveLength(2);
|
||||
expect(result.add[0].id).toBe('gpt-4');
|
||||
});
|
||||
// ✅ 使用真实标识符
|
||||
const result = parseModelString('openai', '+gpt-4,+gpt-3.5-turbo');
|
||||
|
||||
// ❌ 使用占位符标识符(价值较低)
|
||||
it('should parse model list correctly', () => {
|
||||
const result = parseModelString('test-provider', '+model1,+model2');
|
||||
expect(result.add).toHaveLength(2);
|
||||
// 这种测试对理解真实场景帮助不大
|
||||
// ❌ 使用占位符(价值较低)
|
||||
const result = parseModelString('test-provider', '+model1,+model2');
|
||||
```
|
||||
|
||||
### 现代化Mock技巧:环境设置与Mock方法
|
||||
|
||||
**环境设置 + Mock方法结合使用**
|
||||
|
||||
客户端代码测试时,推荐使用环境注释配合现代化Mock方法:
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* @vitest-environment happy-dom // 提供浏览器API
|
||||
*/
|
||||
import { beforeEach, vi } from 'vitest';
|
||||
|
||||
beforeEach(() => {
|
||||
// 现代方法1:使用vi.stubGlobal替代global.xxx = ...
|
||||
const mockImage = vi.fn().mockImplementation(() => ({
|
||||
addEventListener: vi.fn(),
|
||||
naturalHeight: 600,
|
||||
naturalWidth: 800,
|
||||
}));
|
||||
vi.stubGlobal('Image', mockImage);
|
||||
|
||||
// 现代方法2:使用vi.spyOn保留原功能,只mock特定方法
|
||||
vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:mock-url');
|
||||
vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {});
|
||||
});
|
||||
```
|
||||
|
||||
### 错误处理测试:测试"行为"而非"文本" ⚠️
|
||||
**环境选择优先级**
|
||||
|
||||
1. **@vitest-environment happy-dom** (推荐) - 轻量、快速,项目已安装
|
||||
2. **@vitest-environment jsdom** - 功能完整,但需要额外安装jsdom包
|
||||
3. **不设置环境** - Node.js环境,需要手动mock所有浏览器API
|
||||
|
||||
**Mock方法对比**
|
||||
|
||||
```typescript
|
||||
// ❌ 旧方法:直接操作global对象(类型问题)
|
||||
global.Image = mockImage;
|
||||
global.URL = { ...global.URL, createObjectURL: mockFn };
|
||||
|
||||
// ✅ 现代方法:类型安全的vi API
|
||||
vi.stubGlobal('Image', mockImage); // 完全替换全局对象
|
||||
vi.spyOn(URL, 'createObjectURL'); // 部分mock,保留其他功能
|
||||
```
|
||||
|
||||
### 测试覆盖率原则:代码分支优于用例数量
|
||||
|
||||
**核心原则**: 优先覆盖所有代码分支,而非编写大量重复用例
|
||||
|
||||
```typescript
|
||||
// ❌ 过度测试:29个测试用例都验证相同分支
|
||||
describe('getImageDimensions', () => {
|
||||
it('should reject .txt files');
|
||||
it('should reject .pdf files');
|
||||
// ... 25个类似测试,都走相同的验证分支
|
||||
});
|
||||
|
||||
// ✅ 精简测试:4个核心用例覆盖所有分支
|
||||
describe('getImageDimensions', () => {
|
||||
it('should return dimensions for valid File object'); // 成功路径 - File
|
||||
it('should return dimensions for valid data URI'); // 成功路径 - String
|
||||
it('should return undefined for invalid inputs'); // 输入验证分支
|
||||
it('should return undefined when image fails to load'); // 错误处理分支
|
||||
});
|
||||
```
|
||||
|
||||
**分支覆盖策略**
|
||||
|
||||
1. **成功路径** - 每种输入类型1个测试即可
|
||||
2. **边界条件** - 合并类似场景到单个测试
|
||||
3. **错误处理** - 测试代表性错误即可
|
||||
4. **业务逻辑** - 覆盖所有if/else分支
|
||||
|
||||
**合理测试数量**
|
||||
|
||||
- 简单工具函数:2-5个测试
|
||||
- 复杂业务逻辑:5-10个测试
|
||||
- 核心安全功能:适当增加,但避免重复路径
|
||||
|
||||
### 错误处理测试:测试"行为"而非"文本"
|
||||
|
||||
**核心原则**: 测试应该验证程序在错误发生时的行为是可预测的,而不是验证易变的错误信息文本。
|
||||
|
||||
#### ✅ 推荐的错误测试方式
|
||||
#### 推荐的错误测试方式
|
||||
|
||||
```typescript
|
||||
// ✅ 测试是否抛出错误
|
||||
it('should throw error when invalid input provided', () => {
|
||||
expect(() => processInput(null)).toThrow();
|
||||
});
|
||||
// ✅ 测试错误类型和属性
|
||||
expect(() => validateUser({})).toThrow(ValidationError);
|
||||
expect(() => processPayment({})).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'INVALID_PAYMENT_DATA',
|
||||
statusCode: 400,
|
||||
}),
|
||||
);
|
||||
|
||||
// ✅ 测试错误类型(最推荐)
|
||||
it('should throw ValidationError for invalid data', () => {
|
||||
expect(() => validateUser({})).toThrow(ValidationError);
|
||||
});
|
||||
|
||||
// ✅ 测试错误属性而非消息文本
|
||||
it('should throw error with correct error code', () => {
|
||||
expect(() => processPayment({})).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'INVALID_PAYMENT_DATA',
|
||||
statusCode: 400,
|
||||
}),
|
||||
);
|
||||
});
|
||||
// ❌ 避免测试具体错误文本
|
||||
expect(() => processUser({})).toThrow('用户数据不能为空,请检查输入参数');
|
||||
```
|
||||
|
||||
#### ❌ 应避免的做法
|
||||
|
||||
```typescript
|
||||
// ❌ 过度依赖具体错误信息文本
|
||||
it('should throw specific error message', () => {
|
||||
expect(() => processUser({})).toThrow('用户数据不能为空,请检查输入参数');
|
||||
// 这种测试很脆弱,错误文案稍有修改就会失败
|
||||
});
|
||||
```
|
||||
|
||||
#### 🎯 例外情况:何时可以测试错误信息
|
||||
|
||||
```typescript
|
||||
// ✅ 测试标准 API 错误(这是契约的一部分)
|
||||
it('should return proper HTTP error for API', () => {
|
||||
expect(response.statusCode).toBe(400);
|
||||
expect(response.error).toBe('Bad Request');
|
||||
});
|
||||
|
||||
// ✅ 测试错误信息的关键部分(使用正则)
|
||||
it('should include field name in validation error', () => {
|
||||
expect(() => validateField('email', '')).toThrow(/email/i);
|
||||
});
|
||||
```
|
||||
|
||||
### 疑难解答:警惕模块污染 🚨
|
||||
### 疑难解答:警惕模块污染
|
||||
|
||||
**识别信号**: 当你的测试出现以下"灵异"现象时,优先怀疑模块污染:
|
||||
|
||||
@@ -341,55 +390,25 @@ it('should include field name in validation error', () => {
|
||||
#### 典型场景:动态 Mock 同一模块
|
||||
|
||||
```typescript
|
||||
// ❌ 容易出现模块污染的写法
|
||||
describe('ConfigService', () => {
|
||||
it('should work in development mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: true }));
|
||||
const { getSettings } = await import('./configService'); // 第一次加载
|
||||
expect(getSettings().debugMode).toBe(true);
|
||||
});
|
||||
|
||||
it('should work in production mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: false }));
|
||||
const { getSettings } = await import('./configService'); // 可能使用缓存的旧版本!
|
||||
expect(getSettings().debugMode).toBe(false); // ❌ 可能失败
|
||||
});
|
||||
// ❌ 问题:动态Mock同一模块
|
||||
it('dev mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: true }));
|
||||
const { getSettings } = await import('./service'); // 可能使用缓存
|
||||
});
|
||||
|
||||
// ✅ 使用 resetModules 解决模块污染
|
||||
describe('ConfigService', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules(); // 清除模块缓存,确保每个测试都是干净的环境
|
||||
});
|
||||
|
||||
it('should work in development mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: true }));
|
||||
const { getSettings } = await import('./configService');
|
||||
expect(getSettings().debugMode).toBe(true);
|
||||
});
|
||||
|
||||
it('should work in production mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: false }));
|
||||
const { getSettings } = await import('./configService');
|
||||
expect(getSettings().debugMode).toBe(false); // ✅ 测试通过
|
||||
});
|
||||
// ✅ 解决:清除模块缓存
|
||||
beforeEach(() => {
|
||||
vi.resetModules(); // 确保每个测试都是干净环境
|
||||
});
|
||||
```
|
||||
|
||||
#### 🔧 排查和解决步骤
|
||||
**记住**: `vi.resetModules()` 是解决测试"灵异"失败的终极武器。
|
||||
|
||||
1. **识别问题**: 测试失败时,首先问自己:"是否有多个测试在 Mock 同一个模块?"
|
||||
2. **添加隔离**: 在 `beforeEach` 中添加 `vi.resetModules()`
|
||||
3. **验证修复**: 重新运行测试,确认问题解决
|
||||
|
||||
**记住**: `vi.resetModules()` 是解决测试"灵异"失败的终极武器,当常规调试方法都无效时,它往往能一针见血地解决问题。
|
||||
|
||||
## 📂 测试文件组织
|
||||
## 测试文件组织
|
||||
|
||||
### 文件命名约定
|
||||
|
||||
- **客户端测试**: `*.test.ts`, `*.test.tsx` (任意位置)
|
||||
- **服务端测试**: `src/database/models/**/*.test.ts`, `src/database/server/**/*.test.ts` (限定路径)
|
||||
`*.test.ts`, `*.test.tsx` (任意位置)
|
||||
|
||||
### 测试文件组织风格
|
||||
|
||||
@@ -406,7 +425,10 @@ src/components/Button/
|
||||
└── index.test.tsx # 测试文件
|
||||
```
|
||||
|
||||
## 🛠️ 测试调试技巧
|
||||
- 也有少数情况会统一放到 `__tests__` 文件夹, 例如 `packages/database/src/models/__tests__`
|
||||
- 测试使用的辅助文件放到 fixtures 文件夹
|
||||
|
||||
## 测试调试技巧
|
||||
|
||||
### 测试调试步骤
|
||||
|
||||
@@ -415,40 +437,28 @@ src/components/Button/
|
||||
3. **分析错误**: 仔细阅读错误信息、堆栈跟踪和最近的文件修改记录
|
||||
4. **添加调试**: 在测试中添加 `console.log` 了解执行流程
|
||||
|
||||
### TypeScript 类型处理 📝
|
||||
### TypeScript 类型处理
|
||||
|
||||
在测试中,为了提高编写效率和可读性,可以适当放宽 TypeScript 类型检测:
|
||||
|
||||
#### ✅ 推荐的类型放宽策略
|
||||
#### 推荐的类型放宽策略
|
||||
|
||||
```typescript
|
||||
// ✅ 使用非空断言访问测试中确定存在的属性
|
||||
// 使用非空断言访问测试中确定存在的属性
|
||||
const result = await someFunction();
|
||||
expect(result!.data).toBeDefined();
|
||||
expect(result!.status).toBe('success');
|
||||
|
||||
// ✅ 使用 any 类型简化复杂的 Mock 设置
|
||||
// 使用 any 类型简化复杂的 Mock 设置
|
||||
const mockStream = new ReadableStream() as any;
|
||||
mockStream.toReadableStream = () => mockStream;
|
||||
|
||||
// ✅ 使用中括号访问私有属性和方法(推荐)
|
||||
class MyClass {
|
||||
private _cache = new Map();
|
||||
private getFromCache(key: string) { /* ... */ }
|
||||
}
|
||||
|
||||
const instance = new MyClass();
|
||||
|
||||
// 推荐:使用中括号访问私有成员
|
||||
await instance['getFromCache']('test-key');
|
||||
expect(instance['_cache'].size).toBe(1);
|
||||
|
||||
// 避免:使用 as any 访问私有成员
|
||||
await (instance as any).getFromCache('test-key'); // ❌ 不推荐
|
||||
expect((instance as any)._cache.size).toBe(1); // ❌ 不推荐
|
||||
// 访问私有成员
|
||||
await instance['getFromCache']('key'); // 推荐中括号
|
||||
await (instance as any).getFromCache('key'); // 避免as any
|
||||
```
|
||||
|
||||
#### 🎯 适用场景
|
||||
#### 适用场景
|
||||
|
||||
- **Mock 对象**: 对于测试用的 Mock 数据,使用 `as any` 避免复杂的类型定义
|
||||
- **第三方库**: 处理复杂的第三方库类型时,适当使用 `any` 提高效率
|
||||
@@ -456,44 +466,30 @@ expect((instance as any)._cache.size).toBe(1); // ❌ 不推荐
|
||||
- **私有成员访问**: 优先使用中括号 `instance['privateMethod']()` 而不是 `(instance as any).privateMethod()`
|
||||
- **临时调试**: 快速编写测试时,先用 `any` 保证功能,后续可选择性地优化类型
|
||||
|
||||
#### ⚠️ 注意事项
|
||||
#### 注意事项
|
||||
|
||||
- **适度使用**: 不要过度依赖 `any`,核心业务逻辑的类型仍应保持严格
|
||||
- **私有成员访问优先级**: 中括号访问 > `as any` 转换,保持更好的类型安全性
|
||||
- **文档说明**: 对于使用 `any` 的复杂场景,添加注释说明原因
|
||||
- **测试覆盖**: 确保即使使用了 `any`,测试仍能有效验证功能正确性
|
||||
|
||||
### 检查最近修改记录 🔍
|
||||
### 检查最近修改记录
|
||||
|
||||
系统性地检查相关文件的修改历史是问题定位的关键步骤。
|
||||
**核心原则**:测试突然失败时,优先检查最近的代码修改。
|
||||
|
||||
#### 三步检查法
|
||||
|
||||
**Step 1: 查看当前状态**
|
||||
#### 快速检查方法
|
||||
|
||||
```bash
|
||||
git status # 查看未提交的修改
|
||||
git diff path/to/component.test.ts | cat # 查看测试文件修改
|
||||
git diff path/to/component.ts | cat # 查看实现文件修改
|
||||
git status # 查看当前修改状态
|
||||
git diff HEAD -- '*.test.*' # 检查测试文件改动
|
||||
git diff main...HEAD # 对比主分支差异
|
||||
gh pr diff # 查看PR中的所有改动
|
||||
```
|
||||
|
||||
**Step 2: 查看提交历史**
|
||||
#### 常见原因与解决
|
||||
|
||||
```bash
|
||||
git log --pretty=format:"%h %ad %s" --date=relative -3 path/to/component.ts | cat
|
||||
```
|
||||
|
||||
**Step 3: 查看具体修改内容**
|
||||
|
||||
```bash
|
||||
git show HEAD -- path/to/component.ts | cat # 查看最新提交的修改
|
||||
```
|
||||
|
||||
#### 时间相关性判断
|
||||
|
||||
- **24小时内的提交**: 🔴 **高度相关** - 很可能是直接原因
|
||||
- **1-7天内的提交**: 🟡 **中等相关** - 需要仔细分析
|
||||
- **超过1周的提交**: ⚪ **低相关性** - 除非重大重构
|
||||
- **最新提交引入bug** → 检查并修复实现代码
|
||||
- **分支代码滞后** → `git rebase main` 同步主分支
|
||||
|
||||
## 特殊场景的测试
|
||||
|
||||
@@ -502,9 +498,9 @@ git show HEAD -- path/to/component.ts | cat # 查看最新提交的修改
|
||||
- [Electron IPC 接口测试策略](mdc:./electron-ipc-test.mdc)
|
||||
- [数据库 Model 测试指南](mdc:./db-model-test.mdc)
|
||||
|
||||
## 🎯 核心要点
|
||||
## 核心要点
|
||||
|
||||
- **命令格式**: 使用 `npx vitest run --config [config-file]` 并指定文件过滤
|
||||
- **命令格式**: 使用 `bunx vitest run --silent='passed-only'` 并指定文件过滤
|
||||
- **修复原则**: 失败1-2次后寻求帮助,测试命名关注行为而非实现细节
|
||||
- **调试流程**: 复现 → 分析 → 假设 → 修复 → 验证 → 总结
|
||||
- **文件组织**: 优先在现有 `describe` 块中添加测试,避免创建冗余顶级块
|
||||
|
||||
@@ -8,11 +8,63 @@ alwaysApply: false
|
||||
|
||||
## Types and Type Safety
|
||||
|
||||
- Avoid explicit type annotations when TypeScript can infer types.
|
||||
- Avoid implicitly `any` variables; explicitly type when necessary (e.g., `let a: number` instead of `let a`).
|
||||
- Use the most accurate type possible (e.g., prefer `Record<PropertyKey, unknown>` over `object`).
|
||||
- Prefer `interface` over `type` for object shapes (e.g., React component props). Keep `type` for unions, intersections, and utility types.
|
||||
- Prefer `as const satisfies XyzInterface` over plain `as const` when suitable.
|
||||
- avoid explicit type annotations when TypeScript can infer types.
|
||||
- avoid implicitly `any` variables; explicitly type when necessary (e.g., `let a: number` instead of `let a`).
|
||||
- use the most accurate type possible (e.g., prefer `Record<PropertyKey, unknown>` over `object`).
|
||||
- prefer `interface` over `type` for object shapes (e.g., React component props). Keep `type` for unions, intersections, and utility types.
|
||||
- prefer `as const satisfies XyzInterface` over plain `as const` when suitable.
|
||||
- prefer `@ts-expect-error` over `@ts-ignore`
|
||||
- prefer `Record<string, any>` over `any`
|
||||
|
||||
- **Avoid unnecessary null checks**: Before adding `xxx !== null`, `?.`, `??`, or `!.`, read the type definition to confirm the necessary. **Example:**
|
||||
|
||||
```typescript
|
||||
// ❌ Wrong: budget.spend and budget.maxBudget is number, not number | null
|
||||
if (budget.spend !== null && budget.maxBudget !== null && budget.spend >= budget.maxBudget) {
|
||||
// ...
|
||||
}
|
||||
|
||||
// ✅ Right
|
||||
if (budget.spend >= budget.maxBudget) {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
- **Avoid redundant runtime checks**: Don't add runtime validation for conditions already guaranteed by types or previous checks. Trust the type system and calling contract. **Example:**
|
||||
|
||||
```typescript
|
||||
// ❌ Wrong: Adding impossible-to-fail checks
|
||||
const due = await db.query.budgets.findMany({
|
||||
where: and(isNotNull(budgets.budgetDuration)), // Already filtered non-null
|
||||
});
|
||||
const result = due.map(b => {
|
||||
const nextReset = computeNextResetAt(b.budgetResetAt!, b.budgetDuration!);
|
||||
if (!nextReset) { // This check is impossible to fail
|
||||
throw new Error(`Unexpected null nextResetAt`);
|
||||
}
|
||||
return nextReset;
|
||||
});
|
||||
|
||||
// ✅ Right: Trust the contract
|
||||
const due = await db.query.budgets.findMany({
|
||||
where: and(isNotNull(budgets.budgetDuration)),
|
||||
});
|
||||
const result = due.map(b => computeNextResetAt(b.budgetResetAt!, b.budgetDuration!));
|
||||
```
|
||||
|
||||
- **Avoid meaningless null/undefined parameters**: Don't accept null/undefined for parameters that have no business meaning when null. Design strict function contracts. **Example:**
|
||||
|
||||
```typescript
|
||||
// ❌ Wrong: Function accepts meaningless null input
|
||||
function computeNextResetAt(currentResetAt: Date, durationStr: string | null): Date | null {
|
||||
if (!durationStr) return null; // Why accept null if it just returns null?
|
||||
}
|
||||
|
||||
// ✅ Right: Strict contract, clear responsibility
|
||||
function computeNextResetAt(currentResetAt: Date, durationStr: string): Date {
|
||||
// Function has single clear purpose, caller ensures valid input
|
||||
}
|
||||
```
|
||||
|
||||
## Imports and Modules
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/typescript-node",
|
||||
"features": {
|
||||
"ghcr.io/devcontainer-community/devcontainer-features/bun.sh:1": {}
|
||||
}
|
||||
"ghcr.io/devcontainer-community/devcontainer-features/bun.sh:1": {},
|
||||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
|
||||
},
|
||||
"image": "mcr.microsoft.com/devcontainers/typescript-node"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
# Specify your API Key selection method, currently supporting `random` and `turn`.
|
||||
# API_KEY_SELECT_MODE=random
|
||||
|
||||
########################################
|
||||
########### Security Settings ###########
|
||||
########################################
|
||||
|
||||
# Control Content Security Policy headers
|
||||
# Set to '1' to enable X-Frame-Options and Content-Security-Policy headers
|
||||
# Default is '0' (enabled)
|
||||
# ENABLED_CSP=1
|
||||
|
||||
########################################
|
||||
########## AI Provider Service #########
|
||||
@@ -153,6 +161,27 @@ OPENAI_API_KEY=sk-xxxxxxxxx
|
||||
|
||||
# AIHUBMIX_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### BFL ###
|
||||
|
||||
# BFL_API_KEY=bfl-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### FAL ###
|
||||
|
||||
# FAL_API_KEY=fal-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Nebius ###
|
||||
|
||||
# NEBIUS_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### NewAPI Service ###
|
||||
|
||||
# NEWAPI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# NEWAPI_PROXY_URL=https://your-newapi-server.com
|
||||
|
||||
### Vercel AI Gateway ###
|
||||
|
||||
# VERCELAIGATEWAY_API_KEY=your_vercel_ai_gateway_api_key
|
||||
|
||||
|
||||
########################################
|
||||
############ Market Service ############
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
# LobeChat Development Server Configuration
|
||||
# This file contains environment variables for both LobeChat server mode and Docker compose setup
|
||||
|
||||
COMPOSE_FILE="docker-compose.development.yml"
|
||||
|
||||
# ⚠️⚠️⚠️ DO NOT USE THE SECRETS BELOW IN PRODUCTION!
|
||||
UNSAFE_SECRET="ww+0igxjGRAAR/eTNFQ55VmhQB5KE5trFZseuntThJs="
|
||||
UNSAFE_PASSWORD="CHANGE_THIS_PASSWORD_IN_PRODUCTION"
|
||||
|
||||
# Core Server Configuration
|
||||
# Service mode - set to 'server' for server-side deployment
|
||||
NEXT_PUBLIC_SERVICE_MODE=server
|
||||
|
||||
# Service Ports Configuration
|
||||
LOBE_PORT=3010
|
||||
|
||||
# Application URL - the base URL where LobeChat will be accessible
|
||||
APP_URL=http://localhost:${LOBE_PORT}
|
||||
|
||||
# Secret key for encrypting vault data (generate with: openssl rand -base64 32)
|
||||
KEY_VAULTS_SECRET=${UNSAFE_SECRET}
|
||||
|
||||
# Database Configuration
|
||||
# Database name for LobeChat
|
||||
LOBE_DB_NAME=lobechat
|
||||
|
||||
# PostgreSQL password
|
||||
POSTGRES_PASSWORD=${UNSAFE_PASSWORD}
|
||||
|
||||
# PostgreSQL database connection URL
|
||||
DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@localhost:5432/${LOBE_DB_NAME}
|
||||
|
||||
# Database driver type
|
||||
DATABASE_DRIVER=node
|
||||
|
||||
# Authentication Configuration
|
||||
# Enable NextAuth authentication
|
||||
NEXT_PUBLIC_ENABLE_NEXT_AUTH=1
|
||||
|
||||
# NextAuth secret for JWT signing (generate with: openssl rand -base64 32)
|
||||
NEXT_AUTH_SECRET=${UNSAFE_SECRET}
|
||||
|
||||
NEXTAUTH_URL=${APP_URL}
|
||||
|
||||
# Authentication URL
|
||||
AUTH_URL=${APP_URL}/api/auth
|
||||
|
||||
# SSO providers configuration - using Casdoor for development
|
||||
NEXT_AUTH_SSO_PROVIDERS=casdoor
|
||||
|
||||
# Casdoor Configuration
|
||||
# Casdoor service port
|
||||
CASDOOR_PORT=8000
|
||||
|
||||
# Casdoor OIDC issuer URL
|
||||
AUTH_CASDOOR_ISSUER=http://localhost:${CASDOOR_PORT}
|
||||
|
||||
# Casdoor application client ID
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249 # DO NOT USE IN PROD
|
||||
|
||||
# Casdoor application client secret
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354 # DO NOT USE IN PROD
|
||||
|
||||
# Origin URL for Casdoor internal configuration
|
||||
origin=http://localhost:${CASDOOR_PORT}
|
||||
|
||||
# MinIO Storage Configuration
|
||||
# MinIO service port
|
||||
MINIO_PORT=9000
|
||||
|
||||
# MinIO root user (admin username)
|
||||
MINIO_ROOT_USER=admin
|
||||
|
||||
# MinIO root password
|
||||
MINIO_ROOT_PASSWORD=${UNSAFE_PASSWORD}
|
||||
|
||||
# MinIO bucket for LobeChat files
|
||||
MINIO_LOBE_BUCKET=lobe
|
||||
|
||||
# S3/MinIO Configuration for LobeChat
|
||||
# S3/MinIO access key ID
|
||||
S3_ACCESS_KEY_ID=${MINIO_ROOT_USER}
|
||||
|
||||
# S3/MinIO secret access key
|
||||
S3_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}
|
||||
|
||||
# S3/MinIO endpoint URL
|
||||
S3_ENDPOINT=http://localhost:${MINIO_PORT}
|
||||
|
||||
# S3 bucket name for storing files
|
||||
S3_BUCKET=${MINIO_LOBE_BUCKET}
|
||||
|
||||
# Public domain for S3 file access
|
||||
S3_PUBLIC_DOMAIN=http://localhost:${MINIO_PORT}
|
||||
|
||||
# Enable path-style S3 requests (required for MinIO)
|
||||
S3_ENABLE_PATH_STYLE=1
|
||||
|
||||
# Disable S3 ACL setting (for MinIO compatibility)
|
||||
S3_SET_ACL=0
|
||||
|
||||
# Use base64 encoding for LLM vision images
|
||||
LLM_VISION_IMAGE_USE_BASE64=1
|
||||
|
||||
# Search Service Configuration
|
||||
# SearXNG search engine URL
|
||||
SEARXNG_URL=http://searxng:8080
|
||||
|
||||
# Development Options
|
||||
# Uncomment to skip authentication during development
|
||||
|
||||
# Proxy Configuration (Optional)
|
||||
# Uncomment if you need proxy support (e.g., for GitHub auth or API access)
|
||||
# HTTP_PROXY=http://localhost:7890
|
||||
# HTTPS_PROXY=http://localhost:7890
|
||||
|
||||
# AI Model Configuration (Optional)
|
||||
# Add your AI model API keys and configurations here
|
||||
# ⚠️ WARNING: Never commit real API keys to version control!
|
||||
# OPENAI_API_KEY=sk-NEVER_USE_REAL_API_KEYS_IN_CONFIG_FILES
|
||||
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
||||
# OPENAI_MODEL_LIST=...
|
||||
@@ -29,3 +29,20 @@ logs
|
||||
# misc
|
||||
# add other ignore file below
|
||||
.next
|
||||
|
||||
# temporary directories
|
||||
tmp
|
||||
temp
|
||||
.temp
|
||||
.local
|
||||
docs/.local
|
||||
|
||||
# cache directories
|
||||
.cache
|
||||
|
||||
# AI coding tools directories
|
||||
.claude
|
||||
.serena
|
||||
|
||||
# MCP tools
|
||||
/.serena/**
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
- [ ] 💄 style
|
||||
- [ ] 👷 build
|
||||
- [ ] ⚡️ perf
|
||||
- [ ] ✅ test
|
||||
- [ ] 📝 docs
|
||||
- [ ] 🔨 chore
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Generate or update PR comment with Docker build info
|
||||
*/
|
||||
module.exports = async ({
|
||||
github,
|
||||
context,
|
||||
dockerMetaJson,
|
||||
image,
|
||||
version,
|
||||
dockerhubUrl,
|
||||
platforms,
|
||||
}) => {
|
||||
const COMMENT_IDENTIFIER = '<!-- DOCKER-BUILD-COMMENT -->';
|
||||
|
||||
const parseTags = () => {
|
||||
try {
|
||||
if (dockerMetaJson) {
|
||||
const parsed = JSON.parse(dockerMetaJson);
|
||||
if (Array.isArray(parsed.tags) && parsed.tags.length > 0) {
|
||||
return parsed.tags;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore parsing error, fallback below
|
||||
}
|
||||
if (image && version) {
|
||||
return [`${image}:${version}`];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const generateCommentBody = () => {
|
||||
const tags = parseTags();
|
||||
const buildTime = new Date().toISOString();
|
||||
|
||||
// Use the first tag as the main version
|
||||
const mainTag = tags.length > 0 ? tags[0] : `${image}:${version}`;
|
||||
const tagVersion = mainTag.includes(':') ? mainTag.split(':')[1] : version;
|
||||
|
||||
return [
|
||||
COMMENT_IDENTIFIER,
|
||||
'',
|
||||
'### 🐳 Database Docker Build Completed!',
|
||||
`**Version**: \`${tagVersion || 'N/A'}\``,
|
||||
`**Build Time**: \`${buildTime}\``,
|
||||
'',
|
||||
dockerhubUrl ? `🔗 View all tags on Docker Hub: ${dockerhubUrl}` : '',
|
||||
'',
|
||||
'### Pull Image',
|
||||
'Download the Docker image to your local machine:',
|
||||
'',
|
||||
'```bash',
|
||||
`docker pull ${mainTag}`,
|
||||
'```',
|
||||
'> [!IMPORTANT]',
|
||||
'> This build is for testing and validation purposes.',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
};
|
||||
|
||||
const body = generateCommentBody();
|
||||
|
||||
// List comments on the PR
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
|
||||
const existing = comments.find((c) => c.body && c.body.includes(COMMENT_IDENTIFIER));
|
||||
if (existing) {
|
||||
await github.rest.issues.updateComment({
|
||||
comment_id: existing.id,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body,
|
||||
});
|
||||
return { updated: true, id: existing.id };
|
||||
}
|
||||
|
||||
const result = await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body,
|
||||
});
|
||||
return { updated: false, id: result.data.id };
|
||||
};
|
||||
@@ -36,10 +36,19 @@ module.exports = async ({ github, context, releaseUrl, version, tag }) => {
|
||||
// Generate combined download table
|
||||
let assetTable = '| Platform | File | Size |\n| --- | --- | --- |\n';
|
||||
|
||||
// Add macOS assets
|
||||
// Add macOS assets with architecture detection
|
||||
macAssets.forEach((asset) => {
|
||||
const sizeInMB = (asset.size / (1024 * 1024)).toFixed(2);
|
||||
assetTable += `| macOS | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
|
||||
|
||||
// Detect architecture from filename
|
||||
let architecture = '';
|
||||
if (asset.name.includes('arm64')) {
|
||||
architecture = ' (Apple Silicon)';
|
||||
} else if (asset.name.includes('x64') || asset.name.includes('-mac.')) {
|
||||
architecture = ' (Intel)';
|
||||
}
|
||||
|
||||
assetTable += `| macOS${architecture} | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
|
||||
});
|
||||
|
||||
// Add Windows assets
|
||||
|
||||
@@ -21,12 +21,12 @@ jobs:
|
||||
git config --global user.name "lobehubbot"
|
||||
git config --global user.email "i@lobehub.com"
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
actions: read # Required for Claude to read CI results on PRs
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
|
||||
# This is an optional setting that allows Claude to read CI results on PRs
|
||||
additional_permissions: |
|
||||
actions: read
|
||||
|
||||
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
|
||||
# model: 'claude-opus-4-1-20250805'
|
||||
allowed_bots: 'bot'
|
||||
|
||||
# Optional: Customize the trigger phrase (default: @claude)
|
||||
# trigger_phrase: "/claude"
|
||||
|
||||
# Optional: Trigger when specific user is assigned to an issue
|
||||
# assignee_trigger: "claude-bot"
|
||||
|
||||
# Optional: Allow Claude to run specific commands
|
||||
allowed_tools: 'Bash(bun run:*),Bash(pnpm run:*),Bash(npm run:*),Bash(npx:*),Bash(bunx:*),Bash(vitest:*),Bash(rg:*),Bash(find:*),Bash(sed:*),Bash(grep:*),Bash(awk:*),Bash(wc:*),Bash(xargs:*)'
|
||||
|
||||
# Optional: Add custom instructions for Claude to customize its behavior for your project
|
||||
# custom_instructions: |
|
||||
# Follow our coding standards
|
||||
# Ensure all new code has tests
|
||||
# Use TypeScript for new files
|
||||
|
||||
# Optional: Custom environment variables for Claude
|
||||
# claude_env: |
|
||||
# NODE_ENV: test
|
||||
@@ -23,27 +23,28 @@ jobs:
|
||||
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
version: 9
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: pnpm install
|
||||
run: bun i
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
|
||||
- name: Lint
|
||||
run: pnpm run lint
|
||||
run: bun run lint
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
|
||||
@@ -56,14 +57,15 @@ jobs:
|
||||
# 输出版本信息,供后续 job 使用
|
||||
version: ${{ steps.set_version.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
# 主要逻辑:确定构建版本号
|
||||
- name: Set version
|
||||
@@ -93,24 +95,25 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-2025, ubuntu-latest]
|
||||
os: [macos-latest, macos-13, windows-2025, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9
|
||||
package-manager-cache: false
|
||||
|
||||
# node-linker=hoisted 模式将可以确保 asar 压缩可用
|
||||
- name: Install deps
|
||||
- name: Install dependencies
|
||||
run: pnpm install --node-linker=hoisted
|
||||
|
||||
- name: Install deps on Desktop
|
||||
@@ -172,6 +175,28 @@ jobs:
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
|
||||
|
||||
# 处理 macOS latest-mac.yml 重命名 (避免多架构覆盖)
|
||||
- name: Rename macOS latest-mac.yml for multi-architecture support
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
cd apps/desktop/release
|
||||
if [ -f "latest-mac.yml" ]; then
|
||||
# 使用系统架构检测,与 electron-builder 输出保持一致
|
||||
SYSTEM_ARCH=$(uname -m)
|
||||
if [[ "$SYSTEM_ARCH" == "arm64" ]]; then
|
||||
ARCH_SUFFIX="arm64"
|
||||
else
|
||||
ARCH_SUFFIX="x64"
|
||||
fi
|
||||
|
||||
mv latest-mac.yml "latest-mac-${ARCH_SUFFIX}.yml"
|
||||
echo "✅ Renamed latest-mac.yml to latest-mac-${ARCH_SUFFIX}.yml (detected: $SYSTEM_ARCH)"
|
||||
ls -la latest-mac-*.yml
|
||||
else
|
||||
echo "⚠️ latest-mac.yml not found, skipping rename"
|
||||
ls -la latest*.yml || echo "No latest*.yml files found"
|
||||
fi
|
||||
|
||||
# 上传构建产物
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -183,22 +208,33 @@ jobs:
|
||||
apps/desktop/release/*.zip*
|
||||
apps/desktop/release/*.exe*
|
||||
apps/desktop/release/*.AppImage
|
||||
apps/desktop/release/*.deb*
|
||||
apps/desktop/release/*.snap*
|
||||
apps/desktop/release/*.rpm*
|
||||
apps/desktop/release/*.tar.gz*
|
||||
retention-days: 5
|
||||
|
||||
publish-pr:
|
||||
# 合并 macOS 多架构 latest-mac.yml 文件
|
||||
merge-mac-files:
|
||||
needs: [build, version]
|
||||
name: Publish PR Build
|
||||
name: Merge macOS Release Files for PR
|
||||
runs-on: ubuntu-latest
|
||||
# Grant write permissions for creating release and commenting on PR
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
outputs:
|
||||
artifact_path: ${{ steps.set_path.outputs.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
# 下载所有平台的构建产物
|
||||
- name: Download artifacts
|
||||
@@ -208,14 +244,62 @@ jobs:
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
|
||||
# 列出下载的构建产物
|
||||
- name: List downloaded artifacts
|
||||
run: ls -R release
|
||||
|
||||
# 仅为该步骤在脚本目录安装 yaml 单包,避免安装整个 monorepo 依赖
|
||||
- name: Install yaml only for merge step
|
||||
run: |
|
||||
cd scripts/electronWorkflow
|
||||
# 在脚本目录创建最小 package.json,防止 bun 向上寻找根 package.json
|
||||
if [ ! -f package.json ]; then
|
||||
echo '{"name":"merge-mac-release","private":true}' > package.json
|
||||
fi
|
||||
bun add --no-save yaml@2.8.1
|
||||
|
||||
# 合并 macOS YAML 文件 (使用 bun 运行 JavaScript)
|
||||
- name: Merge latest-mac.yml files
|
||||
run: bun run scripts/electronWorkflow/mergeMacReleaseFiles.js
|
||||
|
||||
# 上传合并后的构建产物
|
||||
- name: Upload artifacts with merged macOS files
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: merged-release-pr
|
||||
path: release/
|
||||
retention-days: 1
|
||||
|
||||
publish-pr:
|
||||
needs: [merge-mac-files, version]
|
||||
name: Publish PR Build
|
||||
runs-on: ubuntu-latest
|
||||
# Grant write permissions for creating release and commenting on PR
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
outputs:
|
||||
artifact_path: ${{ steps.set_path.outputs.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# 下载合并后的构建产物
|
||||
- name: Download merged artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: merged-release-pr
|
||||
path: release
|
||||
|
||||
# 列出所有构建产物
|
||||
- name: List artifacts
|
||||
- name: List final artifacts
|
||||
run: ls -R release
|
||||
|
||||
# 生成PR发布描述
|
||||
- name: Generate PR Release Body
|
||||
id: pr_release_body
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
@@ -245,12 +329,16 @@ jobs:
|
||||
release/*.zip*
|
||||
release/*.exe*
|
||||
release/*.AppImage
|
||||
release/*.deb*
|
||||
release/*.snap*
|
||||
release/*.rpm*
|
||||
release/*.tar.gz*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# 在 PR 上添加评论,包含构建信息和下载链接
|
||||
- name: Comment on PR
|
||||
uses: actions/github-script@v7
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: .
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -159,3 +159,21 @@ jobs:
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
|
||||
- name: Comment on PR with Docker build info
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const prComment = require('${{ github.workspace }}/.github/scripts/docker-pr-comment.js');
|
||||
const result = await prComment({
|
||||
github,
|
||||
context,
|
||||
dockerMetaJson: ${{ toJSON(steps.meta.outputs.json) }},
|
||||
image: "${{ env.REGISTRY_IMAGE }}",
|
||||
version: "${{ steps.meta.outputs.version }}",
|
||||
dockerhubUrl: "https://hub.docker.com/r/${{ env.REGISTRY_IMAGE }}/tags",
|
||||
platforms: "linux/amd64, linux/arm64",
|
||||
});
|
||||
core.info(`Status: ${result.updated ? 'Updated' : 'Created'}, ID: ${result.id}`);
|
||||
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: .
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: .
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@ jobs:
|
||||
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
|
||||
env:
|
||||
REPO_BRANCH: ${{ matrix.REPO_BRANCH || env.REPO_BRANCH }}
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
repository: ${{ env.REPOSITORY }}
|
||||
token: ${{ secrets[matrix.TOKEN_NAME] || secrets[env.TOKEN_NAME] }}
|
||||
ref: ${{ env.BRANCH }}
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
repository: 'myactionway/lighthouse-badges'
|
||||
path: temp_lighthouse_badges_nested
|
||||
|
||||
@@ -19,25 +19,26 @@ jobs:
|
||||
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
version: 9
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: pnpm install
|
||||
run: bun i
|
||||
|
||||
- name: Lint
|
||||
run: pnpm run lint
|
||||
run: bun run lint
|
||||
|
||||
version:
|
||||
name: Determine version
|
||||
@@ -47,14 +48,15 @@ jobs:
|
||||
version: ${{ steps.set_version.outputs.version }}
|
||||
is_pr_build: ${{ steps.set_version.outputs.is_pr_build }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
# 主要逻辑:确定构建版本号
|
||||
- name: Set version
|
||||
@@ -80,24 +82,25 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-2025, ubuntu-latest]
|
||||
os: [macos-latest, macos-13, windows-2025, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
run_install: false
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9
|
||||
package-manager-cache: false
|
||||
|
||||
# node-linker=hoisted 模式将可以确保 asar 压缩可用
|
||||
- name: Install deps
|
||||
- name: Install dependencies
|
||||
run: pnpm install --node-linker=hoisted
|
||||
|
||||
- name: Install deps on Desktop
|
||||
@@ -154,7 +157,29 @@ jobs:
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_BETA_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_BETA_DESKTOP_BASE_URL }}
|
||||
|
||||
# 上传构建产物,移除了 zip 相关部分
|
||||
# 处理 macOS latest-mac.yml 重命名 (避免多架构覆盖)
|
||||
- name: Rename macOS latest-mac.yml for multi-architecture support
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
cd apps/desktop/release
|
||||
if [ -f "latest-mac.yml" ]; then
|
||||
# 使用系统架构检测,与 electron-builder 输出保持一致
|
||||
SYSTEM_ARCH=$(uname -m)
|
||||
if [[ "$SYSTEM_ARCH" == "arm64" ]]; then
|
||||
ARCH_SUFFIX="arm64"
|
||||
else
|
||||
ARCH_SUFFIX="x64"
|
||||
fi
|
||||
|
||||
mv latest-mac.yml "latest-mac-${ARCH_SUFFIX}.yml"
|
||||
echo "✅ Renamed latest-mac.yml to latest-mac-${ARCH_SUFFIX}.yml (detected: $SYSTEM_ARCH)"
|
||||
ls -la latest-mac-*.yml
|
||||
else
|
||||
echo "⚠️ latest-mac.yml not found, skipping rename"
|
||||
ls -la latest*.yml || echo "No latest*.yml files found"
|
||||
fi
|
||||
|
||||
# 上传构建产物 (工作流处理重命名,不依赖 electron-builder 钩子)
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
@@ -165,19 +190,34 @@ jobs:
|
||||
apps/desktop/release/*.zip*
|
||||
apps/desktop/release/*.exe*
|
||||
apps/desktop/release/*.AppImage
|
||||
apps/desktop/release/*.deb*
|
||||
apps/desktop/release/*.snap*
|
||||
apps/desktop/release/*.rpm*
|
||||
apps/desktop/release/*.tar.gz*
|
||||
retention-days: 5
|
||||
|
||||
# 正式版发布 job
|
||||
publish-release:
|
||||
# 合并 macOS 多架构 latest-mac.yml 文件
|
||||
merge-mac-files:
|
||||
needs: [build, version]
|
||||
name: Publish Beta Release
|
||||
name: Merge macOS Release Files
|
||||
runs-on: ubuntu-latest
|
||||
# Grant write permission to contents for uploading release assets
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
artifact_path: ${{ steps.set_path.outputs.path }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
# 下载所有平台的构建产物
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -186,11 +226,52 @@ jobs:
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
|
||||
# 列出所有构建产物
|
||||
- name: List artifacts
|
||||
# 列出下载的构建产物
|
||||
- name: List downloaded artifacts
|
||||
run: ls -R release
|
||||
|
||||
# 将构建产物上传到现有 release
|
||||
# 仅为该步骤在脚本目录安装 yaml 单包,避免安装整个 monorepo 依赖
|
||||
- name: Install yaml only for merge step
|
||||
run: |
|
||||
cd scripts/electronWorkflow
|
||||
# 在脚本目录创建最小 package.json,防止 bun 向上寻找根 package.json
|
||||
if [ ! -f package.json ]; then
|
||||
echo '{"name":"merge-mac-release","private":true}' > package.json
|
||||
fi
|
||||
bun add --no-save yaml@2.8.1
|
||||
|
||||
# 合并 macOS YAML 文件 (使用 bun 运行 JavaScript)
|
||||
- name: Merge latest-mac.yml files
|
||||
run: bun run scripts/electronWorkflow/mergeMacReleaseFiles.js
|
||||
|
||||
# 上传合并后的构建产物
|
||||
- name: Upload artifacts with merged macOS files
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: merged-release
|
||||
path: release/
|
||||
retention-days: 1
|
||||
|
||||
# 发布所有平台构建产物
|
||||
publish-release:
|
||||
needs: [merge-mac-files]
|
||||
name: Publish Beta Release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
# 下载合并后的构建产物
|
||||
- name: Download merged artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: merged-release
|
||||
path: release
|
||||
|
||||
# 列出所有构建产物
|
||||
- name: List final artifacts
|
||||
run: ls -R release
|
||||
|
||||
# 将构建产物上传到现有 release (现在包含合并后的 latest-mac.yml)
|
||||
- name: Upload to Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
@@ -201,5 +282,9 @@ jobs:
|
||||
release/*.zip*
|
||||
release/*.exe*
|
||||
release/*.AppImage
|
||||
release/*.deb*
|
||||
release/*.snap*
|
||||
release/*.rpm*
|
||||
release/*.tar.gz*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -11,24 +11,29 @@ jobs:
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: pgvector/pgvector:pg16
|
||||
image: paradedb/paradedb:latest
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
options: >-
|
||||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
|
||||
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
@@ -38,8 +43,8 @@ jobs:
|
||||
- name: Lint
|
||||
run: bun run lint
|
||||
|
||||
- name: Test Server Coverage
|
||||
run: bun run test-server:coverage
|
||||
- name: Test Database Coverage
|
||||
run: bun run --filter @lobechat/database test
|
||||
env:
|
||||
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
||||
DATABASE_DRIVER: node
|
||||
@@ -48,8 +53,8 @@ jobs:
|
||||
S3_PUBLIC_DOMAIN: https://example.com
|
||||
APP_URL: https://home.com
|
||||
|
||||
- name: Test App Coverage
|
||||
run: bun run test-app:coverage
|
||||
- name: Test App
|
||||
run: bun run test-app
|
||||
|
||||
- name: Release
|
||||
run: bun run release
|
||||
|
||||
@@ -11,13 +11,15 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Install dbdocs
|
||||
run: sudo npm install -g dbdocs
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Check dbdocs
|
||||
run: dbdocs
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: sync database schema to dbdocs
|
||||
env:
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
if: ${{ github.event.repository.fork }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Clean issue notice
|
||||
uses: actions-cool/issues-helper@v3
|
||||
|
||||
+134
-19
@@ -2,8 +2,125 @@ name: Test CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
# Package tests - using each package's own test script
|
||||
test-intenral-packages:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
package:
|
||||
- file-loaders
|
||||
- prompts
|
||||
- model-runtime
|
||||
- web-crawler
|
||||
- electron-server-ipc
|
||||
- utils
|
||||
- context-engine
|
||||
- agent-runtime
|
||||
|
||||
name: Test package ${{ matrix.package }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Test ${{ matrix.package }} package with coverage
|
||||
run: bun run --filter @lobechat/${{ matrix.package }} test:coverage
|
||||
|
||||
- name: Upload ${{ matrix.package }} coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./packages/${{ matrix.package }}/coverage/lcov.info
|
||||
flags: packages/${{ matrix.package }}
|
||||
|
||||
test-packages:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
package: [model-bank]
|
||||
|
||||
name: Test package ${{ matrix.package }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Test ${{ matrix.package }} package with coverage
|
||||
run: bun run --filter ${{ matrix.package }} test:coverage
|
||||
|
||||
- name: Upload ${{ matrix.package }} coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./packages/${{ matrix.package }}/coverage/lcov.info
|
||||
flags: packages/${{ matrix.package }}
|
||||
|
||||
# App tests
|
||||
test-website:
|
||||
name: Test Website
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Test App Coverage
|
||||
run: bun run test-app:coverage
|
||||
|
||||
- name: Upload App Coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage/app/lcov.info
|
||||
flags: app
|
||||
|
||||
test-databsae:
|
||||
name: Test Database
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
@@ -19,15 +136,16 @@ jobs:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
package-manager-cache: false
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
@@ -37,8 +155,15 @@ jobs:
|
||||
- name: Lint
|
||||
run: bun run lint
|
||||
|
||||
- name: Test Server Coverage
|
||||
run: bun run test-server:coverage
|
||||
- name: Test Client DB
|
||||
run: bun run --filter @lobechat/database test:client-db
|
||||
env:
|
||||
KEY_VAULTS_SECRET: LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=
|
||||
S3_PUBLIC_DOMAIN: https://example.com
|
||||
APP_URL: https://home.com
|
||||
|
||||
- name: Test Coverage
|
||||
run: bun run --filter @lobechat/database test:coverage
|
||||
env:
|
||||
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
||||
DATABASE_DRIVER: node
|
||||
@@ -47,19 +172,9 @@ jobs:
|
||||
S3_PUBLIC_DOMAIN: https://example.com
|
||||
APP_URL: https://home.com
|
||||
|
||||
- name: Upload Server coverage to Codecov
|
||||
- name: Upload Database coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage/server/lcov.info
|
||||
flags: server
|
||||
|
||||
- name: Test App Coverage
|
||||
run: bun run test-app:coverage
|
||||
|
||||
- name: Upload App Coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage/app/lcov.info
|
||||
flags: app
|
||||
files: ./packages/database/coverage/lcov.info
|
||||
flags: database
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
name: Wiki Sync
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- 'docs/wiki/**'
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
update-wiki:
|
||||
runs-on: ubuntu-latest
|
||||
name: Wiki sync
|
||||
steps:
|
||||
- uses: OrlovM/Wiki-Action@v1
|
||||
with:
|
||||
path: 'docs/wiki'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
+10
-3
@@ -19,11 +19,11 @@ Desktop.ini
|
||||
|
||||
# IDE and editors
|
||||
.idea/
|
||||
.vscode/
|
||||
*.sublime-*
|
||||
.history/
|
||||
.windsurfrules
|
||||
*.code-workspace
|
||||
.vscode/sessions.json
|
||||
|
||||
# Temporary files
|
||||
.temp/
|
||||
@@ -39,6 +39,7 @@ tmp/
|
||||
.env
|
||||
.env.local
|
||||
.env*.local
|
||||
.env.development
|
||||
venv/
|
||||
.venv/
|
||||
|
||||
@@ -102,11 +103,17 @@ vertex-ai-key.json
|
||||
.local/
|
||||
.claude/
|
||||
.mcp.json
|
||||
CLAUDE.md
|
||||
CLAUDE.*.md
|
||||
|
||||
CLAUDE.local.md
|
||||
|
||||
# MCP tools
|
||||
.serena/**
|
||||
|
||||
# Misc
|
||||
./packages/lobe-ui
|
||||
*.ppt*
|
||||
*.doc*
|
||||
*.xls*
|
||||
|
||||
prd
|
||||
GEMINI.md
|
||||
|
||||
@@ -4,6 +4,9 @@ resolution-mode=highest
|
||||
ignore-workspace-root-check=true
|
||||
enable-pre-post-scripts=true
|
||||
|
||||
# Load dotenv files for all the npm scripts
|
||||
node-options="--require dotenv-expand/config"
|
||||
|
||||
public-hoist-pattern[]=*@umijs/lint*
|
||||
public-hoist-pattern[]=*changelog*
|
||||
public-hoist-pattern[]=*commitlint*
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
.DS_Store
|
||||
.editorconfig
|
||||
.idea
|
||||
.vscode
|
||||
.history
|
||||
.temp
|
||||
.env.local
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# Stylelintignore for LobeHub
|
||||
################################################################
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
# ci
|
||||
coverage
|
||||
.coverage
|
||||
|
||||
# production
|
||||
dist
|
||||
es
|
||||
lib
|
||||
logs
|
||||
|
||||
# framework specific
|
||||
.next
|
||||
.umi
|
||||
.umi-production
|
||||
.umi-test
|
||||
.dumi/tmp*
|
||||
|
||||
# temporary directories
|
||||
tmp
|
||||
temp
|
||||
.temp
|
||||
.local
|
||||
docs/.local
|
||||
|
||||
# cache directories
|
||||
.cache
|
||||
|
||||
# AI coding tools directories
|
||||
.claude
|
||||
.serena
|
||||
|
||||
# MCP tools
|
||||
/.serena/**
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"Anthropic.claude-code",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"jrr997.antd-docs",
|
||||
"seatonjiang.gitmoji-vscode",
|
||||
"styled-components.vscode-styled-components",
|
||||
"stylelint.vscode-stylelint",
|
||||
"unifiedjs.vscode-mdx",
|
||||
"unifiedjs.vscode-remark",
|
||||
"vitest.explorer",
|
||||
]
|
||||
}
|
||||
Vendored
+95
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.addMissingImports": "explicit",
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.fixAll.stylelint": "explicit"
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
// don't show errors, but fix when save and git pre commit
|
||||
"eslint.rules.customizations": [
|
||||
{ "rule": "import/order", "severity": "off" },
|
||||
{ "rule": "prettier/prettier", "severity": "off" },
|
||||
{ "rule": "react/jsx-sort-props", "severity": "off" },
|
||||
{ "rule": "sort-keys-fix/sort-keys-fix", "severity": "off" },
|
||||
{ "rule": "typescript-sort-keys/interface", "severity": "off" }
|
||||
],
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
// support mdx
|
||||
"mdx"
|
||||
],
|
||||
"npm.packageManager": "pnpm",
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
// useless to search this big folder
|
||||
"locales": true
|
||||
},
|
||||
"stylelint.validate": [
|
||||
"css",
|
||||
"postcss",
|
||||
// make stylelint work with tsx antd-style css template string
|
||||
"typescriptreact"
|
||||
],
|
||||
"vitest.maximumConfigs": 20,
|
||||
"workbench.editor.customLabels.patterns": {
|
||||
"**/app/**/[[]*[]]/[[]*[]]/page.tsx": "${dirname(2)}/${dirname(1)}/${dirname} • page component",
|
||||
"**/app/**/[[]*[]]/page.tsx": "${dirname(1)}/${dirname} • page component",
|
||||
"**/app/**/page.tsx": "${dirname} • page component",
|
||||
|
||||
"**/app/**/[[]*[]]/[[]*[]]/layout.tsx": "${dirname(2)}/${dirname(1)}/${dirname} • page layout",
|
||||
"**/app/**/[[]*[]]/layout.tsx": "${dirname(1)}/${dirname} • page layout",
|
||||
"**/app/**/layout.tsx": "${dirname} • page layout",
|
||||
|
||||
"**/app/**/[[]*[]]/[[]*[]]/default.tsx": "${dirname(2)}/${dirname(1)}/${dirname} • slot default",
|
||||
"**/app/**/[[]*[]]/default.tsx": "${dirname(1)}/${dirname} • slot default",
|
||||
"**/app/**/default.tsx": "${dirname} • slot default",
|
||||
|
||||
"**/app/**/[[]*[]]/[[]*[]]/error.tsx": "${dirname(2)}/${dirname(1)}/${dirname} • error component",
|
||||
"**/app/**/[[]*[]]/error.tsx": "${dirname(1)}/${dirname} • error component",
|
||||
"**/app/**/error.tsx": "${dirname} • error component",
|
||||
|
||||
"**/app/**/[[]*[]]/[[]*[]]/loading.tsx": "${dirname(2)}/${dirname(1)}/${dirname} • loading component",
|
||||
"**/app/**/[[]*[]]/loading.tsx": "${dirname(1)}/${dirname} • loading component",
|
||||
"**/app/**/loading.tsx": "${dirname} • loading component",
|
||||
|
||||
"**/src/**/route.ts": "${dirname(1)}/${dirname} • route",
|
||||
"**/src/**/index.tsx": "${dirname} • component",
|
||||
|
||||
"**/packages/database/src/repositories/*/index.ts": "${dirname} • db repository",
|
||||
"**/packages/database/src/models/*.ts": "${filename} • db model",
|
||||
"**/packages/database/src/schemas/*.ts": "${filename} • db schema",
|
||||
|
||||
"**/src/services/*.ts": "${filename} • service",
|
||||
"**/src/services/*/client.ts": "${dirname} • client service",
|
||||
"**/src/services/*/server.ts": "${dirname} • server service",
|
||||
|
||||
"**/src/store/*/action.ts": "${dirname} • action",
|
||||
"**/src/store/*/slices/*/action.ts": "${dirname(2)}/${dirname} • action",
|
||||
"**/src/store/*/slices/*/actions/*.ts": "${dirname(1)}/${dirname}/${filename} • action",
|
||||
|
||||
"**/src/store/*/initialState.ts": "${dirname} • state",
|
||||
"**/src/store/*/slices/*/initialState.ts": "${dirname(2)}/${dirname} • state",
|
||||
|
||||
"**/src/store/*/selectors.ts": "${dirname} • selectors",
|
||||
"**/src/store/*/slices/*/selectors.ts": "${dirname(2)}/${dirname} • selectors",
|
||||
|
||||
"**/src/store/*/reducer.ts": "${dirname} • reducer",
|
||||
"**/src/store/*/slices/*/reducer.ts": "${dirname(2)}/${dirname} • reducer",
|
||||
|
||||
"**/src/config/modelProviders/*.ts": "${filename} • provider",
|
||||
"**/packages/model-bank/src/aiModels/*.ts": "${filename} • model",
|
||||
"**/packages/model-runtime/src/*/index.ts": "${dirname} • runtime",
|
||||
|
||||
"**/src/server/services/*/index.ts": "${dirname} • server/service",
|
||||
"**/src/server/routers/lambda/*.ts": "${filename} • lambda",
|
||||
"**/src/server/routers/async/*.ts": "${filename} • async",
|
||||
"**/src/server/routers/edge/*.ts": "${filename} • edge",
|
||||
|
||||
"**/src/locales/default/*.ts": "${filename} • locale",
|
||||
|
||||
"**/index.*": "${dirname}/${filename}.${extname}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
# LobeChat Development Guidelines
|
||||
|
||||
This document serves as a comprehensive guide for all team members when developing LobeChat.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
Built with modern technologies:
|
||||
|
||||
- **Frontend**: Next.js 15, React 19, TypeScript
|
||||
- **UI Components**: Ant Design, @lobehub/ui, antd-style
|
||||
- **State Management**: Zustand, SWR
|
||||
- **Database**: PostgreSQL, PGLite, Drizzle ORM
|
||||
- **Testing**: Vitest, Testing Library
|
||||
- **Package Manager**: pnpm (monorepo structure)
|
||||
- **Build Tools**: Next.js (Turbopack in dev, Webpack in prod)
|
||||
|
||||
## Directory Structure
|
||||
|
||||
The project follows a well-organized monorepo structure:
|
||||
|
||||
- `apps/` - Main applications
|
||||
- `packages/` - Shared packages and libraries
|
||||
- `src/` - Main source code
|
||||
- `docs/` - Documentation
|
||||
- `.cursor/rules/` - Development rules and guidelines
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Git Workflow
|
||||
|
||||
- Use rebase for git pull
|
||||
- Git commit messages should prefix with gitmoji
|
||||
- Git branch name format: `username/feat/feature-name`
|
||||
- Use `.github/PULL_REQUEST_TEMPLATE.md` for PR descriptions
|
||||
|
||||
### Package Management
|
||||
|
||||
- Use `pnpm` as the primary package manager
|
||||
- Use `bun` to run npm scripts
|
||||
- Use `bunx` to run executable npm packages
|
||||
- Navigate to specific packages using `cd packages/<package-name>`
|
||||
|
||||
### Code Style Guidelines
|
||||
|
||||
#### TypeScript
|
||||
|
||||
- Follow strict TypeScript practices for type safety and code quality
|
||||
- Use proper type annotations
|
||||
- Prefer interfaces over types for object shapes
|
||||
- Use generics for reusable components
|
||||
|
||||
#### React Components
|
||||
|
||||
- Use functional components with hooks
|
||||
|
||||
#### Database Schema
|
||||
|
||||
- Follow Drizzle ORM naming conventions
|
||||
- Use plural snake_case for table names
|
||||
- Implement proper foreign key relationships
|
||||
- Follow the schema style guide
|
||||
|
||||
### Testing Strategy
|
||||
|
||||
**Required Rule**: `testing-guide/testing-guide.mdc`
|
||||
|
||||
**Commands**:
|
||||
|
||||
- Web: `bunx vitest run --silent='passed-only' '[file-path-pattern]'`
|
||||
- Packages: `cd packages/[package-name] && bunx vitest run --silent='passed-only' '[file-path-pattern]'`
|
||||
|
||||
**Important Notes**:
|
||||
|
||||
- Wrap file paths in single quotes to avoid shell expansion
|
||||
- Never run `bun run test` - this runs all tests and takes ~10 minutes
|
||||
- If a test fails twice, stop and ask for help
|
||||
- Always add tests for new code
|
||||
|
||||
### Type Checking
|
||||
|
||||
- Use `bun run type-check` to check for type errors
|
||||
- Ensure all TypeScript errors are resolved before committing
|
||||
|
||||
### Internationalization
|
||||
|
||||
- Add new keys to `src/locales/default/namespace.ts`
|
||||
- Translate at least `zh-CN` files for development preview
|
||||
- Use hierarchical nested objects, not flat keys
|
||||
- Don't run `pnpm i18n` manually (handled by CI)
|
||||
|
||||
## Available Development Rules
|
||||
|
||||
The project provides comprehensive rules in `.cursor/rules/` directory:
|
||||
|
||||
### Core Development
|
||||
|
||||
- `backend-architecture.mdc` - Three-layer architecture and data flow
|
||||
- `react-component.mdc` - Component patterns and UI library usage
|
||||
- `drizzle-schema-style-guide.mdc` - Database schema conventions
|
||||
- `define-database-model.mdc` - Model templates and CRUD patterns
|
||||
- `i18n.mdc` - Internationalization workflow
|
||||
|
||||
### State Management & UI
|
||||
|
||||
- `zustand-slice-organization.mdc` - Store organization patterns
|
||||
- `zustand-action-patterns.mdc` - Action implementation patterns
|
||||
- `packages/react-layout-kit.mdc` - Flex layout component usage
|
||||
|
||||
### Testing & Quality
|
||||
|
||||
- `testing-guide/testing-guide.mdc` - Comprehensive testing strategy
|
||||
- `code-review.mdc` - Code review process and standards
|
||||
|
||||
### Desktop (Electron)
|
||||
|
||||
- `desktop-feature-implementation.mdc` - Main/renderer process patterns
|
||||
- `desktop-local-tools-implement.mdc` - Tool integration workflow
|
||||
- `desktop-menu-configuration.mdc` - Menu system configuration
|
||||
- `desktop-window-management.mdc` - Window management patterns
|
||||
- `desktop-controller-tests.mdc` - Controller testing guide
|
||||
|
||||
## Best Practices
|
||||
|
||||
- **Conservative for existing code, modern approaches for new features**
|
||||
- **Code Language**: Use Chinese for files with existing Chinese comments, American English for new files
|
||||
- Always add tests for new functionality
|
||||
- Follow the established patterns in the codebase
|
||||
- Use proper error handling and logging
|
||||
- Implement proper accessibility features
|
||||
- Consider internationalization from the start
|
||||
+3121
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,100 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This document serves as a shared guideline for all team members when using Claude Code in this repository.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
read @.cursor/rules/project-introduce.mdc
|
||||
|
||||
## Directory Structure
|
||||
|
||||
read @.cursor/rules/project-structure.mdc
|
||||
|
||||
## Development
|
||||
|
||||
### Git Workflow
|
||||
|
||||
- use rebase for git pull
|
||||
- git commit message should prefix with gitmoji
|
||||
- git branch name format example: tj/feat/feature-name
|
||||
- use .github/PULL_REQUEST_TEMPLATE.md to generate pull request description
|
||||
|
||||
### Package Management
|
||||
|
||||
This repository adopts a monorepo structure.
|
||||
|
||||
- Use `pnpm` as the primary package manager for dependency management
|
||||
- Use `bun` to run npm scripts
|
||||
- Use `bunx` to run executable npm packages
|
||||
|
||||
### TypeScript Code Style Guide
|
||||
|
||||
see @.cursor/rules/typescript.mdc
|
||||
|
||||
### Modify Code Rules
|
||||
|
||||
- **Code Language**:
|
||||
- For files with existing Chinese comments: Continue using Chinese to maintain consistency
|
||||
- For new files or files without Chinese comments: MUST use American English.
|
||||
- eg: new react tsx file and new test file
|
||||
- Conservative for existing code, modern approaches for new features
|
||||
|
||||
### Testing
|
||||
|
||||
Testing work follows the Rule-Aware Task Execution system above.
|
||||
|
||||
- **Required Rule**: `testing-guide/testing-guide.mdc`
|
||||
- **Command**:
|
||||
- web: `bunx vitest run --silent='passed-only' '[file-path-pattern]'`
|
||||
- packages(eg: database): `cd packages/database && bunx vitest run --silent='passed-only' '[file-path-pattern]'`
|
||||
|
||||
**Important**:
|
||||
|
||||
- wrapped the file path in single quotes to avoid shell expansion
|
||||
- Never run `bun run test` etc to run tests, this will run all tests and cost about 10mins
|
||||
- If try to fix the same test twice, but still failed, stop and ask for help.
|
||||
|
||||
### Typecheck
|
||||
|
||||
- use `bun run type-check` to check type errors.
|
||||
|
||||
### i18n
|
||||
|
||||
- **Keys**: Add to `src/locales/default/namespace.ts`
|
||||
- **Dev**: Translate `locales/zh-CN/namespace.json` locale file only for preview
|
||||
- DON'T run `pnpm i18n`, let CI auto handle it
|
||||
|
||||
## Rules Index
|
||||
|
||||
Some useful rules of this project. Read them when needed.
|
||||
|
||||
**IMPORTANT**: All rule files referenced in this document are located in the `.cursor/rules/` directory. Throughout this document, rule files are referenced by their filename only for brevity.
|
||||
|
||||
### 📋 Complete Rule Files
|
||||
|
||||
**Core Development**
|
||||
|
||||
- `backend-architecture.mdc` - Three-layer architecture, data flow
|
||||
- `react-component.mdc` - antd-style, Lobe UI usage
|
||||
- `drizzle-schema-style-guide.mdc` - Schema naming, patterns
|
||||
- `define-database-model.mdc` - Model templates, CRUD patterns
|
||||
- `i18n.mdc` - Internationalization workflow
|
||||
|
||||
**State & UI**
|
||||
|
||||
- `zustand-slice-organization.mdc` - Store organization
|
||||
- `zustand-action-patterns.mdc` - Action patterns
|
||||
- `packages/react-layout-kit.mdc` - flex layout components usage
|
||||
|
||||
**Testing & Quality**
|
||||
|
||||
- `testing-guide/testing-guide.mdc` - Test strategy, mock patterns
|
||||
- `code-review.mdc` - Review process and standards
|
||||
|
||||
**Desktop (Electron)**
|
||||
|
||||
- `desktop-feature-implementation.mdc` - Main/renderer process patterns
|
||||
- `desktop-local-tools-implement.mdc` - Tool integration workflow
|
||||
- `desktop-menu-configuration.mdc` - App menu, context menu, tray menu
|
||||
- `desktop-window-management.mdc` - Window creation, state management, multi-window
|
||||
- `desktop-controller-tests.mdc` - Controller unit testing guide
|
||||
+14
-4
@@ -1,5 +1,5 @@
|
||||
## Set global build ENV
|
||||
ARG NODEJS_VERSION="22"
|
||||
ARG NODEJS_VERSION="24"
|
||||
|
||||
## Base image for all building stages
|
||||
FROM node:${NODEJS_VERSION}-slim AS base
|
||||
@@ -66,7 +66,7 @@ ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
|
||||
|
||||
# Node
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
ENV NODE_OPTIONS="--max-old-space-size=6144"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -126,7 +126,7 @@ ENV NODE_ENV="production" \
|
||||
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
|
||||
NODE_EXTRA_CA_CERTS="" \
|
||||
NODE_TLS_REJECT_UNAUTHORIZED="" \
|
||||
SSL_CERT_DIR="/etc/ssl/certs/ca-certificates.crt"
|
||||
SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
# Make the middleware rewrite through local as default
|
||||
# refs: https://github.com/lobehub/lobe-chat/issues/5876
|
||||
@@ -194,6 +194,10 @@ ENV \
|
||||
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
|
||||
# Moonshot
|
||||
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
|
||||
# Nebius
|
||||
NEBIUS_API_KEY="" NEBIUS_MODEL_LIST="" NEBIUS_PROXY_URL="" \
|
||||
# NewAPI
|
||||
NEWAPI_API_KEY="" NEWAPI_PROXY_URL="" \
|
||||
# Novita
|
||||
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
|
||||
# Nvidia NIM
|
||||
@@ -249,7 +253,13 @@ ENV \
|
||||
# Infini-AI
|
||||
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST="" \
|
||||
# 302.AI
|
||||
AI302_API_KEY="" AI302_MODEL_LIST=""
|
||||
AI302_API_KEY="" AI302_MODEL_LIST="" \
|
||||
# FAL
|
||||
FAL_API_KEY="" FAL_MODEL_LIST="" \
|
||||
# BFL
|
||||
BFL_API_KEY="" BFL_MODEL_LIST="" \
|
||||
# Vercel AI Gateway
|
||||
VERCELAIGATEWAY_API_KEY="" VERCELAIGATEWAY_MODEL_LIST=""
|
||||
|
||||
USER nextjs
|
||||
|
||||
|
||||
+15
-5
@@ -1,5 +1,5 @@
|
||||
## Set global build ENV
|
||||
ARG NODEJS_VERSION="22"
|
||||
ARG NODEJS_VERSION="24"
|
||||
|
||||
## Base image for all building stages
|
||||
FROM node:${NODEJS_VERSION}-slim AS base
|
||||
@@ -74,7 +74,7 @@ ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
|
||||
|
||||
# Node
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
ENV NODE_OPTIONS="--max-old-space-size=6144"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -120,7 +120,7 @@ COPY --from=base /distroless/ /
|
||||
COPY --from=builder /app/.next/standalone /app/
|
||||
|
||||
# Copy database migrations
|
||||
COPY --from=builder /app/src/database/migrations /app/migrations
|
||||
COPY --from=builder /app/packages/database/migrations /app/migrations
|
||||
COPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs
|
||||
COPY --from=builder /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js
|
||||
|
||||
@@ -149,7 +149,7 @@ ENV NODE_ENV="production" \
|
||||
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
|
||||
NODE_EXTRA_CA_CERTS="" \
|
||||
NODE_TLS_REJECT_UNAUTHORIZED="" \
|
||||
SSL_CERT_DIR="/etc/ssl/certs/ca-certificates.crt"
|
||||
SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
# Make the middleware rewrite through local as default
|
||||
# refs: https://github.com/lobehub/lobe-chat/issues/5876
|
||||
@@ -236,6 +236,10 @@ ENV \
|
||||
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
|
||||
# Moonshot
|
||||
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
|
||||
# Nebius
|
||||
NEBIUS_API_KEY="" NEBIUS_MODEL_LIST="" NEBIUS_PROXY_URL="" \
|
||||
# NewAPI
|
||||
NEWAPI_API_KEY="" NEWAPI_PROXY_URL="" \
|
||||
# Novita
|
||||
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
|
||||
# Nvidia NIM
|
||||
@@ -291,7 +295,13 @@ ENV \
|
||||
# Infini-AI
|
||||
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST="" \
|
||||
# 302.AI
|
||||
AI302_API_KEY="" AI302_MODEL_LIST=""
|
||||
AI302_API_KEY="" AI302_MODEL_LIST="" \
|
||||
# FAL
|
||||
FAL_API_KEY="" FAL_MODEL_LIST="" \
|
||||
# BFL
|
||||
BFL_API_KEY="" BFL_MODEL_LIST="" \
|
||||
# Vercel AI Gateway
|
||||
VERCELAIGATEWAY_API_KEY="" VERCELAIGATEWAY_MODEL_LIST=""
|
||||
|
||||
USER nextjs
|
||||
|
||||
|
||||
+14
-4
@@ -1,5 +1,5 @@
|
||||
## Set global build ENV
|
||||
ARG NODEJS_VERSION="22"
|
||||
ARG NODEJS_VERSION="24"
|
||||
|
||||
## Base image for all building stages
|
||||
FROM node:${NODEJS_VERSION}-slim AS base
|
||||
@@ -68,7 +68,7 @@ ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
|
||||
|
||||
# Node
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
ENV NODE_OPTIONS="--max-old-space-size=6144"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -128,7 +128,7 @@ ENV NODE_ENV="production" \
|
||||
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
|
||||
NODE_EXTRA_CA_CERTS="" \
|
||||
NODE_TLS_REJECT_UNAUTHORIZED="" \
|
||||
SSL_CERT_DIR="/etc/ssl/certs/ca-certificates.crt"
|
||||
SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
# Make the middleware rewrite through local as default
|
||||
# refs: https://github.com/lobehub/lobe-chat/issues/5876
|
||||
@@ -196,6 +196,10 @@ ENV \
|
||||
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
|
||||
# Moonshot
|
||||
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
|
||||
# Nebius
|
||||
NEBIUS_API_KEY="" NEBIUS_MODEL_LIST="" NEBIUS_PROXY_URL="" \
|
||||
# NewAPI
|
||||
NEWAPI_API_KEY="" NEWAPI_PROXY_URL="" \
|
||||
# Novita
|
||||
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
|
||||
# Nvidia NIM
|
||||
@@ -247,7 +251,13 @@ ENV \
|
||||
# Infini-AI
|
||||
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST="" \
|
||||
# 302.AI
|
||||
AI302_API_KEY="" AI302_MODEL_LIST=""
|
||||
AI302_API_KEY="" AI302_MODEL_LIST="" \
|
||||
# FAL
|
||||
FAL_API_KEY="" FAL_MODEL_LIST="" \
|
||||
# BFL
|
||||
BFL_API_KEY="" BFL_MODEL_LIST="" \
|
||||
# Vercel AI Gateway
|
||||
VERCELAIGATEWAY_API_KEY="" VERCELAIGATEWAY_MODEL_LIST=""
|
||||
|
||||
USER nextjs
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
Apache License Version 2.0
|
||||
LobeHub Community License
|
||||
|
||||
Copyright (c) 2024/06/17 - current LobeHub LLC. All rights reserved.
|
||||
|
||||
----------
|
||||
|
||||
From 1.0, LobeChat is licensed under the Apache License 2.0, with the following additional conditions:
|
||||
From 1.0, LobeChat is licensed under the LobeHub Community License, based on Apache License 2.0 with the following additional conditions:
|
||||
|
||||
1. The commercial usage of LobeChat:
|
||||
|
||||
@@ -22,17 +22,3 @@ Please contact hello@lobehub.com by email to inquire about licensing matters.
|
||||
b. Your contributed code may be used for commercial purposes, including but not limited to its cloud edition.
|
||||
|
||||
Apart from the specific conditions mentioned above, all other rights and restrictions follow the Apache License 2.0. Detailed information about the Apache License 2.0 can be found at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
----------
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -150,7 +150,7 @@ From productivity tools to development environments, discover new ways to extend
|
||||
|
||||
**Peak Performance, Zero Distractions**
|
||||
|
||||
Get the full LobeChat experience without browser limitations—lightweight, focused, and always ready to go. Our desktop application provides a dedicated environment for your AI interactions, ensuring optimal performance and minimal distractions.
|
||||
Get the full LobeChat experience without browser limitations—comprehensive, focused, and always ready to go. Our desktop application provides a dedicated environment for your AI interactions, ensuring optimal performance and minimal distractions.
|
||||
|
||||
Experience faster response times, better resource management, and a more stable connection to your AI assistant. The desktop app is designed for users who demand the best performance from their AI tools.
|
||||
|
||||
@@ -255,6 +255,7 @@ We have implemented support for the following model service providers:
|
||||
- **[GitHub](https://lobechat.com/discover/provider/github)**: With GitHub Models, developers can become AI engineers and leverage the industry's leading AI models.
|
||||
- **[Novita](https://lobechat.com/discover/provider/novita)**: Novita AI is a platform providing a variety of large language models and AI image generation API services, flexible, reliable, and cost-effective. It supports the latest open-source models like Llama3 and Mistral, offering a comprehensive, user-friendly, and auto-scaling API solution for generative AI application development, suitable for the rapid growth of AI startups.
|
||||
- **[PPIO](https://lobechat.com/discover/provider/ppio)**: PPIO supports stable and cost-efficient open-source LLM APIs, such as DeepSeek, Llama, Qwen etc.
|
||||
- **[302.AI](https://lobechat.com/discover/provider/ai302)**: 302.AI is an on-demand AI application platform offering the most comprehensive AI APIs and online AI applications available on the market.
|
||||
- **[Together AI](https://lobechat.com/discover/provider/togetherai)**: Together AI is dedicated to achieving leading performance through innovative AI models, offering extensive customization capabilities, including rapid scaling support and intuitive deployment processes to meet various enterprise needs.
|
||||
- **[Fireworks AI](https://lobechat.com/discover/provider/fireworksai)**: Fireworks AI is a leading provider of advanced language model services, focusing on functional calling and multimodal processing. Its latest model, Firefunction V2, is based on Llama-3, optimized for function calling, conversation, and instruction following. The visual language model FireLLaVA-13B supports mixed input of images and text. Other notable models include the Llama series and Mixtral series, providing efficient multilingual instruction following and generation support.
|
||||
- **[Groq](https://lobechat.com/discover/provider/groq)**: Groq's LPU inference engine has excelled in the latest independent large language model (LLM) benchmarks, redefining the standards for AI solutions with its remarkable speed and efficiency. Groq represents instant inference speed, demonstrating strong performance in cloud-based deployments.
|
||||
@@ -283,7 +284,6 @@ We have implemented support for the following model service providers:
|
||||
- **[Search1API](https://lobechat.com/discover/provider/search1api)**: Search1API provides access to the DeepSeek series of models that can connect to the internet as needed, including standard and fast versions, supporting a variety of model sizes.
|
||||
- **[InfiniAI](https://lobechat.com/discover/provider/infiniai)**: Provides high-performance, easy-to-use, and secure large model services for application developers, covering the entire process from large model development to service deployment.
|
||||
- **[Qiniu](https://lobechat.com/discover/provider/qiniu)**: Qiniu, as a long-established cloud service provider, delivers cost-effective and reliable AI inference services for both real-time and batch processing, with a simple and user-friendly experience.
|
||||
- **[302.AI](https://lobechat.com/discover/provider/ai302)**: 302.AI is an on-demand AI application platform offering the most comprehensive AI APIs and online AI applications available on the market.
|
||||
|
||||
</details>
|
||||
|
||||
@@ -382,14 +382,14 @@ In addition, these plugins are not limited to news aggregation, but can also ext
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
| Recent Submits | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
||||
| [PortfolioMeta](https://lobechat.com/discover/plugin/StockData)<br/><sup>By **portfoliometa** on **2025-07-21**</sup> | Analyze stocks and get comprehensive real-time investment data and analytics.<br/>`stock` |
|
||||
| [Speak](https://lobechat.com/discover/plugin/speak)<br/><sup>By **speak** on **2025-07-18**</sup> | Learn how to say anything in another language with Speak, your AI-powered language tutor.<br/>`education` `language` |
|
||||
| [Web](https://lobechat.com/discover/plugin/web)<br/><sup>By **Proghit** on **2025-01-24**</sup> | Smart web search that reads and analyzes pages to deliver comprehensive answers from Google results.<br/>`web` `search` |
|
||||
| [Bing_websearch](https://lobechat.com/discover/plugin/Bingsearch-identifier)<br/><sup>By **FineHow** on **2024-12-22**</sup> | Search for information from the internet base BingApi<br/>`bingsearch` |
|
||||
| Recent Submits | Description |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [Web](https://lobechat.com/discover/plugin/web)<br/><sup>By **Proghit** on **2025-01-24**</sup> | Smart web search that reads and analyzes pages to deliver comprehensive answers from Google results.<br/>`web` `search` |
|
||||
| [Bing_websearch](https://lobechat.com/discover/plugin/Bingsearch-identifier)<br/><sup>By **FineHow** on **2024-12-22**</sup> | Search for information from the internet base BingApi<br/>`bingsearch` |
|
||||
| [Google CSE](https://lobechat.com/discover/plugin/google-cse)<br/><sup>By **vsnthdev** on **2024-12-02**</sup> | Searches Google through their official CSE API.<br/>`web` `search` |
|
||||
| [Tongyi wanxiang Image Generator](https://lobechat.com/discover/plugin/alps-tongyi-image)<br/><sup>By **YoungTx** on **2024-08-09**</sup> | This plugin uses Alibaba's Tongyi Wanxiang model to generate images based on text prompts.<br/>`image` `tongyi` `wanxiang` |
|
||||
|
||||
> 📊 Total plugins: [<kbd>**43**</kbd>](https://lobechat.com/discover/plugins)
|
||||
> 📊 Total plugins: [<kbd>**41**</kbd>](https://lobechat.com/discover/plugins)
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
@@ -481,7 +481,7 @@ We deeply understand the importance of providing a seamless experience for users
|
||||
Therefore, we have adopted Progressive Web Application ([PWA](https://support.google.com/chrome/answer/9658361)) technology,
|
||||
a modern web technology that elevates web applications to an experience close to that of native apps.
|
||||
|
||||
Through PWA, LobeChat can offer a highly optimized user experience on both desktop and mobile devices while maintaining its lightweight and high-performance characteristics.
|
||||
Through PWA, LobeChat can offer a highly optimized user experience on both desktop and mobile devices while maintaining high-performance characteristics.
|
||||
Visually and in terms of feel, we have also meticulously designed the interface to ensure it is indistinguishable from native apps,
|
||||
providing smooth animations, responsive layouts, and adapting to different device screen resolutions.
|
||||
|
||||
@@ -819,7 +819,7 @@ Every bit counts and your one-time donation sparkles in our galaxy of support! Y
|
||||
</details>
|
||||
|
||||
Copyright © 2025 [LobeHub][profile-link]. <br />
|
||||
This project is [Apache 2.0](./LICENSE) licensed.
|
||||
This project is [LobeHub Community License](./LICENSE) licensed.
|
||||
|
||||
<!-- LINK GROUP -->
|
||||
|
||||
|
||||
+9
-9
@@ -255,6 +255,7 @@ LobeChat 支持文件上传与知识库功能,你可以上传文件、图片
|
||||
- **[GitHub](https://lobechat.com/discover/provider/github)**: 通过 GitHub 模型,开发人员可以成为 AI 工程师,并使用行业领先的 AI 模型进行构建。
|
||||
- **[Novita](https://lobechat.com/discover/provider/novita)**: Novita AI 是一个提供多种大语言模型与 AI 图像生成的 API 服务的平台,灵活、可靠且具有成本效益。它支持 Llama3、Mistral 等最新的开源模型,并为生成式 AI 应用开发提供了全面、用户友好且自动扩展的 API 解决方案,适合 AI 初创公司的快速发展。
|
||||
- **[PPIO](https://lobechat.com/discover/provider/ppio)**: PPIO 派欧云提供稳定、高性价比的开源模型 API 服务,支持 DeepSeek 全系列、Llama、Qwen 等行业领先大模型。
|
||||
- **[302.AI](https://lobechat.com/discover/provider/ai302)**: 302.AI 是一个按需付费的 AI 应用平台,提供市面上最全的 AI API 和 AI 在线应用
|
||||
- **[Together AI](https://lobechat.com/discover/provider/togetherai)**: Together AI 致力于通过创新的 AI 模型实现领先的性能,提供广泛的自定义能力,包括快速扩展支持和直观的部署流程,满足企业的各种需求。
|
||||
- **[Fireworks AI](https://lobechat.com/discover/provider/fireworksai)**: Fireworks AI 是一家领先的高级语言模型服务商,专注于功能调用和多模态处理。其最新模型 Firefunction V2 基于 Llama-3,优化用于函数调用、对话及指令跟随。视觉语言模型 FireLLaVA-13B 支持图像和文本混合输入。其他 notable 模型包括 Llama 系列和 Mixtral 系列,提供高效的多语言指令跟随与生成支持。
|
||||
- **[Groq](https://lobechat.com/discover/provider/groq)**: Groq 的 LPU 推理引擎在最新的独立大语言模型(LLM)基准测试中表现卓越,以其惊人的速度和效率重新定义了 AI 解决方案的标准。Groq 是一种即时推理速度的代表,在基于云的部署中展现了良好的性能。
|
||||
@@ -283,7 +284,6 @@ LobeChat 支持文件上传与知识库功能,你可以上传文件、图片
|
||||
- **[Search1API](https://lobechat.com/discover/provider/search1api)**: Search1API 提供可根据需要自行联网的 DeepSeek 系列模型的访问,包括标准版和快速版本,支持多种参数规模的模型选择。
|
||||
- **[InfiniAI](https://lobechat.com/discover/provider/infiniai)**: 为应用开发者提供高性能、易上手、安全可靠的大模型服务,覆盖从大模型开发到大模型服务化部署的全流程。
|
||||
- **[Qiniu](https://lobechat.com/discover/provider/qiniu)**: 七牛作为老牌云服务厂商,提供高性价比稳定的实时、批量 AI 推理服务,简单易用。
|
||||
- **[302.AI](https://lobechat.com/discover/provider/ai302)**: 302.AI 是一个按需付费的 AI 应用平台,提供市面上最全的 AI API 和 AI 在线应用
|
||||
|
||||
</details>
|
||||
|
||||
@@ -375,14 +375,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
| 最近新增 | 描述 |
|
||||
| -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| [PortfolioMeta](https://lobechat.com/discover/plugin/StockData)<br/><sup>By **portfoliometa** on **2025-07-21**</sup> | 分析股票并获取全面的实时投资数据和分析。<br/>`股票` |
|
||||
| [Speak](https://lobechat.com/discover/plugin/speak)<br/><sup>By **speak** on **2025-07-18**</sup> | 使用 Speak,您的 AI 语言导师,学习如何用另一种语言说任何事情。<br/>`教育` `语言` |
|
||||
| [网页](https://lobechat.com/discover/plugin/web)<br/><sup>By **Proghit** on **2025-01-24**</sup> | 智能网页搜索,读取和分析页面,以提供来自 Google 结果的全面答案。<br/>`网页` `搜索` |
|
||||
| [必应网页搜索](https://lobechat.com/discover/plugin/Bingsearch-identifier)<br/><sup>By **FineHow** on **2024-12-22**</sup> | 通过 BingApi 搜索互联网上的信息<br/>`bingsearch` |
|
||||
| 最近新增 | 描述 |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| [网页](https://lobechat.com/discover/plugin/web)<br/><sup>By **Proghit** on **2025-01-24**</sup> | 智能网页搜索,读取和分析页面,以提供来自 Google 结果的全面答案。<br/>`网页` `搜索` |
|
||||
| [必应网页搜索](https://lobechat.com/discover/plugin/Bingsearch-identifier)<br/><sup>By **FineHow** on **2024-12-22**</sup> | 通过 BingApi 搜索互联网上的信息<br/>`bingsearch` |
|
||||
| [谷歌自定义搜索引擎](https://lobechat.com/discover/plugin/google-cse)<br/><sup>By **vsnthdev** on **2024-12-02**</sup> | 通过他们的官方自定义搜索引擎 API 搜索谷歌。<br/>`网络` `搜索` |
|
||||
| [通义万象图像生成器](https://lobechat.com/discover/plugin/alps-tongyi-image)<br/><sup>By **YoungTx** on **2024-08-09**</sup> | 此插件使用阿里巴巴的通义万象模型根据文本提示生成图像。<br/>`图像` `通义` `万象` |
|
||||
|
||||
> 📊 Total plugins: [<kbd>**43**</kbd>](https://lobechat.com/discover/plugins)
|
||||
> 📊 Total plugins: [<kbd>**41**</kbd>](https://lobechat.com/discover/plugins)
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
@@ -840,7 +840,7 @@ $ pnpm run dev
|
||||
</details>
|
||||
|
||||
Copyright © 2025 [LobeHub][profile-link]. <br />
|
||||
This project is [Apache 2.0](./LICENSE) licensed.
|
||||
This project is [LobeHub Community License](./LICENSE) licensed.
|
||||
|
||||
<!-- LINK GROUP -->
|
||||
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
const dotenv = require('dotenv');
|
||||
const os = require('node:os');
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const packageJSON = require('./package.json');
|
||||
|
||||
const channel = process.env.UPDATE_CHANNEL;
|
||||
const arch = os.arch();
|
||||
const hasAppleCertificate = Boolean(process.env.CSC_LINK);
|
||||
|
||||
console.log(`🚄 Build Version ${packageJSON.version}, Channel: ${channel}`);
|
||||
console.log(`🏗️ Building for architecture: ${arch}`);
|
||||
|
||||
const isNightly = channel === 'nightly';
|
||||
const isBeta = packageJSON.name.includes('beta');
|
||||
|
||||
// https://www.electron.build/code-signing-mac#how-to-disable-code-signing-during-the-build-process-on-macos
|
||||
if (!hasAppleCertificate) {
|
||||
// Disable auto discovery to keep electron-builder from searching unavailable signing identities
|
||||
process.env.CSC_IDENTITY_AUTO_DISCOVERY = 'false';
|
||||
console.log('⚠️ Apple certificate link not found, macOS artifacts will be unsigned.');
|
||||
}
|
||||
|
||||
// 根据版本类型确定协议 scheme
|
||||
const getProtocolScheme = () => {
|
||||
if (isNightly) return 'lobehub-nightly';
|
||||
@@ -64,7 +75,7 @@ const config = {
|
||||
linux: {
|
||||
category: 'Utility',
|
||||
maintainer: 'electronjs.org',
|
||||
target: ['AppImage', 'snap', 'deb'],
|
||||
target: ['AppImage', 'snap', 'deb', 'rpm', 'tar.gz'],
|
||||
},
|
||||
mac: {
|
||||
compression: 'maximum',
|
||||
@@ -84,15 +95,17 @@ const config = {
|
||||
NSMicrophoneUsageDescription: "Application requests access to the device's microphone.",
|
||||
},
|
||||
gatekeeperAssess: false,
|
||||
hardenedRuntime: true,
|
||||
notarize: true,
|
||||
hardenedRuntime: hasAppleCertificate,
|
||||
notarize: hasAppleCertificate,
|
||||
...(hasAppleCertificate ? {} : { identity: null }),
|
||||
target:
|
||||
// 降低构建时间,nightly 只打 arm64
|
||||
// 降低构建时间,nightly 只打 dmg
|
||||
// 根据当前机器架构只构建对应架构的包
|
||||
isNightly
|
||||
? [{ arch: ['arm64'], target: 'dmg' }]
|
||||
? [{ arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'dmg' }]
|
||||
: [
|
||||
{ arch: ['x64', 'arm64'], target: 'dmg' },
|
||||
{ arch: ['x64', 'arm64'], target: 'zip' },
|
||||
{ arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'dmg' },
|
||||
{ arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'zip' },
|
||||
],
|
||||
},
|
||||
npmRebuild: true,
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"dependencies": {
|
||||
"electron-updater": "^6.6.2",
|
||||
"electron-window-state": "^5.0.3",
|
||||
"fetch-socks": "^1.3.2",
|
||||
"get-port-please": "^3.1.2",
|
||||
"pdfjs-dist": "4.10.38"
|
||||
},
|
||||
@@ -51,14 +52,14 @@
|
||||
"@typescript/native-preview": "7.0.0-dev.20250711.1",
|
||||
"consola": "^3.1.0",
|
||||
"cookie": "^1.0.2",
|
||||
"electron": "^37.2.0",
|
||||
"electron": "^38.0.0",
|
||||
"electron-builder": "^26.0.12",
|
||||
"electron-is": "^3.0.0",
|
||||
"electron-log": "^5.3.3",
|
||||
"electron-store": "^8.2.0",
|
||||
"electron-vite": "^3.0.0",
|
||||
"execa": "^9.5.2",
|
||||
"fix-path": "^4.0.0",
|
||||
"fix-path": "^5.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
"just-diff": "^6.0.2",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { beforeEach, describe, expect, it, vi, Mock } from 'vitest';
|
||||
import { InterceptRouteParams } from '@lobechat/electron-client-ipc';
|
||||
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { AppBrowsersIdentifiers, BrowsersIdentifiers } from '@/appBrowsers';
|
||||
import type { App } from '@/core/App';
|
||||
import type { IpcClientEventSender } from '@/types/ipcClientEvent';
|
||||
import { BrowsersIdentifiers, AppBrowsersIdentifiers } from '@/appBrowsers';
|
||||
|
||||
import BrowserWindowsCtr from '../BrowserWindowsCtr';
|
||||
|
||||
@@ -33,12 +33,14 @@ const mockApp = {
|
||||
closeWindow: mockCloseWindow,
|
||||
minimizeWindow: mockMinimizeWindow,
|
||||
maximizeWindow: mockMaximizeWindow,
|
||||
retrieveByIdentifier: mockRetrieveByIdentifier.mockImplementation((identifier: AppBrowsersIdentifiers | string) => {
|
||||
if (identifier === BrowsersIdentifiers.settings || identifier === 'some-other-window') {
|
||||
return { show: mockShow };
|
||||
}
|
||||
return { show: mockShow }; // Default mock for other identifiers
|
||||
}),
|
||||
retrieveByIdentifier: mockRetrieveByIdentifier.mockImplementation(
|
||||
(identifier: AppBrowsersIdentifiers | string) => {
|
||||
if (identifier === BrowsersIdentifiers.settings || identifier === 'some-other-window') {
|
||||
return { show: mockShow };
|
||||
}
|
||||
return { show: mockShow }; // Default mock for other identifiers
|
||||
},
|
||||
),
|
||||
},
|
||||
} as unknown as App;
|
||||
|
||||
@@ -104,7 +106,11 @@ describe('BrowserWindowsCtr', () => {
|
||||
const baseParams = { source: 'link-click' as const };
|
||||
|
||||
it('should not intercept if no matching route is found', async () => {
|
||||
const params: InterceptRouteParams = { ...baseParams, path: '/unknown/route', url: 'app://host/unknown/route' };
|
||||
const params: InterceptRouteParams = {
|
||||
...baseParams,
|
||||
path: '/unknown/route',
|
||||
url: 'app://host/unknown/route',
|
||||
};
|
||||
(findMatchingRoute as Mock).mockReturnValue(undefined);
|
||||
const result = await browserWindowsCtr.interceptRoute(params);
|
||||
expect(findMatchingRoute).toHaveBeenCalledWith(params.path);
|
||||
@@ -112,7 +118,11 @@ describe('BrowserWindowsCtr', () => {
|
||||
});
|
||||
|
||||
it('should show settings window if matched route target is settings', async () => {
|
||||
const params: InterceptRouteParams = { ...baseParams, path: '/settings/common', url: 'app://host/settings/common' };
|
||||
const params: InterceptRouteParams = {
|
||||
...baseParams,
|
||||
path: '/settings?active=common',
|
||||
url: 'app://host/settings?active=common',
|
||||
};
|
||||
const matchedRoute = { targetWindow: BrowsersIdentifiers.settings, pathPrefix: '/settings' };
|
||||
const subPath = 'common';
|
||||
(findMatchingRoute as Mock).mockReturnValue(matchedRoute);
|
||||
@@ -134,7 +144,11 @@ describe('BrowserWindowsCtr', () => {
|
||||
});
|
||||
|
||||
it('should open target window if matched route target is not settings', async () => {
|
||||
const params: InterceptRouteParams = { ...baseParams, path: '/other/page', url: 'app://host/other/page' };
|
||||
const params: InterceptRouteParams = {
|
||||
...baseParams,
|
||||
path: '/other/page',
|
||||
url: 'app://host/other/page',
|
||||
};
|
||||
const targetWindowIdentifier = 'some-other-window' as AppBrowsersIdentifiers;
|
||||
const matchedRoute = { targetWindow: targetWindowIdentifier, pathPrefix: '/other' };
|
||||
(findMatchingRoute as Mock).mockReturnValue(matchedRoute);
|
||||
@@ -154,7 +168,11 @@ describe('BrowserWindowsCtr', () => {
|
||||
});
|
||||
|
||||
it('should return error if processing route interception fails for settings', async () => {
|
||||
const params: InterceptRouteParams = { ...baseParams, path: '/settings/general', url: 'app://host/settings/general' };
|
||||
const params: InterceptRouteParams = {
|
||||
...baseParams,
|
||||
path: '/settings?active=general',
|
||||
url: 'app://host/settings?active=general',
|
||||
};
|
||||
const matchedRoute = { targetWindow: BrowsersIdentifiers.settings, pathPrefix: '/settings' };
|
||||
const subPath = 'general';
|
||||
const errorMessage = 'Processing error for settings';
|
||||
@@ -173,7 +191,11 @@ describe('BrowserWindowsCtr', () => {
|
||||
});
|
||||
|
||||
it('should return error if processing route interception fails for other window', async () => {
|
||||
const params: InterceptRouteParams = { ...baseParams, path: '/another/custom', url: 'app://host/another/custom' };
|
||||
const params: InterceptRouteParams = {
|
||||
...baseParams,
|
||||
path: '/another/custom',
|
||||
url: 'app://host/another/custom',
|
||||
};
|
||||
const targetWindowIdentifier = 'another-custom-window' as AppBrowsersIdentifiers;
|
||||
const matchedRoute = { targetWindow: targetWindowIdentifier, pathPrefix: '/another' };
|
||||
const errorMessage = 'Processing error for other window';
|
||||
@@ -192,4 +214,4 @@ describe('BrowserWindowsCtr', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NetworkProxySettings } from '@lobechat/electron-client-ipc';
|
||||
import { SocksProxies, socksDispatcher } from 'fetch-socks';
|
||||
import { Agent, ProxyAgent, getGlobalDispatcher, setGlobalDispatcher } from 'undici';
|
||||
|
||||
import { createLogger } from '@/utils/logger';
|
||||
@@ -91,8 +92,29 @@ export class ProxyDispatcherManager {
|
||||
*/
|
||||
static createProxyAgent(proxyType: string, proxyUrl: string) {
|
||||
try {
|
||||
// undici 的 ProxyAgent 支持 http, https 和 socks5
|
||||
return new ProxyAgent({ uri: proxyUrl });
|
||||
if (proxyType === 'socks5') {
|
||||
// 解析 SOCKS5 代理 URL
|
||||
const url = new URL(proxyUrl);
|
||||
const socksProxies: SocksProxies = [
|
||||
{
|
||||
host: url.hostname,
|
||||
port: parseInt(url.port, 10),
|
||||
type: 5,
|
||||
...(url.username && url.password
|
||||
? {
|
||||
password: url.password,
|
||||
userId: url.username,
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
];
|
||||
|
||||
// 使用 fetch-socks 处理 SOCKS5 代理
|
||||
return socksDispatcher(socksProxies);
|
||||
} else {
|
||||
// undici 的 ProxyAgent 支持 http, https
|
||||
return new ProxyAgent({ uri: proxyUrl });
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(`Failed to create proxy agent for ${proxyType}:`, error);
|
||||
throw new Error(
|
||||
|
||||
@@ -1,4 +1,837 @@
|
||||
[
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Add proxyUrl configuration for NEW API provider."]
|
||||
},
|
||||
"date": "2025-09-25",
|
||||
"version": "1.132.15"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-25",
|
||||
"version": "1.132.14"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-25",
|
||||
"version": "1.132.13"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Slove setting proxy page with style error."]
|
||||
},
|
||||
"date": "2025-09-25",
|
||||
"version": "1.132.12"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": [
|
||||
"Enhanced Nvidia NIM chat experience, OpenAI models in AiHubMix use Responses API."
|
||||
]
|
||||
},
|
||||
"date": "2025-09-24",
|
||||
"version": "1.132.11"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Macos desktop sign."]
|
||||
},
|
||||
"date": "2025-09-24",
|
||||
"version": "1.132.10"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-23",
|
||||
"version": "1.132.9"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor all @/types in model runtime to @lobechat/types."]
|
||||
},
|
||||
"date": "2025-09-23",
|
||||
"version": "1.132.8"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-23",
|
||||
"version": "1.132.7"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-23",
|
||||
"version": "1.132.6"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Move the ModelProvider to model-bank."]
|
||||
},
|
||||
"date": "2025-09-22",
|
||||
"version": "1.132.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Enable thinkingBudget control for Vertex Gemini 2.5 models, update i18n."]
|
||||
},
|
||||
"date": "2025-09-22",
|
||||
"version": "1.132.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Added AUTH_MICROSOFT_ENTRA_ID_BASE_URL routing."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.132.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix non stream mode in OpenAI Response API."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.132.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix missing provider in server message."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.132.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Support google video understanding."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.132.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Enhanced AkashChat experience."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.131.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Update Responses search tool to web_search."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.131.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Use ID as name if provider name is empty."]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.131.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": [
|
||||
"Extend custom provider runtime options, Optimized modelFetch for Vercel AI Gateway, update i18n."
|
||||
]
|
||||
},
|
||||
"date": "2025-09-21",
|
||||
"version": "1.131.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Qwen provider add qwen-image-edit model support."]
|
||||
},
|
||||
"date": "2025-09-19",
|
||||
"version": "1.131.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix oidc open direct issue."]
|
||||
},
|
||||
"date": "2025-09-18",
|
||||
"version": "1.130.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Add scroll support for pinned assistants using ScrollShadow."]
|
||||
},
|
||||
"date": "2025-09-18",
|
||||
"version": "1.130.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix svg xss issue."]
|
||||
},
|
||||
"date": "2025-09-18",
|
||||
"version": "1.129.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Add qwen provider support for image-edit model."]
|
||||
},
|
||||
"date": "2025-09-17",
|
||||
"version": "1.129.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Improve db migrations sql."],
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-17",
|
||||
"version": "1.129.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update SiliconCloud reasoning models."]
|
||||
},
|
||||
"date": "2025-09-16",
|
||||
"version": "1.129.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Support Vercel AI Gateway provider."]
|
||||
},
|
||||
"date": "2025-09-16",
|
||||
"version": "1.129.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix azure ai runtime error."]
|
||||
},
|
||||
"date": "2025-09-16",
|
||||
"version": "1.128.10"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Improve error handle with agent config, support .doc file parse."]
|
||||
},
|
||||
"date": "2025-09-15",
|
||||
"version": "1.128.9"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": [
|
||||
"Enable toggling search on/off via search button click & historyCount button."
|
||||
]
|
||||
},
|
||||
"date": "2025-09-15",
|
||||
"version": "1.128.8"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-14",
|
||||
"version": "1.128.7"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-14",
|
||||
"version": "1.128.6"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Google stream error unable to abort request."]
|
||||
},
|
||||
"date": "2025-09-13",
|
||||
"version": "1.128.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Fix discover plugin link."]
|
||||
},
|
||||
"date": "2025-09-13",
|
||||
"version": "1.128.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix open chat page with float link modal."]
|
||||
},
|
||||
"date": "2025-09-13",
|
||||
"version": "1.128.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n, Update model configs."]
|
||||
},
|
||||
"date": "2025-09-13",
|
||||
"version": "1.128.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor message proccesser to the context engine."]
|
||||
},
|
||||
"date": "2025-09-12",
|
||||
"version": "1.128.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["ChatInput support resize."]
|
||||
},
|
||||
"date": "2025-09-12",
|
||||
"version": "1.128.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Improve OpenAIStream processing to emit usage data for chunks lacking choices."]
|
||||
},
|
||||
"date": "2025-09-11",
|
||||
"version": "1.127.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor model runtime folder structure and add more tests."]
|
||||
},
|
||||
"date": "2025-09-11",
|
||||
"version": "1.127.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Delete files should delete chunks、embedings、fileChunk."]
|
||||
},
|
||||
"date": "2025-09-11",
|
||||
"version": "1.127.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix not remove message with server mode."],
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-11",
|
||||
"version": "1.127.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Seedream 4.0."],
|
||||
"improvements": ["Add hotkey tooltip to typobar actions."]
|
||||
},
|
||||
"date": "2025-09-10",
|
||||
"version": "1.127.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Add CometAPI model provider and chat models, update i18n."]
|
||||
},
|
||||
"date": "2025-09-10",
|
||||
"version": "1.126.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix editor key handling."]
|
||||
},
|
||||
"date": "2025-09-09",
|
||||
"version": "1.126.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix Assistant List error message."]
|
||||
},
|
||||
"date": "2025-09-09",
|
||||
"version": "1.126.1"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-08",
|
||||
"version": "1.126.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Add Math and TaskList to Editor."]
|
||||
},
|
||||
"date": "2025-09-08",
|
||||
"version": "1.125.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Revert V1 Mobile."]
|
||||
},
|
||||
"date": "2025-09-06",
|
||||
"version": "1.124.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor to remove edge runtime and add more tests."]
|
||||
},
|
||||
"date": "2025-09-06",
|
||||
"version": "1.124.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix ChatInput send command switch."]
|
||||
},
|
||||
"date": "2025-09-06",
|
||||
"version": "1.124.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Enhance NewAPI with environment variables and fix routers compatibility."],
|
||||
"improvements": ["Update doubao-seed-1.6-vision models."]
|
||||
},
|
||||
"date": "2025-09-06",
|
||||
"version": "1.124.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["ChatInput support rich text and support parallel send."]
|
||||
},
|
||||
"date": "2025-09-06",
|
||||
"version": "1.124.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Remove edge runtime."]
|
||||
},
|
||||
"date": "2025-09-05",
|
||||
"version": "1.123.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix mobile header title to loog not ellipsis."]
|
||||
},
|
||||
"date": "2025-09-05",
|
||||
"version": "1.123.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Not use branch topic when this topic is not save."]
|
||||
},
|
||||
"date": "2025-09-05",
|
||||
"version": "1.123.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-05",
|
||||
"version": "1.123.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Add NewAPI as a router provider for multi-model aggregation."]
|
||||
},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.123.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Make LobeNextAuthDBAdapter Edge Compatible."]
|
||||
},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.7"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.6"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Make LobeNextAuthDBAdapter Edge Compatible."]
|
||||
},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Support base64 image from markdown image syntax."],
|
||||
"improvements": ["Update the price of the o3 model in OpenRouter."]
|
||||
},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.3"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.2"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Refactor to speed up send message in server mode."]
|
||||
},
|
||||
"date": "2025-09-04",
|
||||
"version": "1.122.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix socks5 proxy not work problem, fix virtuaso minheight was null."]
|
||||
},
|
||||
"date": "2025-09-03",
|
||||
"version": "1.121.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Add nano banana Chinese prompt notify."]
|
||||
},
|
||||
"date": "2025-09-03",
|
||||
"version": "1.121.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-09-02",
|
||||
"version": "1.120.7"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Add upload hint for non-visual model."]
|
||||
},
|
||||
"date": "2025-09-01",
|
||||
"version": "1.120.6"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-09-01",
|
||||
"version": "1.120.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Adjust ControlsForm component to adapt to mobile phone display."]
|
||||
},
|
||||
"date": "2025-09-01",
|
||||
"version": "1.120.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Support new provider Nebius."]
|
||||
},
|
||||
"date": "2025-09-01",
|
||||
"version": "1.120.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Remove base path."]
|
||||
},
|
||||
"date": "2025-08-31",
|
||||
"version": "1.120.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-08-31",
|
||||
"version": "1.120.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Remove webrtc sync feature flag."],
|
||||
"features": ["Rename Gemini 2.5 flash image to Nano Banana."]
|
||||
},
|
||||
"date": "2025-08-30",
|
||||
"version": "1.120.0"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-30",
|
||||
"version": "1.119.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Update enableStreaming name."]
|
||||
},
|
||||
"date": "2025-08-30",
|
||||
"version": "1.119.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Added support for Azure OpenAI Image Generation."]
|
||||
},
|
||||
"date": "2025-08-30",
|
||||
"version": "1.119.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update DeepSeek V3.1 & Gemini 2.5 Flash Image Preview models."]
|
||||
},
|
||||
"date": "2025-08-30",
|
||||
"version": "1.118.8"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-08-30",
|
||||
"version": "1.118.7"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Support non-stream mode."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.6"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Fix clerk scrollBox style, ModelFetcher support getting prices."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Fix chat session part switch theme issue."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Correct totalOutputTokens calculation for XAI provider."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Add Grok Code Fast 1 model."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Add Content-Security-Policy env."],
|
||||
"improvements": ["Support Gemini URL context tool."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Add new provider AkashChat."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.118.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Move chat item into chat."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.117.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": [
|
||||
"Ai image support Gemini 2.5 Flash Image, Support Gemini 2.5 Flash Image Preview in OpenRouter."
|
||||
],
|
||||
"improvements": ["Update i18n."]
|
||||
},
|
||||
"date": "2025-08-29",
|
||||
"version": "1.117.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Support html preview."]
|
||||
},
|
||||
"date": "2025-08-28",
|
||||
"version": "1.116.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Fix desktop route error."]
|
||||
},
|
||||
"date": "2025-08-28",
|
||||
"version": "1.116.3"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-28",
|
||||
"version": "1.116.2"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-27",
|
||||
"version": "1.116.1"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"features": ["Add gemini 2.5 flash image for vertex ai."]
|
||||
},
|
||||
"date": "2025-08-27",
|
||||
"version": "1.116.0"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-26",
|
||||
"version": "1.115.0"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-22",
|
||||
"version": "1.114.6"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update mistral model vision ability."]
|
||||
},
|
||||
"date": "2025-08-22",
|
||||
"version": "1.114.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Move database to packages."]
|
||||
},
|
||||
"date": "2025-08-22",
|
||||
"version": "1.114.4"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-21",
|
||||
"version": "1.114.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Can't load custom provider config."]
|
||||
},
|
||||
"date": "2025-08-21",
|
||||
"version": "1.114.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Move chain into @lobechat/prompts."]
|
||||
},
|
||||
"date": "2025-08-21",
|
||||
"version": "1.114.1"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-19",
|
||||
"version": "1.114.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": [
|
||||
"Support Grok thinking models in AiHubMix, The 'stream_options' parameter is only allowed when 'stream' is enabled."
|
||||
]
|
||||
},
|
||||
"date": "2025-08-19",
|
||||
"version": "1.113.3"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-18",
|
||||
"version": "1.113.2"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-17",
|
||||
"version": "1.113.1"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-17",
|
||||
"version": "1.113.0"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Improve mcp tracing with user config."]
|
||||
},
|
||||
"date": "2025-08-17",
|
||||
"version": "1.112.5"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor prompts folder to the @lobechat/prompts pacakge."]
|
||||
},
|
||||
"date": "2025-08-16",
|
||||
"version": "1.112.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor const folder to a new package."]
|
||||
},
|
||||
"date": "2025-08-16",
|
||||
"version": "1.112.3"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["重构 ArgsInput 组件."]
|
||||
},
|
||||
"date": "2025-08-16",
|
||||
"version": "1.112.2"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Add Imagen 4 GA models, style improve auth sign in box loading."]
|
||||
},
|
||||
"date": "2025-08-16",
|
||||
"version": "1.112.1"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-15",
|
||||
"version": "1.112.0"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-14",
|
||||
"version": "1.111.12"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Update Mistral AI models & Optimize many model providers fetching."]
|
||||
},
|
||||
"date": "2025-08-13",
|
||||
"version": "1.111.11"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Adjust near bottom size on thinking scroll."]
|
||||
},
|
||||
"date": "2025-08-12",
|
||||
"version": "1.111.10"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Improve Gemini error display with promptFeedback."]
|
||||
},
|
||||
"date": "2025-08-12",
|
||||
"version": "1.111.9"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Support new GPT-5 Verbosity params."]
|
||||
},
|
||||
"date": "2025-08-11",
|
||||
"version": "1.111.8"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Refactor model-runtime to a seperated package."]
|
||||
},
|
||||
"date": "2025-08-11",
|
||||
"version": "1.111.7"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"fixes": ["Solve the cache problem caused by the same dom id when sharing pictures."]
|
||||
},
|
||||
"date": "2025-08-11",
|
||||
"version": "1.111.6"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": ["Add mask effect to thinking scroll, update i18n."]
|
||||
},
|
||||
"date": "2025-08-10",
|
||||
"version": "1.111.5"
|
||||
},
|
||||
{
|
||||
"children": {},
|
||||
"date": "2025-08-09",
|
||||
"version": "1.111.4"
|
||||
},
|
||||
{
|
||||
"children": {
|
||||
"improvements": [
|
||||
|
||||
+30
-2
@@ -1,11 +1,39 @@
|
||||
component_management:
|
||||
individual_components:
|
||||
# App architecture layers
|
||||
- component_id: app_store
|
||||
name: "Store"
|
||||
paths:
|
||||
- src/store/**
|
||||
- component_id: app_services
|
||||
name: "Services"
|
||||
paths:
|
||||
- src/services/**
|
||||
- component_id: app_server
|
||||
name: "Server"
|
||||
paths:
|
||||
- src/server/**
|
||||
- component_id: app_libs
|
||||
name: "Libs"
|
||||
paths:
|
||||
- src/libs/**
|
||||
- component_id: app_utils
|
||||
name: "Utils"
|
||||
paths:
|
||||
- src/utils/**
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default: off
|
||||
server:
|
||||
database:
|
||||
flags:
|
||||
- server
|
||||
- database
|
||||
app:
|
||||
flags:
|
||||
- app
|
||||
patch: off
|
||||
|
||||
|
||||
comment:
|
||||
layout: "header, diff, flags, components" # show component info in the PR comment
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
name: lobe-chat-development
|
||||
services:
|
||||
network-service:
|
||||
image: alpine
|
||||
container_name: lobe-network
|
||||
restart: always
|
||||
ports:
|
||||
- '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
|
||||
- '9001:9001' # MinIO Console
|
||||
- '${CASDOOR_PORT}:${CASDOOR_PORT}' # Casdoor
|
||||
- '3000:3000' # Grafana
|
||||
- '4318:4318' # otel-collector HTTP
|
||||
- '4317:4317' # otel-collector gRPC
|
||||
command: tail -f /dev/null
|
||||
networks:
|
||||
- lobe-network
|
||||
|
||||
postgresql:
|
||||
extends:
|
||||
file: docker-compose/local/docker-compose.yml
|
||||
service: postgresql
|
||||
minio:
|
||||
extends:
|
||||
file: docker-compose/local/docker-compose.yml
|
||||
service: minio
|
||||
casdoor:
|
||||
extends:
|
||||
file: docker-compose/local/docker-compose.yml
|
||||
service: casdoor
|
||||
searxng:
|
||||
extends:
|
||||
file: docker-compose/local/docker-compose.yml
|
||||
service: searxng
|
||||
|
||||
grafana:
|
||||
profiles:
|
||||
- otel
|
||||
extends:
|
||||
file: docker-compose/local/grafana/docker-compose.yml
|
||||
service: grafana
|
||||
|
||||
tempo:
|
||||
profiles:
|
||||
- otel
|
||||
extends:
|
||||
file: docker-compose/local/grafana/docker-compose.yml
|
||||
service: tempo
|
||||
|
||||
prometheus:
|
||||
profiles:
|
||||
- otel
|
||||
extends:
|
||||
file: docker-compose/local/grafana/docker-compose.yml
|
||||
service: prometheus
|
||||
|
||||
otel-collector:
|
||||
profiles:
|
||||
- otel
|
||||
extends:
|
||||
file: docker-compose/local/grafana/docker-compose.yml
|
||||
service: otel-collector
|
||||
|
||||
otel-tracing-test:
|
||||
profiles:
|
||||
- otel-test
|
||||
extends:
|
||||
file: docker-compose/local/grafana/docker-compose.yml
|
||||
service: otel-tracing-test
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
s3_data:
|
||||
driver: local
|
||||
grafana_data:
|
||||
driver: local
|
||||
tempo_data:
|
||||
driver: local
|
||||
prometheus_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
lobe-network:
|
||||
driver: bridge
|
||||
@@ -27,6 +27,7 @@ AUTH_CASDOOR_ISSUER=http://localhost:8000
|
||||
# Casdoor secret
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354
|
||||
CASDOOR_WEBHOOK_SECRET=casdoor-secret
|
||||
|
||||
# MinIO S3 configuration
|
||||
MINIO_ROOT_USER=admin
|
||||
|
||||
@@ -27,6 +27,7 @@ AUTH_CASDOOR_ISSUER=http://localhost:8000
|
||||
# Casdoor secret
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354
|
||||
CASDOOR_WEBHOOK_SECRET=casdoor-secret
|
||||
|
||||
# MinIO S3 配置
|
||||
MINIO_ROOT_USER=admin
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
data/
|
||||
s3_data/
|
||||
@@ -9,6 +9,9 @@ services:
|
||||
- '9001:9001' # MinIO Console
|
||||
- '${CASDOOR_PORT}:${CASDOOR_PORT}' # Casdoor
|
||||
- '${LOBE_PORT}:3210' # LobeChat
|
||||
- '3000:3000' # Grafana
|
||||
- '4318:4318' # otel-collector HTTP
|
||||
- '4317:4317' # otel-collector gRPC
|
||||
command: tail -f /dev/null
|
||||
networks:
|
||||
- lobe-network
|
||||
@@ -58,9 +61,9 @@ services:
|
||||
wait \$MINIO_PID
|
||||
"
|
||||
|
||||
# version lock ref: https://github.com/lobehub/lobe-chat/pull/7331
|
||||
# version lock ref: https://github.com/lobehub/lobe-chat/pull/7331
|
||||
casdoor:
|
||||
image: casbin/casdoor:v1.843.0
|
||||
image: casbin/casdoor:v2.13.0
|
||||
container_name: lobe-casdoor
|
||||
entrypoint: /bin/sh -c './server --createDatabase=true'
|
||||
network_mode: 'service:network-service'
|
||||
@@ -162,11 +165,90 @@ services:
|
||||
wait \$LOBE_PID
|
||||
"
|
||||
|
||||
grafana:
|
||||
profiles:
|
||||
- otel
|
||||
image: grafana/grafana:12.2.0-17419259409
|
||||
container_name: lobe-grafana
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
environment:
|
||||
- GF_AUTH_ANONYMOUS_ENABLED=true
|
||||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
|
||||
- GF_AUTH_DISABLE_LOGIN_FORM=true
|
||||
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./grafana/dashboards:/etc/grafana/provisioning/dashboards
|
||||
- ./grafana/datasources:/etc/grafana/provisioning/datasources
|
||||
depends_on:
|
||||
- tempo
|
||||
- prometheus
|
||||
|
||||
tempo:
|
||||
profiles:
|
||||
- otel
|
||||
image: grafana/tempo:latest
|
||||
container_name: lobe-tempo
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./tempo/tempo.yaml:/etc/tempo.yaml
|
||||
- tempo_data:/var/tempo
|
||||
command: ['-config.file=/etc/tempo.yaml']
|
||||
|
||||
prometheus:
|
||||
profiles:
|
||||
- otel
|
||||
image: prom/prometheus
|
||||
container_name: lobe-prometheus
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--web.enable-otlp-receiver'
|
||||
- '--web.enable-remote-write-receiver'
|
||||
- '--enable-feature=exemplar-storage'
|
||||
|
||||
otel-collector:
|
||||
profiles:
|
||||
- otel
|
||||
image: otel/opentelemetry-collector
|
||||
container_name: lobe-otel-collector
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./otel-collector/collector-config.yaml:/etc/otelcol/config.yaml
|
||||
command: ['--config', '/etc/otelcol/config.yaml']
|
||||
depends_on:
|
||||
- tempo
|
||||
- prometheus
|
||||
|
||||
otel-tracing-test:
|
||||
profiles:
|
||||
- otel-test
|
||||
image: ghcr.io/grafana/xk6-client-tracing:v0.0.7
|
||||
container_name: lobe-otel-tracing-test
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
environment:
|
||||
- ENDPOINT=127.0.0.1:4317
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
s3_data:
|
||||
driver: local
|
||||
grafana_data:
|
||||
driver: local
|
||||
tempo_data:
|
||||
driver: local
|
||||
prometheus_data:
|
||||
driver: local
|
||||
|
||||
|
||||
networks:
|
||||
lobe-network:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Proxy, if you need it
|
||||
# HTTP_PROXY=http://localhost:7890
|
||||
# HTTPS_PROXY=http://localhost:7890
|
||||
|
||||
|
||||
# Other environment variables, as needed. You can refer to the environment variables configuration for the client version, making sure not to have ACCESS_CODE.
|
||||
# OPENAI_API_KEY=sk-xxxx
|
||||
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
||||
# OPENAI_MODEL_LIST=...
|
||||
|
||||
|
||||
# ===========================
|
||||
# ====== Preset config ======
|
||||
# ===========================
|
||||
# if no special requirements, no need to change
|
||||
LOBE_PORT=3210
|
||||
CASDOOR_PORT=8000
|
||||
MINIO_PORT=9000
|
||||
APP_URL=http://localhost:3210
|
||||
AUTH_URL=http://localhost:3210/api/auth
|
||||
|
||||
# Postgres related, which are the necessary environment variables for DB
|
||||
LOBE_DB_NAME=lobechat
|
||||
POSTGRES_PASSWORD=uWNZugjBqixf8dxC
|
||||
|
||||
AUTH_CASDOOR_ISSUER=http://localhost:8000
|
||||
# Casdoor secret
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354
|
||||
CASDOOR_WEBHOOK_SECRET=casdoor-secret
|
||||
|
||||
# MinIO S3 configuration
|
||||
MINIO_ROOT_USER=admin
|
||||
MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD
|
||||
|
||||
# Configure the bucket information of MinIO
|
||||
S3_PUBLIC_DOMAIN=http://localhost:9000
|
||||
S3_ENDPOINT=http://localhost:9000
|
||||
MINIO_LOBE_BUCKET=lobe
|
||||
|
||||
# Configure for casdoor
|
||||
origin=http://localhost:8000
|
||||
@@ -0,0 +1,42 @@
|
||||
# Proxy,如果你需要的话(比如你使用 GitHub 作为鉴权服务提供商)
|
||||
# HTTP_PROXY=http://localhost:7890
|
||||
# HTTPS_PROXY=http://localhost:7890
|
||||
|
||||
|
||||
# 其他环境变量,视需求而定,可以参照客户端版本的环境变量配置,注意不要有 ACCESS_CODE
|
||||
# OPENAI_API_KEY=sk-xxxx
|
||||
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
||||
# OPENAI_MODEL_LIST=...
|
||||
|
||||
|
||||
# ===================
|
||||
# ===== 预设配置 =====
|
||||
# ===================
|
||||
# 如没有特殊需要不用更改
|
||||
LOBE_PORT=3210
|
||||
CASDOOR_PORT=8000
|
||||
MINIO_PORT=9000
|
||||
APP_URL=http://localhost:3210
|
||||
AUTH_URL=http://localhost:3210/api/auth
|
||||
|
||||
# Postgres 相关,也即 DB 必须的环境变量
|
||||
LOBE_DB_NAME=lobechat
|
||||
POSTGRES_PASSWORD=uWNZugjBqixf8dxC
|
||||
|
||||
AUTH_CASDOOR_ISSUER=http://localhost:8000
|
||||
# Casdoor secret
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354
|
||||
CASDOOR_WEBHOOK_SECRET=casdoor-secret
|
||||
|
||||
# MinIO S3 配置
|
||||
MINIO_ROOT_USER=admin
|
||||
MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD
|
||||
|
||||
# 在下方配置 minio 中添加的桶
|
||||
S3_PUBLIC_DOMAIN=http://localhost:9000
|
||||
S3_ENDPOINT=http://localhost:9000
|
||||
MINIO_LOBE_BUCKET=lobe
|
||||
|
||||
# 为 casdoor 配置
|
||||
origin=http://localhost:8000
|
||||
@@ -0,0 +1,251 @@
|
||||
name: lobe-chat-database
|
||||
services:
|
||||
network-service:
|
||||
image: alpine
|
||||
container_name: lobe-network
|
||||
restart: always
|
||||
ports:
|
||||
- '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
|
||||
- '9001:9001' # MinIO Console
|
||||
- '${CASDOOR_PORT}:${CASDOOR_PORT}' # Casdoor
|
||||
- '${LOBE_PORT}:3210' # LobeChat
|
||||
- '3000:3000' # Grafana
|
||||
- '4318:4318' # otel-collector HTTP
|
||||
- '4317:4317' # otel-collector gRPC
|
||||
command: tail -f /dev/null
|
||||
networks:
|
||||
- lobe-network
|
||||
|
||||
postgresql:
|
||||
image: pgvector/pgvector:pg17
|
||||
container_name: lobe-postgres
|
||||
ports:
|
||||
- '5432:5432'
|
||||
volumes:
|
||||
- './data:/var/lib/postgresql/data'
|
||||
environment:
|
||||
- 'POSTGRES_DB=${LOBE_DB_NAME}'
|
||||
- 'POSTGRES_PASSWORD=${POSTGRES_PASSWORD}'
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: always
|
||||
networks:
|
||||
- lobe-network
|
||||
|
||||
minio:
|
||||
image: minio/minio:RELEASE.2025-04-22T22-12-26Z
|
||||
container_name: lobe-minio
|
||||
network_mode: 'service:network-service'
|
||||
volumes:
|
||||
- './s3_data:/etc/minio/data'
|
||||
environment:
|
||||
- 'MINIO_API_CORS_ALLOW_ORIGIN=*'
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
entrypoint: >
|
||||
/bin/sh -c "
|
||||
minio server /etc/minio/data --address ':${MINIO_PORT}' --console-address ':9001' &
|
||||
MINIO_PID=\$!
|
||||
while ! curl -s http://localhost:${MINIO_PORT}/minio/health/live; do
|
||||
echo 'Waiting for MinIO to start...'
|
||||
sleep 1
|
||||
done
|
||||
sleep 5
|
||||
mc alias set myminio http://localhost:${MINIO_PORT} ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}
|
||||
echo 'Creating bucket ${MINIO_LOBE_BUCKET}'
|
||||
mc mb myminio/${MINIO_LOBE_BUCKET}
|
||||
wait \$MINIO_PID
|
||||
"
|
||||
|
||||
# version lock ref: https://github.com/lobehub/lobe-chat/pull/7331
|
||||
casdoor:
|
||||
image: casbin/casdoor:v2.13.0
|
||||
container_name: lobe-casdoor
|
||||
entrypoint: /bin/sh -c './server --createDatabase=true'
|
||||
network_mode: 'service:network-service'
|
||||
depends_on:
|
||||
postgresql:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
httpport: ${CASDOOR_PORT}
|
||||
RUNNING_IN_DOCKER: 'true'
|
||||
driverName: 'postgres'
|
||||
dataSourceName: 'user=postgres password=${POSTGRES_PASSWORD} host=postgresql port=5432 sslmode=disable dbname=casdoor'
|
||||
runmode: 'dev'
|
||||
volumes:
|
||||
- ./init_data.json:/init_data.json
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
searxng:
|
||||
image: searxng/searxng
|
||||
container_name: lobe-searxng
|
||||
volumes:
|
||||
- './searxng-settings.yml:/etc/searxng/settings.yml'
|
||||
environment:
|
||||
- 'SEARXNG_SETTINGS_FILE=/etc/searxng/settings.yml'
|
||||
restart: always
|
||||
networks:
|
||||
- lobe-network
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:12.2.0-17419259409
|
||||
container_name: lobe-grafana
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
environment:
|
||||
- GF_AUTH_ANONYMOUS_ENABLED=true
|
||||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
|
||||
- GF_AUTH_DISABLE_LOGIN_FORM=true
|
||||
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./grafana/dashboards:/etc/grafana/provisioning/dashboards
|
||||
- ./grafana/datasources:/etc/grafana/provisioning/datasources
|
||||
depends_on:
|
||||
- tempo
|
||||
- prometheus
|
||||
|
||||
tempo:
|
||||
image: grafana/tempo:latest
|
||||
container_name: lobe-tempo
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./tempo/tempo.yaml:/etc/tempo.yaml
|
||||
- tempo_data:/var/tempo
|
||||
command: ['-config.file=/etc/tempo.yaml']
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus
|
||||
container_name: lobe-prometheus
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--web.enable-otlp-receiver'
|
||||
- '--web.enable-remote-write-receiver'
|
||||
- '--enable-feature=exemplar-storage'
|
||||
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector
|
||||
container_name: lobe-otel-collector
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./otel-collector/collector-config.yaml:/etc/otelcol/config.yaml
|
||||
command: ['--config', '/etc/otelcol/config.yaml']
|
||||
depends_on:
|
||||
- tempo
|
||||
- prometheus
|
||||
|
||||
otel-tracing-test:
|
||||
profiles:
|
||||
- otel-test
|
||||
image: ghcr.io/grafana/xk6-client-tracing:v0.0.7
|
||||
container_name: lobe-otel-tracing-test
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
environment:
|
||||
- ENDPOINT=127.0.0.1:4317
|
||||
|
||||
lobe:
|
||||
image: lobehub/lobe-chat-database
|
||||
container_name: lobe-chat
|
||||
network_mode: 'service:network-service'
|
||||
depends_on:
|
||||
postgresql:
|
||||
condition: service_healthy
|
||||
network-service:
|
||||
condition: service_started
|
||||
minio:
|
||||
condition: service_started
|
||||
casdoor:
|
||||
condition: service_started
|
||||
|
||||
environment:
|
||||
- 'NEXT_AUTH_SSO_PROVIDERS=casdoor'
|
||||
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
|
||||
- 'NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
|
||||
- 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
|
||||
- 'S3_BUCKET=${MINIO_LOBE_BUCKET}'
|
||||
- 'S3_ENABLE_PATH_STYLE=1'
|
||||
- 'S3_ACCESS_KEY=${MINIO_ROOT_USER}'
|
||||
- 'S3_ACCESS_KEY_ID=${MINIO_ROOT_USER}'
|
||||
- 'S3_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}'
|
||||
- 'LLM_VISION_IMAGE_USE_BASE64=1'
|
||||
- 'S3_SET_ACL=0'
|
||||
- 'SEARXNG_URL=http://searxng:8080'
|
||||
- 'OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf'
|
||||
- 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://localhost:4318/v1/metrics'
|
||||
- 'OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf'
|
||||
- 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces'
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
entrypoint: >
|
||||
/bin/sh -c "
|
||||
/bin/node /app/startServer.js &
|
||||
LOBE_PID=\$!
|
||||
sleep 3
|
||||
if [ $(wget --timeout=5 --spider --server-response ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep -c 'HTTP/1.1 200 OK') -eq 0 ]; then
|
||||
echo '⚠️Warning: Unable to fetch OIDC configuration from Casdoor'
|
||||
echo 'Request URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo 'Read more at: https://lobehub.com/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
echo '⚠️注意:无法从 Casdoor 获取 OIDC 配置'
|
||||
echo '请求 URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo '了解更多:https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
else
|
||||
if ! wget -O - --timeout=5 ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep 'issuer' | grep ${AUTH_CASDOOR_ISSUER}; then
|
||||
printf '❌Error: The Auth issuer is conflict, Issuer in OIDC configuration is: %s' \$(wget -O - --timeout=5 ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep -E 'issuer.*' | awk -F '\"' '{print \$4}')
|
||||
echo ' , but the issuer in .env file is: ${AUTH_CASDOOR_ISSUER} '
|
||||
echo 'Request URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo 'Read more at: https://lobehub.com/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
printf '❌错误:Auth 的 issuer 冲突,OIDC 配置中的 issuer 是:%s' \$(wget -O - --timeout=5 ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep -E 'issuer.*' | awk -F '\"' '{print \$4}')
|
||||
echo ' , 但 .env 文件中的 issuer 是:${AUTH_CASDOOR_ISSUER} '
|
||||
echo '请求 URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo '了解更多:https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
fi
|
||||
fi
|
||||
if [ $(wget --timeout=5 --spider --server-response ${S3_ENDPOINT}/minio/health/live 2>&1 | grep -c 'HTTP/1.1 200 OK') -eq 0 ]; then
|
||||
echo '⚠️Warning: Unable to fetch MinIO health status'
|
||||
echo 'Request URL: ${S3_ENDPOINT}/minio/health/live'
|
||||
echo 'Read more at: https://lobehub.com/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
echo '⚠️注意:无法获取 MinIO 健康状态'
|
||||
echo '请求 URL: ${S3_ENDPOINT}/minio/health/live'
|
||||
echo '了解更多:https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
fi
|
||||
wait \$LOBE_PID
|
||||
"
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
s3_data:
|
||||
driver: local
|
||||
grafana_data:
|
||||
driver: local
|
||||
tempo_data:
|
||||
driver: local
|
||||
prometheus_data:
|
||||
driver: local
|
||||
|
||||
|
||||
networks:
|
||||
lobe-network:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: 1
|
||||
|
||||
prune: true
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://127.0.0.1:9090
|
||||
basicAuth: false
|
||||
isDefault: false
|
||||
version: 1
|
||||
editable: false
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: 1
|
||||
|
||||
prune: true
|
||||
|
||||
datasources:
|
||||
- name: Tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://127.0.0.1:3200
|
||||
basicAuth: false
|
||||
isDefault: true
|
||||
version: 1
|
||||
editable: false
|
||||
apiVersion: 1
|
||||
uid: tempo
|
||||
@@ -0,0 +1,45 @@
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 127.0.0.1:13133
|
||||
|
||||
receivers:
|
||||
prometheus:
|
||||
config:
|
||||
scrape_configs:
|
||||
- job_name: otel-collector-metrics
|
||||
scrape_interval: 10s
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:8888"]
|
||||
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
exporters:
|
||||
prometheusremotewrite:
|
||||
endpoint: http://127.0.0.1:9090/api/v1/write
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
otlp:
|
||||
endpoint: 127.0.0.1:14317
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
debug:
|
||||
verbosity: detailed
|
||||
|
||||
service:
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [prometheus, otlp]
|
||||
exporters: [prometheusremotewrite]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
exporters: [otlp]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
exporters: [debug]
|
||||
@@ -0,0 +1,11 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:9090"]
|
||||
- job_name: "tempo"
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:3200"]
|
||||
@@ -0,0 +1,58 @@
|
||||
stream_over_http_enabled: true
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
log_level: info
|
||||
|
||||
query_frontend:
|
||||
search:
|
||||
duration_slo: 5s
|
||||
throughput_bytes_slo: 1.073741824e+09
|
||||
metadata_slo:
|
||||
duration_slo: 5s
|
||||
throughput_bytes_slo: 1.073741824e+09
|
||||
trace_by_id:
|
||||
duration_slo: 5s
|
||||
|
||||
distributor:
|
||||
max_attribute_bytes: 10485760
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 127.0.0.1:14317
|
||||
http:
|
||||
endpoint: 127.0.0.1:14318
|
||||
|
||||
ingester:
|
||||
max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 1h # overall Tempo trace retention. set for demo purposes
|
||||
|
||||
metrics_generator:
|
||||
registry:
|
||||
external_labels:
|
||||
source: tempo
|
||||
cluster: docker-compose
|
||||
storage:
|
||||
path: /var/tempo/generator/wal
|
||||
remote_write:
|
||||
- url: http://127.0.0.1:9090/api/v1/write
|
||||
send_exemplars: true
|
||||
traces_storage:
|
||||
path: /var/tempo/generator/traces
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local # backend configuration to use
|
||||
wal:
|
||||
path: /var/tempo/wal # where to store the wal locally
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
|
||||
overrides:
|
||||
defaults:
|
||||
metrics_generator:
|
||||
processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator
|
||||
generate_native_histograms: both
|
||||
+752
-289
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
# Proxy, if you need it
|
||||
# HTTP_PROXY=http://localhost:7890
|
||||
# HTTPS_PROXY=http://localhost:7890
|
||||
|
||||
|
||||
# Other environment variables, as needed. You can refer to the environment variables configuration for the client version, making sure not to have ACCESS_CODE.
|
||||
# OPENAI_API_KEY=sk-xxxx
|
||||
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
||||
# OPENAI_MODEL_LIST=...
|
||||
|
||||
|
||||
# ===========================
|
||||
# ====== Preset config ======
|
||||
# ===========================
|
||||
# if no special requirements, no need to change
|
||||
LOBE_PORT=3210
|
||||
CASDOOR_PORT=8000
|
||||
MINIO_PORT=9000
|
||||
APP_URL=http://localhost:3210
|
||||
AUTH_URL=http://localhost:3210/api/auth
|
||||
|
||||
# Postgres related, which are the necessary environment variables for DB
|
||||
LOBE_DB_NAME=lobechat
|
||||
POSTGRES_PASSWORD=uWNZugjBqixf8dxC
|
||||
|
||||
AUTH_CASDOOR_ISSUER=http://localhost:8000
|
||||
# Casdoor secret
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354
|
||||
CASDOOR_WEBHOOK_SECRET=casdoor-secret
|
||||
|
||||
# MinIO S3 configuration
|
||||
MINIO_ROOT_USER=admin
|
||||
MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD
|
||||
|
||||
# Configure the bucket information of MinIO
|
||||
S3_PUBLIC_DOMAIN=http://localhost:9000
|
||||
S3_ENDPOINT=http://localhost:9000
|
||||
MINIO_LOBE_BUCKET=lobe
|
||||
|
||||
GF_SECURITY_ADMIN_PASSWORD=YOUR_GRAFANA_PASSWORD
|
||||
|
||||
# Configure for casdoor
|
||||
origin=http://localhost:8000
|
||||
@@ -0,0 +1,42 @@
|
||||
# Proxy,如果你需要的话(比如你使用 GitHub 作为鉴权服务提供商)
|
||||
# HTTP_PROXY=http://localhost:7890
|
||||
# HTTPS_PROXY=http://localhost:7890
|
||||
|
||||
|
||||
# 其他环境变量,视需求而定,可以参照客户端版本的环境变量配置,注意不要有 ACCESS_CODE
|
||||
# OPENAI_API_KEY=sk-xxxx
|
||||
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
||||
# OPENAI_MODEL_LIST=...
|
||||
|
||||
|
||||
# ===================
|
||||
# ===== 预设配置 =====
|
||||
# ===================
|
||||
# 如没有特殊需要不用更改
|
||||
LOBE_PORT=3210
|
||||
CASDOOR_PORT=8000
|
||||
MINIO_PORT=9000
|
||||
APP_URL=http://localhost:3210
|
||||
AUTH_URL=http://localhost:3210/api/auth
|
||||
|
||||
# Postgres 相关,也即 DB 必须的环境变量
|
||||
LOBE_DB_NAME=lobechat
|
||||
POSTGRES_PASSWORD=uWNZugjBqixf8dxC
|
||||
|
||||
AUTH_CASDOOR_ISSUER=http://localhost:8000
|
||||
# Casdoor secret
|
||||
AUTH_CASDOOR_ID=a387a4892ee19b1a2249
|
||||
AUTH_CASDOOR_SECRET=dbf205949d704de81b0b5b3603174e23fbecc354
|
||||
CASDOOR_WEBHOOK_SECRET=casdoor-secret
|
||||
|
||||
# MinIO S3 配置
|
||||
MINIO_ROOT_USER=admin
|
||||
MINIO_ROOT_PASSWORD=YOUR_MINIO_PASSWORD
|
||||
|
||||
# 在下方配置 minio 中添加的桶
|
||||
S3_PUBLIC_DOMAIN=http://localhost:9000
|
||||
S3_ENDPOINT=http://localhost:9000
|
||||
MINIO_LOBE_BUCKET=lobe
|
||||
|
||||
# 为 casdoor 配置
|
||||
origin=http://localhost:8000
|
||||
@@ -0,0 +1,249 @@
|
||||
name: lobe-chat-database
|
||||
services:
|
||||
network-service:
|
||||
image: alpine
|
||||
container_name: lobe-network
|
||||
restart: always
|
||||
ports:
|
||||
- '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
|
||||
- '9001:9001' # MinIO Console
|
||||
- '${CASDOOR_PORT}:${CASDOOR_PORT}' # Casdoor
|
||||
- '${LOBE_PORT}:3210' # LobeChat
|
||||
- '3000:3000' # Grafana
|
||||
- '4318:4318' # otel-collector HTTP
|
||||
- '4317:4317' # otel-collector gRPC
|
||||
command: tail -f /dev/null
|
||||
networks:
|
||||
- lobe-network
|
||||
|
||||
postgresql:
|
||||
image: pgvector/pgvector:pg17
|
||||
container_name: lobe-postgres
|
||||
ports:
|
||||
- '5432:5432'
|
||||
volumes:
|
||||
- './data:/var/lib/postgresql/data'
|
||||
environment:
|
||||
- 'POSTGRES_DB=${LOBE_DB_NAME}'
|
||||
- 'POSTGRES_PASSWORD=${POSTGRES_PASSWORD}'
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
restart: always
|
||||
networks:
|
||||
- lobe-network
|
||||
|
||||
minio:
|
||||
image: minio/minio:RELEASE.2025-04-22T22-12-26Z
|
||||
container_name: lobe-minio
|
||||
network_mode: 'service:network-service'
|
||||
volumes:
|
||||
- './s3_data:/etc/minio/data'
|
||||
environment:
|
||||
- 'MINIO_API_CORS_ALLOW_ORIGIN=*'
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
entrypoint: >
|
||||
/bin/sh -c "
|
||||
minio server /etc/minio/data --address ':${MINIO_PORT}' --console-address ':9001' &
|
||||
MINIO_PID=\$!
|
||||
while ! curl -s http://localhost:${MINIO_PORT}/minio/health/live; do
|
||||
echo 'Waiting for MinIO to start...'
|
||||
sleep 1
|
||||
done
|
||||
sleep 5
|
||||
mc alias set myminio http://localhost:${MINIO_PORT} ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}
|
||||
echo 'Creating bucket ${MINIO_LOBE_BUCKET}'
|
||||
mc mb myminio/${MINIO_LOBE_BUCKET}
|
||||
wait \$MINIO_PID
|
||||
"
|
||||
|
||||
# version lock ref: https://github.com/lobehub/lobe-chat/pull/7331
|
||||
casdoor:
|
||||
image: casbin/casdoor:v2.13.0
|
||||
container_name: lobe-casdoor
|
||||
entrypoint: /bin/sh -c './server --createDatabase=true'
|
||||
network_mode: 'service:network-service'
|
||||
depends_on:
|
||||
postgresql:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
httpport: ${CASDOOR_PORT}
|
||||
RUNNING_IN_DOCKER: 'true'
|
||||
driverName: 'postgres'
|
||||
dataSourceName: 'user=postgres password=${POSTGRES_PASSWORD} host=postgresql port=5432 sslmode=disable dbname=casdoor'
|
||||
runmode: 'dev'
|
||||
volumes:
|
||||
- ./init_data.json:/init_data.json
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
searxng:
|
||||
image: searxng/searxng
|
||||
container_name: lobe-searxng
|
||||
volumes:
|
||||
- './searxng-settings.yml:/etc/searxng/settings.yml'
|
||||
environment:
|
||||
- 'SEARXNG_SETTINGS_FILE=/etc/searxng/settings.yml'
|
||||
restart: always
|
||||
networks:
|
||||
- lobe-network
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:12.2.0-17419259409
|
||||
container_name: lobe-grafana
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}
|
||||
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./grafana/dashboards:/etc/grafana/provisioning/dashboards
|
||||
- ./grafana/datasources:/etc/grafana/provisioning/datasources
|
||||
depends_on:
|
||||
- tempo
|
||||
- prometheus
|
||||
|
||||
tempo:
|
||||
image: grafana/tempo:latest
|
||||
container_name: lobe-tempo
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./tempo/tempo.yaml:/etc/tempo.yaml
|
||||
- tempo_data:/var/tempo
|
||||
command: ['-config.file=/etc/tempo.yaml']
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus
|
||||
container_name: lobe-prometheus
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--web.enable-otlp-receiver'
|
||||
- '--web.enable-remote-write-receiver'
|
||||
- '--enable-feature=exemplar-storage'
|
||||
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector
|
||||
container_name: lobe-otel-collector
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
volumes:
|
||||
- ./otel-collector/collector-config.yaml:/etc/otelcol/config.yaml
|
||||
command: ['--config', '/etc/otelcol/config.yaml']
|
||||
depends_on:
|
||||
- tempo
|
||||
- prometheus
|
||||
|
||||
otel-tracing-test:
|
||||
profiles:
|
||||
- otel-test
|
||||
image: ghcr.io/grafana/xk6-client-tracing:v0.0.7
|
||||
container_name: lobe-otel-tracing-test
|
||||
network_mode: 'service:network-service'
|
||||
restart: always
|
||||
environment:
|
||||
- ENDPOINT=127.0.0.1:4317
|
||||
|
||||
lobe:
|
||||
image: lobehub/lobe-chat-database
|
||||
container_name: lobe-chat
|
||||
network_mode: 'service:network-service'
|
||||
depends_on:
|
||||
postgresql:
|
||||
condition: service_healthy
|
||||
network-service:
|
||||
condition: service_started
|
||||
minio:
|
||||
condition: service_started
|
||||
casdoor:
|
||||
condition: service_started
|
||||
|
||||
environment:
|
||||
- 'NEXT_AUTH_SSO_PROVIDERS=casdoor'
|
||||
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
|
||||
- 'NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
|
||||
- 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
|
||||
- 'S3_BUCKET=${MINIO_LOBE_BUCKET}'
|
||||
- 'S3_ENABLE_PATH_STYLE=1'
|
||||
- 'S3_ACCESS_KEY=${MINIO_ROOT_USER}'
|
||||
- 'S3_ACCESS_KEY_ID=${MINIO_ROOT_USER}'
|
||||
- 'S3_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}'
|
||||
- 'LLM_VISION_IMAGE_USE_BASE64=1'
|
||||
- 'S3_SET_ACL=0'
|
||||
- 'SEARXNG_URL=http://searxng:8080'
|
||||
- 'OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf'
|
||||
- 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://localhost:4318/v1/metrics'
|
||||
- 'OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf'
|
||||
- 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/traces'
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
entrypoint: >
|
||||
/bin/sh -c "
|
||||
/bin/node /app/startServer.js &
|
||||
LOBE_PID=\$!
|
||||
sleep 3
|
||||
if [ $(wget --timeout=5 --spider --server-response ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep -c 'HTTP/1.1 200 OK') -eq 0 ]; then
|
||||
echo '⚠️Warning: Unable to fetch OIDC configuration from Casdoor'
|
||||
echo 'Request URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo 'Read more at: https://lobehub.com/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
echo '⚠️注意:无法从 Casdoor 获取 OIDC 配置'
|
||||
echo '请求 URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo '了解更多:https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
else
|
||||
if ! wget -O - --timeout=5 ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep 'issuer' | grep ${AUTH_CASDOOR_ISSUER}; then
|
||||
printf '❌Error: The Auth issuer is conflict, Issuer in OIDC configuration is: %s' \$(wget -O - --timeout=5 ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep -E 'issuer.*' | awk -F '\"' '{print \$4}')
|
||||
echo ' , but the issuer in .env file is: ${AUTH_CASDOOR_ISSUER} '
|
||||
echo 'Request URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo 'Read more at: https://lobehub.com/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
printf '❌错误:Auth 的 issuer 冲突,OIDC 配置中的 issuer 是:%s' \$(wget -O - --timeout=5 ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration 2>&1 | grep -E 'issuer.*' | awk -F '\"' '{print \$4}')
|
||||
echo ' , 但 .env 文件中的 issuer 是:${AUTH_CASDOOR_ISSUER} '
|
||||
echo '请求 URL: ${AUTH_CASDOOR_ISSUER}/.well-known/openid-configuration'
|
||||
echo '了解更多:https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
fi
|
||||
fi
|
||||
if [ $(wget --timeout=5 --spider --server-response ${S3_ENDPOINT}/minio/health/live 2>&1 | grep -c 'HTTP/1.1 200 OK') -eq 0 ]; then
|
||||
echo '⚠️Warning: Unable to fetch MinIO health status'
|
||||
echo 'Request URL: ${S3_ENDPOINT}/minio/health/live'
|
||||
echo 'Read more at: https://lobehub.com/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
echo '⚠️注意:无法获取 MinIO 健康状态'
|
||||
echo '请求 URL: ${S3_ENDPOINT}/minio/health/live'
|
||||
echo '了解更多:https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose#necessary-configuration'
|
||||
echo ''
|
||||
fi
|
||||
wait \$LOBE_PID
|
||||
"
|
||||
|
||||
volumes:
|
||||
data:
|
||||
driver: local
|
||||
s3_data:
|
||||
driver: local
|
||||
grafana_data:
|
||||
driver: local
|
||||
tempo_data:
|
||||
driver: local
|
||||
prometheus_data:
|
||||
driver: local
|
||||
|
||||
|
||||
networks:
|
||||
lobe-network:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
uid: prometheus
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://127.0.0.1:9090
|
||||
basicAuth: false
|
||||
isDefault: false
|
||||
version: 1
|
||||
editable: false
|
||||
jsonData:
|
||||
httpMethod: GET
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://127.0.0.1:3200
|
||||
basicAuth: false
|
||||
isDefault: true
|
||||
version: 1
|
||||
editable: false
|
||||
apiVersion: 1
|
||||
uid: tempo
|
||||
jsonData:
|
||||
httpMethod: GET
|
||||
serviceMap:
|
||||
datasourceUid: prometheus
|
||||
streamingEnabled:
|
||||
search: true
|
||||
@@ -0,0 +1,45 @@
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 127.0.0.1:13133
|
||||
|
||||
receivers:
|
||||
prometheus:
|
||||
config:
|
||||
scrape_configs:
|
||||
- job_name: otel-collector-metrics
|
||||
scrape_interval: 10s
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:8888"]
|
||||
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
exporters:
|
||||
prometheusremotewrite:
|
||||
endpoint: http://127.0.0.1:9090/api/v1/write
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
otlp:
|
||||
endpoint: 127.0.0.1:14317
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
debug:
|
||||
verbosity: detailed
|
||||
|
||||
service:
|
||||
pipelines:
|
||||
metrics:
|
||||
receivers: [prometheus]
|
||||
exporters: [prometheusremotewrite]
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
exporters: [otlp]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
exporters: [debug]
|
||||
@@ -0,0 +1,11 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:9090"]
|
||||
- job_name: "tempo"
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:3200"]
|
||||
@@ -0,0 +1,58 @@
|
||||
stream_over_http_enabled: true
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
log_level: info
|
||||
|
||||
query_frontend:
|
||||
search:
|
||||
duration_slo: 5s
|
||||
throughput_bytes_slo: 1.073741824e+09
|
||||
metadata_slo:
|
||||
duration_slo: 5s
|
||||
throughput_bytes_slo: 1.073741824e+09
|
||||
trace_by_id:
|
||||
duration_slo: 5s
|
||||
|
||||
distributor:
|
||||
max_attribute_bytes: 10485760
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 127.0.0.1:14317
|
||||
http:
|
||||
endpoint: 127.0.0.1:14318
|
||||
|
||||
ingester:
|
||||
max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 1h # overall Tempo trace retention. set for demo purposes
|
||||
|
||||
metrics_generator:
|
||||
registry:
|
||||
external_labels:
|
||||
source: tempo
|
||||
cluster: docker-compose
|
||||
storage:
|
||||
path: /var/tempo/generator/wal
|
||||
remote_write:
|
||||
- url: http://127.0.0.1:9090/api/v1/write
|
||||
send_exemplars: true
|
||||
traces_storage:
|
||||
path: /var/tempo/generator/traces
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local # backend configuration to use
|
||||
wal:
|
||||
path: /var/tempo/wal # where to store the wal locally
|
||||
local:
|
||||
path: /var/tempo/blocks
|
||||
|
||||
overrides:
|
||||
defaults:
|
||||
metrics_generator:
|
||||
processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator
|
||||
generate_native_histograms: both
|
||||
@@ -450,7 +450,7 @@ ENV_EXAMPLES=(
|
||||
"$SUB_DIR/.env.example"
|
||||
)
|
||||
# Default values
|
||||
CASDOOR_PASSWORD="123"
|
||||
CASDOOR_PASSWORD="pswd123"
|
||||
CASDOOR_SECRET="CASDOOR_SECRET"
|
||||
MINIO_ROOT_PASSWORD="YOUR_MINIO_PASSWORD"
|
||||
CASDOOR_HOST="localhost:8000"
|
||||
@@ -657,10 +657,10 @@ section_regenerate_secrets() {
|
||||
CASDOOR_PASSWORD=$(generate_key 10)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo $(show_message "security_secrect_regenerate_failed") "CASDOOR_PASSWORD"
|
||||
CASDOOR_PASSWORD="123"
|
||||
CASDOOR_PASSWORD="pswd123"
|
||||
else
|
||||
# replace `password` in init_data.json
|
||||
sed "${SED_INPLACE_ARGS[@]}" "s/"123"/${CASDOOR_PASSWORD}/" init_data.json
|
||||
sed "${SED_INPLACE_ARGS[@]}" "s/"pswd123"/${CASDOOR_PASSWORD}/" init_data.json
|
||||
if [ $? -ne 0 ]; then
|
||||
echo $(show_message "security_secrect_regenerate_failed") "CASDOOR_PASSWORD in \`init_data.json\`"
|
||||
fi
|
||||
|
||||
@@ -456,7 +456,7 @@ The project uses vitest for unit testing.
|
||||
|
||||
Since our two new configuration fields are both optional, theoretically you could pass the tests without updating them. However, since we added the `openingQuestions` field to the `DEFAULT_AGENT_CONFIG` mentioned earlier, this causes many tests to calculate configurations that include this field, so we still need to update some test snapshots.
|
||||
|
||||
For the current scenario, I recommend running the tests locally to see which tests fail, and then update them as needed. For example, for the test file `src/store/agent/slices/chat/selectors/agent.test.ts`, you need to run `npx vitest -u src/store/agent/slices/chat/selectors/agent.test.ts` to update the snapshot.
|
||||
For the current scenario, I recommend running the tests locally to see which tests fail, and then update them as needed. For example, for the test file `src/store/agent/slices/chat/selectors/agent.test.ts`, you need to run `bunx vitest -u src/store/agent/slices/chat/selectors/agent.test.ts` to update the snapshot.
|
||||
|
||||
## Summary
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ export default WelcomeMessage;
|
||||
|
||||
由于我们目前两个新的配置字段都是可选的,所以理论上你不更新测试也能跑通,不过由于我们把前面提到的默认配置 `DEFAULT_AGENT_CONFIG` 增加了 `openingQuestions` 字段,这导致很多测试计算出的配置都是有这个字段的,因此我们还是需要更新一部分测试的快照。
|
||||
|
||||
对于当前这个场景,我建议是本地直接跑下测试,看哪些测试失败了,针对需要更新,例如测试文件 `src/store/agent/slices/chat/selectors/agent.test.ts` 需要执行一下 `npx vitest -u src/store/agent/slices/chat/selectors/agent.test.ts` 更新快照。
|
||||
对于当前这个场景,我建议是本地直接跑下测试,看哪些测试失败了,针对需要更新,例如测试文件 `src/store/agent/slices/chat/selectors/agent.test.ts` 需要执行一下 `bunx vitest -u src/store/agent/slices/chat/selectors/agent.test.ts` 更新快照。
|
||||
|
||||
## 总结
|
||||
|
||||
|
||||
@@ -17,10 +17,14 @@ Before starting development on LobeChat, you need to install and configure some
|
||||
First, you need to install the following software:
|
||||
|
||||
- Node.js: LobeChat is built on Node.js, so you need to install Node.js. We recommend installing the latest stable version.
|
||||
- Yarn: We use Yarn as the preferred package manager. You can download and install it from the Yarn official website.
|
||||
- PNPM: We use PNPM as an auxiliary package manager. You can download and install it from the PNPM official website.
|
||||
- PNPM: We use PNPM as the preferred package manager. You can download and install it from the [PNPM official website](https://pnpm.io/installation).
|
||||
- Bun: We use Bun as the npm scripts runner. You can download and install it from the [Bun official website](https://bun.com/docs/installation).
|
||||
- Git: We use Git for version control. You can download and install it from the Git official website.
|
||||
- IDE: You can choose your preferred integrated development environment (IDE). We recommend using WebStorm, a powerful IDE particularly suitable for TypeScript development.
|
||||
- IDE: You can choose your preferred integrated development environment (IDE). We recommend using WebStorm/VSCode.
|
||||
|
||||
### VSCode Users
|
||||
|
||||
We recommend installing the extensions listed in [.vscode/extensions.json](https://github.com/lobehub/lobe-chat/blob/main/.vscode/extensions.json) for the best development experience.
|
||||
|
||||
### Project Setup
|
||||
|
||||
@@ -32,30 +36,35 @@ After installing the above software, you can start setting up the LobeChat proje
|
||||
git clone https://github.com/lobehub/lobe-chat.git
|
||||
```
|
||||
|
||||
2. **Install dependencies**: Then, navigate to the project directory and use Yarn to install the project's dependencies:
|
||||
2. **Install dependencies**: Then, navigate to the project directory and use PNPM to install the project's dependencies:
|
||||
|
||||
```bash
|
||||
cd lobe-chat
|
||||
yarn install
|
||||
```
|
||||
|
||||
If you are using PNPM, you can execute:
|
||||
|
||||
```bash
|
||||
cd lobe-chat
|
||||
pnpm install
|
||||
pnpm i
|
||||
```
|
||||
|
||||
3. **Start the development server**: After installing the dependencies, you can start the development server:
|
||||
|
||||
```bash
|
||||
yarn run dev
|
||||
bun run dev
|
||||
```
|
||||
|
||||
Now, you can open `http://localhost:3010` in your browser, and you should see the welcome page of LobeChat. This indicates that you have successfully set up the development environment.
|
||||
|
||||

|
||||
|
||||
## Working with Server-Side Features
|
||||
|
||||
The basic setup above uses LobeChat's client-side database mode. If you need to work with server-side features such as:
|
||||
|
||||
- Database persistence
|
||||
- File uploads and storage
|
||||
- Image generation
|
||||
- Multi-user authentication
|
||||
- Advanced server-side integrations
|
||||
|
||||
Please refer to the [Work with Server-Side Database](/docs/development/basic/work-with-server-side-database) guide for complete setup instructions.
|
||||
|
||||
During the development process, if you encounter any issues with environment setup or have any questions about LobeChat development, feel free to ask us at any time. We look forward to seeing your contributions!
|
||||
|
||||
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
|
||||
|
||||
@@ -17,10 +17,14 @@
|
||||
首先,你需要安装以下软件:
|
||||
|
||||
- Node.js:LobeChat 是基于 Node.js 构建的,因此你需要安装 Node.js。我们建议安装最新的稳定版。
|
||||
- Bun:我们使用 Bun 作为首选包管理器。你可以从 Bun 的官方网站上下载并安装。
|
||||
- PNPM:我们使用 PNPM 作为辅助包管理器。你可以从 pnpm 的官方网站上下载并安装。
|
||||
- PNPM:我们使用 PNPM 作为管理器。你可以从 [pnpm 的官方网站](https://pnpm.io/installation) 上下载并安装。
|
||||
- Bun:我们使用 Bun 作为 npm scripts runner, 你可以从 [Bun 的官方网站](https://bun.com/docs/installation) 上下载并安装。
|
||||
- Git:我们使用 Git 进行版本控制。你可以从 Git 的官方网站上下载并安装。
|
||||
- IDE:你可以选择你喜欢的集成开发环境(IDE)。我们推荐使用 WebStorm,它是一款功能强大的 IDE,特别适合 TypeScript 开发。
|
||||
- IDE:你可以选择你喜欢的集成开发环境(IDE),我们推荐使用 WebStorm/VSCode。
|
||||
|
||||
### VSCode 用户
|
||||
|
||||
推荐安装 [.vscode/extensions.json](https://github.com/lobehub/lobe-chat/blob/main/.vscode/extensions.json) 中推荐安装的扩展获得最佳开发体验。
|
||||
|
||||
### 项目设置
|
||||
|
||||
@@ -32,14 +36,7 @@
|
||||
git clone https://github.com/lobehub/lobe-chat.git
|
||||
```
|
||||
|
||||
2. **安装依赖**:然后,进入项目目录,并使用 bun 安装项目的依赖包:
|
||||
|
||||
```bash
|
||||
cd lobe-chat
|
||||
bun i
|
||||
```
|
||||
|
||||
如果你使用 pnpm ,可以执行:
|
||||
2. **安装依赖**:然后,进入项目目录,并使用 `pnpm` 安装项目的依赖包:
|
||||
|
||||
```bash
|
||||
cd lobe-chat
|
||||
@@ -54,7 +51,19 @@ bun run dev
|
||||
|
||||
现在,你可以在浏览器中打开 `http://localhost:3010`,你应该能看到 LobeChat 的欢迎页面。这表明你已经成功地设置了开发环境。
|
||||
|
||||

|
||||

|
||||
|
||||
## 使用服务端功能
|
||||
|
||||
上述基础设置使用 LobeChat 的客户端数据库模式。如果你需要开发服务端功能,如:
|
||||
|
||||
- 数据库持久化
|
||||
- 文件上传和存储
|
||||
- 图像生成
|
||||
- 多用户身份验证
|
||||
- 高级服务端集成
|
||||
|
||||
请参考[使用服务端数据库](/docs/development/basic/work-with-server-side-database)指南获得完整的设置说明。
|
||||
|
||||
在开发过程中,如果你在环境设置上遇到任何问题,或者有任何关于 LobeChat 开发的问题,欢迎随时向我们提问。我们期待看到你的贡献!
|
||||
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
# Work with Server-Side Database
|
||||
|
||||
LobeChat provides a battery-included experience with its client-side database.
|
||||
While some features you really care about is only available at a server-side development.
|
||||
|
||||
In order to work with the aspect of server-side database,
|
||||
you can setup all the prerequisites by following the [Deploying Server-Side Database](https://lobehub.com/docs/self-hosting/server-database) story.
|
||||
But here is the easier approach that can reduce your pain.
|
||||
|
||||
## Quick Setup
|
||||
|
||||
### Environment Configuration
|
||||
|
||||
First, copy the example environment file to create your development configuration:
|
||||
|
||||
```bash
|
||||
cp .env.example.development .env.development
|
||||
```
|
||||
|
||||
This file contains all necessary environment variables for server-side database mode and configures:
|
||||
|
||||
- **Service Mode**: `NEXT_PUBLIC_SERVICE_MODE=server`
|
||||
- **Database**: PostgreSQL with connection string
|
||||
- **Authentication**: NextAuth with Casdoor SSO
|
||||
- **Storage**: MinIO S3-compatible storage
|
||||
- **Search**: SearXNG search engine
|
||||
|
||||
### Start Docker Services
|
||||
|
||||
Start all required services using Docker Compose:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.development.yml up -d
|
||||
```
|
||||
|
||||
This will start the following services:
|
||||
|
||||
- PostgreSQL database (port 5432)
|
||||
- MinIO storage (port 9000)
|
||||
- Casdoor authentication (port 8000)
|
||||
- SearXNG search (port 8080)
|
||||
|
||||
### Run Database Migrations
|
||||
|
||||
Execute the database migration script to create all necessary tables:
|
||||
|
||||
```bash
|
||||
pnpm db:migrate
|
||||
```
|
||||
|
||||
You should see: `✅ database migration pass.`
|
||||
|
||||
### Start Development Server
|
||||
|
||||
Launch the LobeChat development server:
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
The server will start on `http://localhost:3010`
|
||||
|
||||
And you can check all Docker services are running by running:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.development.yml ps
|
||||
```
|
||||
|
||||
## Image Generation Development
|
||||
|
||||
When working with image generation features (text-to-image, image-to-image), the Docker Compose setup already includes all necessary storage services for handling generated images and user uploads.
|
||||
|
||||
### Image Generation Configuration
|
||||
|
||||
The existing Docker Compose configuration already includes MinIO storage service and all necessary environment variables in `.env.example.development`. No additional setup is required.
|
||||
|
||||
### Image Generation Architecture
|
||||
|
||||
The image generation feature requires:
|
||||
|
||||
- **PostgreSQL**: Stores metadata about generated images
|
||||
- **MinIO/S3**: Stores the actual image files
|
||||
- **Server Mode**: Required for file handling (`NEXT_PUBLIC_SERVICE_MODE=server`)
|
||||
|
||||
### Storage Configuration
|
||||
|
||||
The `.env.example.development` file includes all necessary S3 environment variables:
|
||||
|
||||
```bash
|
||||
# S3 Storage Configuration (MinIO for local development)
|
||||
S3_ACCESS_KEY_ID=${MINIO_ROOT_USER}
|
||||
S3_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}
|
||||
S3_ENDPOINT=http://localhost:${MINIO_PORT}
|
||||
S3_BUCKET=${MINIO_LOBE_BUCKET}
|
||||
S3_PUBLIC_DOMAIN=http://localhost:${MINIO_PORT}
|
||||
S3_ENABLE_PATH_STYLE=1 # Required for MinIO
|
||||
S3_SET_ACL=0 # MinIO compatibility
|
||||
```
|
||||
|
||||
### File Storage Structure
|
||||
|
||||
Generated images and user uploads are organized in the MinIO bucket:
|
||||
|
||||
```
|
||||
lobe/ # S3 Bucket (MINIO_LOBE_BUCKET)
|
||||
├── generated/ # Generated images
|
||||
│ └── {userId}/
|
||||
│ └── {sessionId}/
|
||||
│ └── {imageId}.png
|
||||
└── uploads/ # User uploads for image-to-image
|
||||
└── {userId}/
|
||||
└── {fileId}.{ext}
|
||||
```
|
||||
|
||||
### Development Workflow for Images
|
||||
|
||||
When developing image generation features, generated images will be:
|
||||
|
||||
1. Created by the AI model
|
||||
2. Uploaded to S3/MinIO via presigned URLs
|
||||
3. Metadata stored in PostgreSQL
|
||||
4. Served via the public S3 URL
|
||||
|
||||
Example code for testing image upload:
|
||||
|
||||
```typescript
|
||||
// Example: Upload generated image
|
||||
const uploadUrl = await trpc.upload.createPresignedUrl.mutate({
|
||||
filename: 'generated-image.png',
|
||||
contentType: 'image/png',
|
||||
});
|
||||
|
||||
// Upload to S3
|
||||
await fetch(uploadUrl, {
|
||||
method: 'PUT',
|
||||
body: imageBlob,
|
||||
headers: { 'Content-Type': 'image/png' },
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Service URLs
|
||||
|
||||
When running with Docker Compose development setup:
|
||||
|
||||
- **PostgreSQL**: `postgres://postgres@localhost:5432/lobechat`
|
||||
- **MinIO API**: `http://localhost:9000`
|
||||
- **MinIO Console**: `http://localhost:9001` (admin/CHANGE_THIS_PASSWORD_IN_PRODUCTION)
|
||||
- **Application**: `http://localhost:3010`
|
||||
|
||||
### Reset Services
|
||||
|
||||
If you encounter issues, you can reset the entire stack:
|
||||
|
||||
```bash
|
||||
# Stop and remove all containers
|
||||
docker-compose -f docker-compose.development.yml down
|
||||
|
||||
# Remove volumes (this will delete all data)
|
||||
docker-compose -f docker-compose.development.yml down -v
|
||||
|
||||
# Start fresh
|
||||
docker-compose -f docker-compose.development.yml up -d
|
||||
pnpm db:migrate
|
||||
```
|
||||
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
#### Port Conflicts
|
||||
|
||||
If ports are already in use:
|
||||
|
||||
```bash
|
||||
# Check what's using the ports
|
||||
lsof -i :5432 # PostgreSQL
|
||||
lsof -i :9000 # MinIO API
|
||||
lsof -i :9001 # MinIO Console
|
||||
```
|
||||
|
||||
#### Database Migrations
|
||||
|
||||
The setup script runs migrations automatically. If you need to run them manually:
|
||||
|
||||
```bash
|
||||
pnpm db:migrate
|
||||
```
|
||||
|
||||
Note: In development mode with `pnpm dev:desktop`, migrations also run automatically on startup.
|
||||
@@ -0,0 +1,189 @@
|
||||
# 使用服务端数据库
|
||||
|
||||
LobeChat 提供了内置的客户端数据库体验。
|
||||
但某些重要功能仅在服务端开发中可用。
|
||||
|
||||
为了使用服务端数据库功能,
|
||||
需要参考 [部署服务端数据库](https://lobehub.com/docs/self-hosting/server-database) 的说明来配置所有前置条件。
|
||||
本文档提供了一个更简化的配置方法,能够在本地开发时快速启动简化的服务端环境。
|
||||
|
||||
## 快速设置
|
||||
|
||||
### 环境配置
|
||||
|
||||
首先,复制示例环境文件来创建你的开发配置:
|
||||
|
||||
```bash
|
||||
cp .env.example.development .env.development
|
||||
```
|
||||
|
||||
此文件包含服务端数据库模式所需的所有环境变量,配置了:
|
||||
|
||||
- **服务模式**: `NEXT_PUBLIC_SERVICE_MODE=server`
|
||||
- **数据库**: 带连接字符串的 PostgreSQL
|
||||
- **身份验证**: 带 Casdoor SSO 的 NextAuth
|
||||
- **存储**: MinIO S3 兼容存储
|
||||
- **搜索**: SearXNG 搜索引擎
|
||||
|
||||
### 启动 Docker 服务
|
||||
|
||||
使用 Docker Compose 启动所有必需的服务:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.development.yml up -d
|
||||
```
|
||||
|
||||
这将启动以下服务:
|
||||
|
||||
- PostgreSQL 数据库(端口 5432)
|
||||
- MinIO 存储(端口 9000)
|
||||
- Casdoor 身份验证(端口 8000)
|
||||
- SearXNG 搜索(端口 8080)
|
||||
|
||||
### 运行数据库迁移
|
||||
|
||||
执行数据库迁移脚本以创建所有必要的表:
|
||||
|
||||
```bash
|
||||
pnpm db:migrate
|
||||
```
|
||||
|
||||
预期输出:`✅ database migration pass.`
|
||||
|
||||
### 启动开发服务器
|
||||
|
||||
启动 LobeChat 开发服务器:
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
服务器将在 `http://localhost:3010` 上启动
|
||||
|
||||
可以通过运行以下命令检查所有 Docker 服务运行状态:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.development.yml ps
|
||||
```
|
||||
|
||||
## 图像生成开发
|
||||
|
||||
在开发图像生成功能(文生图、图生图)时,Docker Compose 配置已经包含了处理生成图像和用户上传所需的所有存储服务。
|
||||
|
||||
### 图像生成配置
|
||||
|
||||
现有的 Docker Compose 配置已经包含了 MinIO 存储服务以及 `.env.example.development` 中的所有必要环境变量。无需额外配置。
|
||||
|
||||
### 图像生成架构
|
||||
|
||||
图像生成功能需要:
|
||||
|
||||
- **PostgreSQL**:存储生成图像的元数据
|
||||
- **MinIO/S3**:存储实际的图像文件
|
||||
- **服务器模式**:文件处理所需(`NEXT_PUBLIC_SERVICE_MODE=server`)
|
||||
|
||||
### 存储配置
|
||||
|
||||
`.env.example.development` 文件包含所有必要的 S3 环境变量:
|
||||
|
||||
```bash
|
||||
# S3 存储配置(本地开发使用 MinIO)
|
||||
S3_ACCESS_KEY_ID=${MINIO_ROOT_USER}
|
||||
S3_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}
|
||||
S3_ENDPOINT=http://localhost:${MINIO_PORT}
|
||||
S3_BUCKET=${MINIO_LOBE_BUCKET}
|
||||
S3_PUBLIC_DOMAIN=http://localhost:${MINIO_PORT}
|
||||
S3_ENABLE_PATH_STYLE=1 # MinIO 必需
|
||||
S3_SET_ACL=0 # MinIO 兼容性
|
||||
```
|
||||
|
||||
### 文件存储结构
|
||||
|
||||
生成的图像和用户上传在 MinIO 存储桶中按以下方式组织:
|
||||
|
||||
```
|
||||
lobe/ # S3 存储桶 (MINIO_LOBE_BUCKET)
|
||||
├── generated/ # 生成的图像
|
||||
│ └── {userId}/
|
||||
│ └── {sessionId}/
|
||||
│ └── {imageId}.png
|
||||
└── uploads/ # 用户上传的图像处理文件
|
||||
└── {userId}/
|
||||
└── {fileId}.{ext}
|
||||
```
|
||||
|
||||
### 图像开发工作流
|
||||
|
||||
在开发图像生成功能时,生成的图像将:
|
||||
|
||||
1. 由 AI 模型创建
|
||||
2. 通过预签名 URL 上传到 S3/MinIO
|
||||
3. 元数据存储在 PostgreSQL 中
|
||||
4. 通过公共 S3 URL 提供服务
|
||||
|
||||
测试图像上传的示例代码:
|
||||
|
||||
```typescript
|
||||
// 示例:上传生成的图像
|
||||
const uploadUrl = await trpc.upload.createPresignedUrl.mutate({
|
||||
filename: 'generated-image.png',
|
||||
contentType: 'image/png',
|
||||
});
|
||||
|
||||
// 上传到 S3
|
||||
await fetch(uploadUrl, {
|
||||
method: 'PUT',
|
||||
body: imageBlob,
|
||||
headers: { 'Content-Type': 'image/png' },
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### 服务地址
|
||||
|
||||
运行 Docker Compose 开发环境时:
|
||||
|
||||
- **PostgreSQL**:`postgres://postgres@localhost:5432/lobechat`
|
||||
- **MinIO API**:`http://localhost:9000`
|
||||
- **MinIO 控制台**:`http://localhost:9001` (admin/CHANGE_THIS_PASSWORD_IN_PRODUCTION)
|
||||
- **应用程序**:`http://localhost:3010`
|
||||
|
||||
### 重置服务
|
||||
|
||||
如遇到问题,可以重置整个服务堆栈:
|
||||
|
||||
```bash
|
||||
# 停止并删除所有容器
|
||||
docker-compose -f docker-compose.development.yml down
|
||||
|
||||
# 删除卷(这将删除所有数据)
|
||||
docker-compose -f docker-compose.development.yml down -v
|
||||
|
||||
# 重新启动
|
||||
docker-compose -f docker-compose.development.yml up -d
|
||||
pnpm db:migrate
|
||||
```
|
||||
|
||||
|
||||
### 故障排除
|
||||
|
||||
#### 端口冲突
|
||||
|
||||
如果端口已被占用:
|
||||
|
||||
```bash
|
||||
# 检查端口使用情况
|
||||
lsof -i :5432 # PostgreSQL
|
||||
lsof -i :9000 # MinIO API
|
||||
lsof -i :9001 # MinIO 控制台
|
||||
```
|
||||
|
||||
#### 数据库迁移
|
||||
|
||||
配置脚本会自动运行迁移。如需手动运行:
|
||||
|
||||
```bash
|
||||
pnpm db:migrate
|
||||
```
|
||||
|
||||
注意:在使用 `pnpm dev:desktop` 的开发模式下,迁移也会在启动时自动运行。
|
||||
@@ -1,8 +1,8 @@
|
||||
table agents {
|
||||
id text [pk, not null]
|
||||
slug varchar(100) [unique]
|
||||
title text
|
||||
description text
|
||||
title varchar(255)
|
||||
description varchar(1000)
|
||||
tags jsonb [default: `[]`]
|
||||
avatar text
|
||||
background_color text
|
||||
@@ -24,6 +24,8 @@ table agents {
|
||||
|
||||
indexes {
|
||||
(client_id, user_id) [name: 'client_id_user_id_unique', unique]
|
||||
title [name: 'agents_title_idx']
|
||||
description [name: 'agents_description_idx']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +106,19 @@ table ai_providers {
|
||||
}
|
||||
}
|
||||
|
||||
table api_keys {
|
||||
id integer [pk, not null]
|
||||
name varchar(256) [not null]
|
||||
key varchar(256) [not null, unique]
|
||||
enabled boolean [default: true]
|
||||
expires_at "timestamp with time zone"
|
||||
last_used_at "timestamp with time zone"
|
||||
user_id text [not null]
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
}
|
||||
|
||||
table async_tasks {
|
||||
id uuid [pk, not null, default: `gen_random_uuid()`]
|
||||
type text
|
||||
@@ -116,6 +131,40 @@ table async_tasks {
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
}
|
||||
|
||||
table chat_groups {
|
||||
id text [pk, not null]
|
||||
title text
|
||||
description text
|
||||
config jsonb
|
||||
client_id text
|
||||
user_id text [not null]
|
||||
group_id text
|
||||
pinned boolean [default: false]
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
|
||||
indexes {
|
||||
(client_id, user_id) [name: 'chat_groups_client_id_user_id_unique', unique]
|
||||
}
|
||||
}
|
||||
|
||||
table chat_groups_agents {
|
||||
chat_group_id text [not null]
|
||||
agent_id text [not null]
|
||||
user_id text [not null]
|
||||
enabled boolean [default: true]
|
||||
order integer [default: 0]
|
||||
role text [default: 'participant']
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
|
||||
indexes {
|
||||
(chat_group_id, agent_id) [pk]
|
||||
}
|
||||
}
|
||||
|
||||
table document_chunks {
|
||||
document_id varchar(30) [not null]
|
||||
chunk_id uuid [not null]
|
||||
@@ -339,7 +388,7 @@ table message_translates {
|
||||
|
||||
table messages {
|
||||
id text [pk, not null]
|
||||
role text [not null]
|
||||
role varchar(255) [not null]
|
||||
content text
|
||||
reasoning jsonb
|
||||
search jsonb
|
||||
@@ -359,6 +408,8 @@ table messages {
|
||||
parent_id text
|
||||
quota_id text
|
||||
agent_id text
|
||||
group_id text
|
||||
target_id text
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
@@ -369,6 +420,9 @@ table messages {
|
||||
topic_id [name: 'messages_topic_id_idx']
|
||||
parent_id [name: 'messages_parent_id_idx']
|
||||
quota_id [name: 'messages_quota_id_idx']
|
||||
user_id [name: 'messages_user_id_idx']
|
||||
session_id [name: 'messages_session_id_idx']
|
||||
thread_id [name: 'messages_thread_id_idx']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,6 +628,7 @@ table chunks {
|
||||
|
||||
indexes {
|
||||
(client_id, user_id) [name: 'chunks_client_id_user_id_unique', unique]
|
||||
user_id [name: 'chunks_user_id_idx']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,6 +642,7 @@ table embeddings {
|
||||
|
||||
indexes {
|
||||
(client_id, user_id) [name: 'embeddings_client_id_user_id_unique', unique]
|
||||
chunk_id [name: 'embeddings_chunk_id_idx']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,6 +758,7 @@ table rbac_roles {
|
||||
description text
|
||||
is_system boolean [not null, default: false]
|
||||
is_active boolean [not null, default: true]
|
||||
metadata jsonb [default: `{}`]
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
@@ -785,6 +842,8 @@ table sessions {
|
||||
indexes {
|
||||
(slug, user_id) [name: 'slug_user_id_unique', unique]
|
||||
(client_id, user_id) [name: 'sessions_client_id_user_id_unique', unique]
|
||||
user_id [name: 'sessions_user_id_idx']
|
||||
(id, user_id) [name: 'sessions_id_user_id_idx']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,6 +883,7 @@ table topics {
|
||||
title text
|
||||
favorite boolean [default: false]
|
||||
session_id text
|
||||
group_id text
|
||||
user_id text [not null]
|
||||
client_id text
|
||||
history_summary text
|
||||
@@ -834,6 +894,8 @@ table topics {
|
||||
|
||||
indexes {
|
||||
(client_id, user_id) [name: 'topics_client_id_user_id_unique', unique]
|
||||
user_id [name: 'topics_user_id_idx']
|
||||
(id, user_id) [name: 'topics_id_user_id_idx']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,6 +957,14 @@ ref: agents_to_sessions.session_id > sessions.id
|
||||
|
||||
ref: agents_to_sessions.agent_id > agents.id
|
||||
|
||||
ref: chat_groups_agents.chat_group_id > chat_groups.id
|
||||
|
||||
ref: chat_groups_agents.agent_id > agents.id
|
||||
|
||||
ref: chat_groups_agents.user_id - users.id
|
||||
|
||||
ref: chat_groups.user_id - users.id
|
||||
|
||||
ref: unstructured_chunks.file_id - files.id
|
||||
|
||||
ref: document_chunks.document_id > documents.id
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{/* eslint-disable no-irregular-whitespace */}
|
||||
|
||||
# Best Practices for State Management
|
||||
|
||||
LobeChat differs from traditional CRUD web applications in that it involves a large amount of rich interactive capabilities. Therefore, it is crucial to design a data flow architecture that is easy to develop and maintain. This document will introduce the best practices for data flow management in LobeChat.
|
||||
@@ -111,6 +109,8 @@ Based on the provided directory structure of LobeChat SessionStore, we can updat
|
||||
|
||||
In the LobeChat application, session management is a complex functional module, so we use the Slice pattern to organize the data flow. Below is the directory structure of LobeChat SessionStore, where each directory and file has its specific purpose:
|
||||
|
||||
{/* eslint-disable no-irregular-whitespace */}
|
||||
|
||||
```bash
|
||||
src/store/session
|
||||
├── helpers.ts # Helper functions
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{/* eslint-disable no-irregular-whitespace */}
|
||||
|
||||
# 状态管理最佳实践
|
||||
|
||||
LobeChat 不同于传统 CRUD 的网页,存在大量的富交互能力,如何设计一个易于开发与易于维护的数据流架构非常重要。本篇文档将介绍 LobeChat 中的数据流管理最佳实践。
|
||||
@@ -111,6 +109,8 @@ LobeChat SessionStore
|
||||
|
||||
在 LobeChat 应用中,由于会话管理是一个复杂的功能模块,因此我们采用了 [slice 模式](https://github.com/pmndrs/zustand/blob/main/docs/guides/slices-pattern.md) 来组织数据流。下面是 LobeChat SessionStore 的目录结构,其中每个目录和文件都有其特定的用途:
|
||||
|
||||
{/* eslint-disable no-irregular-whitespace */}
|
||||
|
||||
```fish
|
||||
src/store/session
|
||||
├── index.ts # SessionStore 的聚合导出文件
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: Observability with Grafana, Prometheus, and Tempo
|
||||
description: >-
|
||||
Monitor and analyze your LobeChat instance using Grafana dashboards, Prometheus metrics, and Tempo traces. This guide covers setup, configuration for self-hosted deployments.
|
||||
tags:
|
||||
- Observability
|
||||
- Grafana
|
||||
- Prometheus
|
||||
- Tempo
|
||||
---
|
||||
|
||||
# Observability with [Grafana](https://grafana.com/), [Prometheus](https://prometheus.io/), and [Tempo](https://grafana.com/docs/tempo/latest/)
|
||||
|
||||
LobeChat supports advanced observability for self-hosted deployments using open-source tools:
|
||||
|
||||
- **Grafana** for dashboards and visualization
|
||||
- **Prometheus** for metrics collection
|
||||
- **Tempo** for distributed tracing
|
||||
- **otel-collector** ingesting other OpenTelemetry supported data
|
||||
|
||||
We provided Docker Compose (`docker-compose`) file presets to bootstrap the observability stack with advanced self-hosting features.
|
||||
This guide will help you set up and use these tools to monitor your LobeChat instance.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- `docker` CLI
|
||||
- OrbStack (macOS), or Docker Desktop Windows
|
||||
- `docker-compose` plugin enabled (check through `docker compose version`)
|
||||
|
||||
## 1. Deploy
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/production/grafana/docker-compose.yml
|
||||
curl -O https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/production/grafana/.env.example
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
1. Update the password & secrets in the `.env` file as needed.
|
||||
2. Start the stack with the correct profile:
|
||||
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
This will launch Grafana, Prometheus, Tempo, and the otel-collector alongside LobeChat with Casdoor, Minio, and other advanced services.
|
||||
|
||||
## 2. Access Grafana Dashboards
|
||||
|
||||
- Open Grafana in your browser at [http://localhost:3000](http://localhost:3000) (or your server's IP).
|
||||
- Default login (if required):
|
||||
- **Username:** admin
|
||||
- **Password:** (see your environment or Docker Compose file)
|
||||
|
||||
## 3. Explore traces & metrics
|
||||
|
||||
Click on "Explore" in the left sidebar to access the query editor to run ad-hoc queries against your Prometheus and Tempo data sources.
|
||||
|
||||
## 4. Troubleshooting
|
||||
|
||||
- Ensure all containers are running: `docker compose ps`
|
||||
- Check logs for any service: `docker compose logs <service-name>`
|
||||
- Verify Prometheus and Tempo are scraping and receiving data from LobeChat and otel-collector.
|
||||
|
||||
## See Also
|
||||
|
||||
- [Langfuse Observability](https://lobehub.com/docs/self-hosting/advanced/observability/langfuse)
|
||||
- [Self-Hosting Overview](https://lobehub.com/docs/self-hosting/start)
|
||||
|
||||
---
|
||||
|
||||
For questions or feedback, open an issue on GitHub or join our community discussions.
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: 使用 Grafana、Prometheus 和 Tempo 进行可观测性监控
|
||||
description: >-
|
||||
使用 Grafana、Prometheus 指标和 Tempo 链路追踪,监控和分析你的 LobeChat 实例。本指南涵盖自托管部署的搭建、配置和示例仪表盘。
|
||||
tags:
|
||||
- 可观测性
|
||||
- Grafana
|
||||
- Prometheus
|
||||
- Tempo
|
||||
---
|
||||
|
||||
# 使用 [Grafana](https://grafana.com/)、[Prometheus](https://prometheus.io/) 和 [Tempo](https://grafana.com/docs/tempo/latest/) 进行可观测性监控
|
||||
|
||||
LobeChat 支持通过开源工具实现自托管部署的高级可观测性:
|
||||
|
||||
- **Grafana**:仪表盘与可视化
|
||||
- **Prometheus**:指标采集
|
||||
- **Tempo**:分布式链路追踪
|
||||
- **otel-collector**:采集 OpenTelemetry 支持的数据
|
||||
|
||||
我们提供了 Docker Compose (`docker-compose`) 预设文件,帮助你一键启动包含高级可观测性功能的自托管栈。
|
||||
|
||||
## 前置条件
|
||||
|
||||
- 已安装 `docker` 命令行工具
|
||||
- OrbStack(macOS)或 Docker Desktop(Windows)
|
||||
- 启用 `docker-compose` 插件(可通过 `docker compose version` 检查)
|
||||
|
||||
## 1. 部署
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/production/grafana/docker-compose.yml
|
||||
curl -O https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/production/grafana/.env.example
|
||||
mv .env.example .env
|
||||
```
|
||||
|
||||
1. 根据需要修改 `.env` 文件中的密码和密钥。
|
||||
2. 使用如下命令启动服务:
|
||||
|
||||
```sh
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
这将会启动 Grafana、Prometheus、Tempo、otel-collector 以及 LobeChat、Casdoor、Minio 等高级服务。
|
||||
|
||||
## 2. 访问 Grafana 仪表盘
|
||||
|
||||
- 在浏览器中打开 [http://localhost:3000](http://localhost:3000)(或你的服务器 IP)。
|
||||
- 默认登录信息(如需):
|
||||
- **用户名:** admin
|
||||
- **密码:** 见你的环境变量或 Docker Compose 文件
|
||||
|
||||
## 3. 探索链路追踪与指标
|
||||
|
||||
点击左侧边栏的 “Explore” 进入查询编辑器,可对 Prometheus 和 Tempo 数据源进行即席查询。
|
||||
|
||||
## 4. 故障排查
|
||||
|
||||
- 确认所有容器已运行:`docker compose ps`
|
||||
- 查看服务日志:`docker compose logs <服务名>`
|
||||
- 检查 Prometheus 和 Tempo 是否正常采集 LobeChat 及 otel-collector 的数据。
|
||||
|
||||
## 相关链接
|
||||
|
||||
- [Langfuse 可观测性](https://lobehub.com/zh/docs/self-hosting/advanced/observability/langfuse)
|
||||
- [自托管总览](https://lobehub.com/zh/docs/self-hosting/start)
|
||||
|
||||
---
|
||||
|
||||
如有问题或建议,欢迎在 GitHub 提 Issue 或加入社区讨论。
|
||||
@@ -34,15 +34,15 @@ CRAWLER_IMPLS="native,search1api"
|
||||
|
||||
Supported crawler types are listed below:
|
||||
|
||||
| Value | Description | Environment Variable |
|
||||
| ------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------- |
|
||||
| `browserless` | Headless browser crawler based on [Browserless](https://www.browserless.io/), suitable for rendering complex pages. | `BROWSERLESS_TOKEN` |
|
||||
| `exa` | Crawler capabilities provided by [Exa](https://exa.ai/), API required. | `EXA_API_KEY` |
|
||||
| `firecrawl` | [Firecrawl](https://firecrawl.dev/) headless browser API, ideal for modern websites. | `FIRECRAWL_API_KEY` |
|
||||
| `jina` | Crawler service from [Jina AI](https://jina.ai/), supports fast content summarization. | `JINA_READER_API_KEY` |
|
||||
| `native` | Built-in general-purpose crawler for standard web structures. | |
|
||||
| `search1api` | Page crawling capabilities from [Search1API](https://www.search1api.com), great for structured content extraction. | `SEARCH1API_CRAWL_API_KEY` |
|
||||
| `tavily` | Web scraping and summarization API from [Tavily](https://www.tavily.com/). | `TAVILY_API_KEY` |
|
||||
| Value | Description | Environment Variable |
|
||||
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||
| `browserless` | Headless browser crawler based on [Browserless](https://www.browserless.io/), suitable for rendering complex pages. | `BROWSERLESS_TOKEN` |
|
||||
| `exa` | Crawler capabilities provided by [Exa](https://exa.ai/), API required. | `EXA_API_KEY` |
|
||||
| `firecrawl` | [Firecrawl](https://firecrawl.dev/) headless browser API, ideal for modern websites. | `FIRECRAWL_API_KEY` |
|
||||
| `jina` | Crawler service from [Jina AI](https://jina.ai/), supports fast content summarization. | `JINA_READER_API_KEY` |
|
||||
| `native` | Built-in general-purpose crawler for standard web structures. | |
|
||||
| `search1api` | Page crawling capabilities from [Search1API](https://www.search1api.com), great for structured content extraction. | `SEARCH1API_API_KEY` `SEARCH1API_CRAWL_API_KEY` `SEARCH1API_SEARCH_API_KEY` |
|
||||
| `tavily` | Web scraping and summarization API from [Tavily](https://www.tavily.com/). | `TAVILY_API_KEY` |
|
||||
|
||||
> 💡 Setting multiple crawlers increases success rate; the system will try different ones based on priority.
|
||||
|
||||
@@ -58,19 +58,19 @@ SEARCH_PROVIDERS="searxng"
|
||||
|
||||
Supported search engines include:
|
||||
|
||||
| Value | Description | Environment Variable |
|
||||
| ------------ | --------------------------------------------------------------------------------------- | ------------------------------------------- |
|
||||
| `anspire` | Search service provided by [Anspire](https://anspire.ai/). | `ANSPIRE_API_KEY` |
|
||||
| `bocha` | Search service from [Bocha](https://open.bochaai.com/). | `BOCHA_API_KEY` |
|
||||
| `brave` | [Brave](https://search.brave.com/help/api), a privacy-friendly search source. | `BRAVE_API_KEY` |
|
||||
| `exa` | [Exa](https://exa.ai/), a search API designed for AI. | `EXA_API_KEY` |
|
||||
| `firecrawl` | Search capabilities via [Firecrawl](https://firecrawl.dev/). | `FIRECRAWL_API_KEY` |
|
||||
| `google` | Uses [Google Programmable Search Engine](https://programmablesearchengine.google.com/). | `GOOGLE_PSE_API_KEY` `GOOGLE_PSE_ENGINE_ID` |
|
||||
| `jina` | Semantic search provided by [Jina AI](https://jina.ai/). | `JINA_READER_API_KEY` |
|
||||
| `kagi` | Premium search API by [Kagi](https://kagi.com/), requires a subscription key. | `KAGI_API_KEY` |
|
||||
| `search1api` | Aggregated search capabilities from [Search1API](https://www.search1api.com). | `SEARCH1API_CRAWL_API_KEY` |
|
||||
| `searxng` | Use a self-hosted or public [SearXNG](https://searx.space/) instance. | `SEARXNG_URL` |
|
||||
| `tavily` | [Tavily](https://www.tavily.com/), offers fast web summaries and answers. | `TAVILY_API_KEY` |
|
||||
| Value | Description | Environment Variable |
|
||||
| ------------ | --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||
| `anspire` | Search service provided by [Anspire](https://anspire.ai/). | `ANSPIRE_API_KEY` |
|
||||
| `bocha` | Search service from [Bocha](https://open.bochaai.com/). | `BOCHA_API_KEY` |
|
||||
| `brave` | [Brave](https://search.brave.com/help/api), a privacy-friendly search source. | `BRAVE_API_KEY` |
|
||||
| `exa` | [Exa](https://exa.ai/), a search API designed for AI. | `EXA_API_KEY` |
|
||||
| `firecrawl` | Search capabilities via [Firecrawl](https://firecrawl.dev/). | `FIRECRAWL_API_KEY` |
|
||||
| `google` | Uses [Google Programmable Search Engine](https://programmablesearchengine.google.com/). | `GOOGLE_PSE_API_KEY` `GOOGLE_PSE_ENGINE_ID` |
|
||||
| `jina` | Semantic search provided by [Jina AI](https://jina.ai/). | `JINA_READER_API_KEY` |
|
||||
| `kagi` | Premium search API by [Kagi](https://kagi.com/), requires a subscription key. | `KAGI_API_KEY` |
|
||||
| `search1api` | Aggregated search capabilities from [Search1API](https://www.search1api.com). | `SEARCH1API_API_KEY` `SEARCH1API_CRAWL_API_KEY` `SEARCH1API_SEARCH_API_KEY` |
|
||||
| `searxng` | Use a self-hosted or public [SearXNG](https://searx.space/) instance. | `SEARXNG_URL` |
|
||||
| `tavily` | [Tavily](https://www.tavily.com/), offers fast web summaries and answers. | `TAVILY_API_KEY` |
|
||||
|
||||
> ⚠️ Some search providers require you to apply for an API Key and configure it in your `.env` file.
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ CRAWLER_IMPLS="native,search1api"
|
||||
| `firecrawl` | [Firecrawl](https://firecrawl.dev/) 无头浏览器 API,适合现代网站抓取。 | `FIRECRAWL_API_KEY` |
|
||||
| `jina` | 使用 [Jina AI](https://jina.ai/) 的爬虫服务,支持快速提取摘要信息。 | `JINA_READER_API_KEY` |
|
||||
| `native` | 内置通用爬虫,适用于标准网页结构。 | |
|
||||
| `search1api` | 利用 [Search1API](https://www.search1api.com) 提供的页面抓取能力,适合结构化内容提取。 | `SEARCH1API_CRAWL_API_KEY` |
|
||||
| `search1api` | 利用 [Search1API](https://www.search1api.com) 提供的页面抓取能力,适合结构化内容提取。 | `SEARCH1API_API_KEY` `SEARCH1API_CRAWL_API_KEY` `SEARCH1API_SEARCH_API_KEY` |
|
||||
| `tavily` | 使用 [Tavily](https://www.tavily.com/) 的网页抓取与摘要 API。 | `TAVILY_API_KEY` |
|
||||
|
||||
> 💡 设置多个爬虫可提升成功率,系统将根据优先级尝试不同爬虫。
|
||||
@@ -64,7 +64,7 @@ SEARCH_PROVIDERS="searxng"
|
||||
| `google` | 使用 [Google Programmable Search Engine](https://programmablesearchengine.google.com/)。 | `GOOGLE_PSE_API_KEY` `GOOGLE_PSE_ENGINE_ID` |
|
||||
| `jina` | 使用 [Jina AI](https://jina.ai/) 提供的语义搜索服务。 | `JINA_READER_API_KEY` |
|
||||
| `kagi` | [Kagi](https://kagi.com/) 提供的高级搜索 API,需订阅 Key。 | `KAGI_API_KEY` |
|
||||
| `search1api` | 使用 [Search1API](https://www.search1api.com) 聚合搜索能力。 | `SEARCH1API_CRAWL_API_KEY` |
|
||||
| `search1api` | 使用 [Search1API](https://www.search1api.com) 聚合搜索能力。 | `SEARCH1API_API_KEY` `SEARCH1API_CRAWL_API_KEY` `SEARCH1API_SEARCH_API_KEY` |
|
||||
| `searxng` | 使用自托管或公共 [SearXNG](https://searx.space/) 实例。 | `SEARXNG_URL` |
|
||||
| `tavily` | [Tavily](https://www.tavily.com/),快速网页摘要与答案返回。 | `TAVILY_API_KEY` |
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ We need to configure an S3 storage service in the server-side database to store
|
||||
<Image alt={'Configure allowed site domain'} src={'https://github.com/lobehub/lobe-chat/assets/28616219/dfcc2cb3-2958-4498-a8a4-51bec584fe7d'} />
|
||||
|
||||
<Callout type={'info'}>
|
||||
If you also plan to use the desktop client, add <code>http://localhost:3015</code> to <code>AllowedOrigins</code> so the desktop client (running locally) can access R2.
|
||||
If you also plan to use the desktop client, add <code>[http://localhost:3015](http://localhost:3015)</code> to <code>AllowedOrigins</code> so the desktop client (running locally) can access R2.
|
||||
</Callout>
|
||||
|
||||
Example configuration is as follows:
|
||||
|
||||
@@ -82,10 +82,10 @@ tags:
|
||||
添加跨域规则,允许你的域名(在上文是 `https://your-project.vercel.app`)来源的请求:
|
||||
|
||||
<Image alt={'配置允许你的站点域名'} src={'https://github.com/lobehub/lobe-chat/assets/28616219/dfcc2cb3-2958-4498-a8a4-51bec584fe7d'} />
|
||||
<Callout type={'info'}>
|
||||
如果你还需要在桌面端使用,请在 <code>AllowedOrigins</code> 中额外添加 <code>http://localhost:3015</code>,以便桌面端(本地运行)能够访问 R2。
|
||||
</Callout>
|
||||
|
||||
<Callout type={'info'}>
|
||||
如果你还需要在桌面端使用,请在 <code>AllowedOrigins</code> 中额外添加 <code>[http://localhost:3015](http://localhost:3015)</code>,以便桌面端(本地运行)能够访问 R2。
|
||||
</Callout>
|
||||
|
||||
示例配置如下:
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
---
|
||||
title: LobeChat WebRTC Sync - Real-Time Data Sharing
|
||||
description: >-
|
||||
Explore LobeChat's WebRTC sync for real-time data sharing and privacy without servers.
|
||||
|
||||
tags:
|
||||
- WebRTC
|
||||
- LobeChat
|
||||
- Data Synchronization
|
||||
- Real-Time Communication
|
||||
- Peer-to-Peer
|
||||
---
|
||||
|
||||
# LobeChat WebRTC Sync
|
||||
|
||||
## Introduction to WebRTC
|
||||
|
||||
WebRTC (Web Real-Time Communication) is a technology that enables peer-to-peer communication between browsers. In LobeChat, we experimentally implemented real-time data synchronization between devices based on WebRTC and YJS, without relying on traditional server databases. This solution offers high privacy, zero conflicts, and provides a real-time session synchronization experience.
|
||||
|
||||
## Configuring WebRTC for Synchronization
|
||||
|
||||
To use the WebRTC synchronization feature in LobeChat, you need to complete the following steps:
|
||||
|
||||
<Steps>
|
||||
### Deploy Signaling Server
|
||||
|
||||
Deploy a WebRTC signaling server with one click using the Zeabur platform:
|
||||
|
||||
[](https://zeabur.com/templates/MY0JZG?referralCode=arvinxx)
|
||||
|
||||
Alternatively, you can view the [source code](https://github.com/lobehub/y-webrtc-signaling) and deploy it on your own.
|
||||
|
||||
After deployment, you will receive a URL, for example: `https://my-signaling-server.zeabur.app`.
|
||||
|
||||
### Enable WebRTC Sync in the Deployment Instance
|
||||
|
||||
The WebRTC sync feature in LobeChat is hidden by default and needs to be enabled by adding the environment variable `FEATURE_FLAGS=+webrtc_sync`.
|
||||
|
||||
### Configure WebRTC Sync Settings in LobeChat
|
||||
|
||||
1. Open LobeChat settings -> Data Sync
|
||||
2. Enter the signaling server address in the WebRTC sync section;
|
||||
3. Set the sync channel name and password
|
||||
|
||||
<Image alt={'LobeChat Data Sync Settings Page'} height={356} inStep src={'https://github.com/lobehub/lobe-chat/assets/28616219/bf86bf1e-87fb-4015-8587-15ff28bb9c24'} />
|
||||
|
||||
### Repeat the Above Configuration on Devices that Need to Sync
|
||||
|
||||
Ensure all devices use the same signaling server, channel name, and password. Once configured, the devices should automatically start syncing data.
|
||||
</Steps>
|
||||
|
||||
## Limitations and Known Issues
|
||||
|
||||
Although WebRTC has the advantages of no database and flexibility, after extensive community testing, the following limitations and known issues have been identified:
|
||||
|
||||
### Requirement for Devices to be Online Simultaneously
|
||||
|
||||
WebRTC requires devices to be online simultaneously to synchronize, meaning changes cannot be made on one device while offline and then synced later on another device.
|
||||
|
||||
This limitation is due to the communication nature of WebRTC. In a pure frontend, serverless scenario, data synchronization between two devices can only be achieved through peer-to-peer communication. When one device is online and the other is offline, it is impossible to determine where the data should come from. Only when both devices are online can data communication occur. This mode is more like an online chat room where everyone needs to be online to see each other's data and achieve synchronization.
|
||||
|
||||
Therefore, in certain situations, WebRTC's pure peer-to-peer approach may not fully meet users' needs (e.g., one device is a work computer, and the other is a home computer), and there are also some issues with data synchronization.
|
||||
|
||||
### Network Issues Leading to Sync Failures
|
||||
|
||||
Due to the implementation mechanism of WebRTC, its peer-to-peer communication has strict network requirements. Many of our users have reported:
|
||||
|
||||
- Syncing between PCs is possible, but syncing between a mobile device with a SIM card and a PC is not, although syncing is possible when using the same WIFI as the PC;
|
||||
- Syncing fails when switching networks.
|
||||
|
||||
### Stability and Performance Issues
|
||||
|
||||
- Some users have reported ICE connection failures on the Firefox browser: [WebRTC Data Sync Feedback](https://github.com/lobehub/lobe-chat/issues/1683#issuecomment-2094745907)
|
||||
- For extremely long text or large amounts of conversation records, the synchronization process may slow down or become unstable: [When the model outputs a very long conversation, the end of the conversation will contain synchronization-related content tags, leading to sync failures](https://github.com/lobehub/lobe-chat/issues/1962)
|
||||
|
||||
## Our Recommendations
|
||||
|
||||
Considering the above reasons, we recommend users treat the WebRTC sync feature as experimental and regularly back up important data.
|
||||
|
||||
We have already released a more stable and user-friendly server database synchronization solution ([deployment guide](/docs/self-hosting/advanced/server-database)). We recommend users prioritize using the server database synchronization solution.
|
||||
|
||||
<Callout type={'warning'}>
|
||||
Please note that we have officially announced the archiving of this sync feature in [PR
|
||||
3182](https://github.com/lobehub/lobe-chat/pull/3182), and the above issues will no longer be
|
||||
considered for fixes.
|
||||
</Callout>
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
title: LobeChat WebRTC 同步配置指南
|
||||
description: 在 LobeChat 中实现基于 WebRTC 和 YJS 的设备间实时数据同步。了解如何配置 WebRTC 并开启同步功能,以及使用局限性和已知问题。
|
||||
tags:
|
||||
- YJS
|
||||
- 信令服务器
|
||||
---
|
||||
|
||||
# LobeChat WebRTC 同步
|
||||
|
||||
## WebRTC 简介
|
||||
|
||||
WebRTC (Web Real-Time Communication) 是一项实现浏览器之间点对点通信的技术。在 LobeChat 中,我们实验性地基于 WebRTC 和 YJS 实现了设备间的实时数据同步,无需依赖传统的服务器数据库。这种方案具有高度隐私性、零冲突性,并能提供实时会话同步体验。
|
||||
|
||||
## 配置 WebRTC 并实现同步
|
||||
|
||||
要使用 LobeChat 的 WebRTC 同步功能,需要完成以下步骤:
|
||||
|
||||
<Steps>
|
||||
### 部署信令服务器
|
||||
|
||||
使用 Zeabur 平台一键部署 WebRTC 信令服务器:
|
||||
|
||||
[](https://zeabur.com/templates/MY0JZG?referralCode=arvinxx)
|
||||
|
||||
或者查看 [源码](https://github.com/lobehub/y-webrtc-signaling) 自行部署。
|
||||
|
||||
部署完成后,可以得到一个 URL,例如:`https://my-signaling-server.zeabur.app`。
|
||||
|
||||
### 在部署实例中开启 WebRTC 同步
|
||||
|
||||
LobeChat 默认隐藏了 WebRTC 同步功能,需要通过添加环境变量 `FEATURE_FLAGS=+webrtc_sync` 来开启 WebRTC 同步特性。
|
||||
|
||||
### 配置 LobeChat 的 WebRTC 同步设置
|
||||
|
||||
1. 打开 LobeChat 设置 -> 数据同步
|
||||
2. 在 WebRTC 同步中填写信令服务器地址;
|
||||
3. 设置同步频道名称和密码
|
||||
|
||||
<Image alt={'LobeChat 数据同步设置页'} height={356} inStep src={'https://github.com/lobehub/lobe-chat/assets/28616219/bf86bf1e-87fb-4015-8587-15ff28bb9c24'} />
|
||||
|
||||
### 在需要同步的设备上重复以上配置
|
||||
|
||||
确保所有设备使用相同的信令服务器、频道名称和密码,完成配置后,设备间应该可以开始自动同步数据。
|
||||
</Steps>
|
||||
|
||||
## 使用局限性和已知问题
|
||||
|
||||
虽然 WebRTC 具有无数据库、比较灵活的特性,但目前该功能经过大范围社区测试,存在以下局限性和已知问题:
|
||||
|
||||
### 设备同时在线要求
|
||||
|
||||
WebRTC 要求设备同时在线才能进行同步,这意味着无法在一台设备离线时在另一台设备上进行更改并稍后同步。
|
||||
|
||||
这是 WebRTC 本身的通信特性有关系,由于在纯前端、无服务端的情况下,两个设备的数据同步只能通过点对点通信的形式达成。当一个设备在线,一个设备离线的情况下,我们无从感知数据到底应该从哪来,只有当两台设备都在线的时候,双发数据才能通信。其实这种模式更像是一个在线聊天室,大家都在线时才能看到对方的数据,然后达成同步。
|
||||
|
||||
因此 WebRTC 这种纯点对点的方式在某些情况下并无法完全满足用户的诉求(例如一个是公司电脑,一个是家里电脑),同时也存在一些数据同步层面的问题。
|
||||
|
||||
### 网络问题可能导致同步失败
|
||||
|
||||
由于 WebRTC 的实现机制,其点对点通信对于网络要求非常苛刻,我们的很多用户反馈:
|
||||
|
||||
- 在 PC 上可以互相同步、 手机 sim 卡无法和 PC 同步、但是换成和 PC 一样的 WIFI 可以和 PC 同步;
|
||||
- 任何切换网络都无法同步;
|
||||
|
||||
### 稳定性与性能问题
|
||||
|
||||
- 部分用户报告在 Firefox 浏览器上遇到 ICE 连接失败的问题:[WebRTC Data Sync Feedback](https://github.com/lobehub/lobe-chat/issues/1683#issuecomment-2094745907)
|
||||
- 对于超长文本或大量对话记录,同步过程可能变慢或不稳定:[当模型输出超长对话时,对话末尾会出现同步相关的内容标签,导致同步失败](https://github.com/lobehub/lobe-chat/issues/1962)
|
||||
|
||||
## 我们的建议
|
||||
|
||||
鉴于以上原因,我们建议用户将 WebRTC 同步功能视为实验性功能,并定期备份重要数据。
|
||||
|
||||
目前我们已经发布了更稳定、更用户友好的服务端数据库同步方案([部署指南](/zh/docs/self-hosting/advanced/server-database)),我们建议用户优先考虑使用服务端数据库同步方案。
|
||||
|
||||
<Callout type={'warning'}>
|
||||
请注意,我们已经在 [PR 3182](https://github.com/lobehub/lobe-chat/pull/3182)
|
||||
中正式宣布归档该同步特性,上述问题将不再考虑进行修复。
|
||||
</Callout>
|
||||
@@ -205,6 +205,13 @@ LobeChat provides a complete authentication service capability when deployed. Th
|
||||
|
||||
### Microsoft Entra ID
|
||||
|
||||
#### `AUTH_MICROSOFT_ENTRA_ID_BASE_URL`
|
||||
|
||||
- Type: Required
|
||||
- Description: - Description: Base URL for Azure login. Use when authenticating against other Microsoft sovereignty clouds like Azure US Government.
|
||||
- Default: `https://login.microsoftonline.com`
|
||||
- Example: `https://login.microsoftonline.us`
|
||||
|
||||
#### `AUTH_AZURE_AD_ID`
|
||||
|
||||
- Type: Required
|
||||
|
||||
@@ -37,13 +37,6 @@ When using the `random` mode, a random API Key will be selected from the availab
|
||||
|
||||
When using the `turn` mode, the API Keys will be retrieved in a polling manner according to the specified order.
|
||||
|
||||
### `NEXT_PUBLIC_BASE_PATH`
|
||||
|
||||
- Type: Optional
|
||||
- Description: Add a `basePath` for LobeChat.
|
||||
- Default: -
|
||||
- Example: `/test`
|
||||
|
||||
### `DEFAULT_AGENT_CONFIG`
|
||||
|
||||
- Type: Optional
|
||||
@@ -152,6 +145,13 @@ For specific content, please refer to the [Feature Flags](/docs/self-hosting/adv
|
||||
- Default: `0`
|
||||
- Example: `1` or `0`
|
||||
|
||||
### `NEXT_PUBLIC_ASSET_PREFIX`
|
||||
|
||||
- Type: Optional
|
||||
- Description: The path access prefix for static resources can be set to the URL for CDN access. For more details, please refer to: [assetPrefix](https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix)
|
||||
- Default: -
|
||||
- Example: `https://cdn.example.com`
|
||||
|
||||
## Plugin Service
|
||||
|
||||
### `PLUGINS_INDEX_URL`
|
||||
|
||||
@@ -34,13 +34,6 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
||||
|
||||
使用 `turn` 模式下,将按照填写的顺序,轮询获取得到 API Key。
|
||||
|
||||
### `NEXT_PUBLIC_BASE_PATH`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:为 LobeChat 添加 `basePath`
|
||||
- 默认值: `-`
|
||||
- 示例: `/test`
|
||||
|
||||
### `DEFAULT_AGENT_CONFIG`
|
||||
|
||||
- 类型:可选
|
||||
@@ -148,6 +141,13 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
||||
- 默认值:`0`
|
||||
- 示例:`1` 或 `0`
|
||||
|
||||
### `NEXT_PUBLIC_ASSET_PREFIX`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:静态资源的路径访问前缀,你可以设置为 CDN 访问的 URL,具体可参考: [assetPrefix](https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix)
|
||||
- 默认值:-
|
||||
- 示例:`https://cdn.example.com`
|
||||
|
||||
## 插件服务
|
||||
|
||||
### `PLUGINS_INDEX_URL`
|
||||
|
||||
@@ -3,6 +3,7 @@ title: LobeChat Model Service Providers - Environment Variables and Configuratio
|
||||
description: >-
|
||||
Learn about the environment variables and configuration settings for various model service providers like OpenAI, Google AI, AWS Bedrock, Ollama, Perplexity AI, Anthropic AI, Mistral AI, Groq AI, OpenRouter AI, and 01.AI.
|
||||
|
||||
|
||||
tags:
|
||||
- Model Service Providers
|
||||
- Environment Variables
|
||||
@@ -646,8 +647,74 @@ If you need to use Azure OpenAI to provide model services, you can refer to the
|
||||
- Type: Optional
|
||||
- Description: Used to control the FAL model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model. Separate multiple entries with commas. The definition syntax follows the same rules as other providers' model lists.
|
||||
- Default: `-`
|
||||
- Example: `-all,+fal-model-1,+fal-model-2=fal-special`
|
||||
- Example: `-all,+fal-ai/flux/schnell,+fal-ai/flux-pro/kontext=FLUX.1 Kontext [pro]`
|
||||
|
||||
The above example disables all models first, then enables `fal-model-1` and `fal-model-2` (displayed as `fal-special`).
|
||||
The above example disables all models first, then enables `fal-ai/flux/schnell` and `fal-ai/flux-pro/kontext` (displayed as `FLUX.1 Kontext [pro]`).
|
||||
|
||||
## BFL
|
||||
|
||||
### `ENABLED_BFL`
|
||||
|
||||
- Type: Optional
|
||||
- Description: Enables BFL as a model provider by default. Set to `0` to disable the BFL service.
|
||||
- Default: `1`
|
||||
- Example: `0`
|
||||
|
||||
### `BFL_API_KEY`
|
||||
|
||||
- Type: Required
|
||||
- Description: This is the API key you applied for in the BFL service.
|
||||
- Default: -
|
||||
- Example: `12345678-1234-1234-1234-123456789abc`
|
||||
|
||||
### `BFL_MODEL_LIST`
|
||||
|
||||
- Type: Optional
|
||||
- Description: Used to control the BFL model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model. Separate multiple entries with commas. The definition syntax follows the same rules as other providers' model lists.
|
||||
- Default: `-`
|
||||
- Example: `-all,+flux-pro-1.1,+flux-kontext-pro=FLUX.1 Kontext [pro]`
|
||||
|
||||
The above example disables all models first, then enables `flux-pro-1.1` and `flux-kontext-pro` (displayed as `FLUX.1 Kontext [pro]`).
|
||||
|
||||
## NewAPI
|
||||
|
||||
### `NEWAPI_API_KEY`
|
||||
|
||||
- Type: Optional
|
||||
- Description: This is the API key for your NewAPI service instance. NewAPI is a multi-provider model aggregation service that provides unified access to various AI model APIs.
|
||||
- Default: -
|
||||
- Example: `sk-xxxxxx...xxxxxx`
|
||||
|
||||
### `NEWAPI_PROXY_URL`
|
||||
|
||||
- Type: Optional
|
||||
- Description: The base URL for your NewAPI server instance. This should point to your deployed NewAPI service endpoint.
|
||||
- Default: -
|
||||
- Example: `https://your-newapi-server.com/`
|
||||
|
||||
NewAPI is a multi-provider model aggregation service that supports automatic model routing based on provider detection. It offers cost management features and provides a single endpoint for accessing models from multiple providers including OpenAI, Anthropic, Google, and more. Learn more about NewAPI at [https://github.com/Calcium-Ion/new-api](https://github.com/Calcium-Ion/new-api).
|
||||
|
||||
## Vercel AI Gateway
|
||||
|
||||
### `ENABLED_VERCELAIGATEWAY`
|
||||
|
||||
- Type: Optional
|
||||
- Description: Enables Vercel AI Gateway as a model provider by default. Set to `0` to disable the Vercel AI Gateway service.
|
||||
- Default: `1`
|
||||
- Example: `0`
|
||||
|
||||
### `VERCELAIGATEWAY_API_KEY`
|
||||
|
||||
- Type: Required
|
||||
- Description: This is the API key you applied for in the Vercel AI Gateway service.
|
||||
- Default: -
|
||||
- Example: `vck_xxxxxx...xxxxxx`
|
||||
|
||||
### `VERCELAIGATEWAY_MODEL_LIST`
|
||||
|
||||
- Type: Optional
|
||||
- Description: Used to control the Vercel AI Gateway model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model. Separate multiple entries with commas. The definition syntax follows the same rules as other providers' model lists.
|
||||
- Default: `-`
|
||||
- Example: `-all,+vercel-model-1,+vercel-model-2=vercel-special`
|
||||
|
||||
[model-list]: /docs/self-hosting/advanced/model-list
|
||||
|
||||
@@ -645,8 +645,79 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,
|
||||
- 类型:可选
|
||||
- 描述:用来控制 FAL 模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。模型定义语法规则与其他 provider 保持一致。
|
||||
- 默认值:`-`
|
||||
- 示例:`-all,+fal-model-1,+fal-model-2=fal-special`
|
||||
- 示例:`-all,+fal-ai/flux/schnell,+fal-ai/flux-pro/kontext=FLUX.1 Kontext [pro]`
|
||||
|
||||
上述示例表示先禁用所有模型,再启用 `fal-model-1` 和 `fal-model-2`(显示名为 `fal-special`)。
|
||||
上述示例表示先禁用所有模型,再启用 `fal-ai/flux/schnell` 和 `fal-ai/flux-pro/kontext`(显示名为 `FLUX.1 Kontext [pro]`)。
|
||||
|
||||
## BFL
|
||||
|
||||
### `ENABLED_BFL`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:默认启用 BFL 作为模型供应商,当设为 0 时关闭 BFL 服务
|
||||
- 默认值:`1`
|
||||
- 示例:`0`
|
||||
|
||||
### `BFL_API_KEY`
|
||||
|
||||
- 类型:必选
|
||||
- 描述:这是你在 BFL 服务中申请的 API 密钥
|
||||
- 默认值:-
|
||||
- 示例:`12345678-1234-1234-1234-123456789abc`
|
||||
|
||||
### `BFL_MODEL_LIST`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:用来控制 BFL 模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。模型定义语法规则与其他 provider 保持一致。
|
||||
- 默认值:`-`
|
||||
- 示例:`-all,+flux-pro-1.1,+flux-kontext-pro=FLUX.1 Kontext [pro]`
|
||||
|
||||
上述示例表示先禁用所有模型,再启用 `flux-pro-1.1` 和 `flux-kontext-pro`(显示名为 `FLUX.1 Kontext [pro]`)。
|
||||
|
||||
## NewAPI
|
||||
|
||||
### `NEWAPI_API_KEY`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:这是你的 NewAPI 服务实例的 API 密钥。NewAPI 是一个多供应商模型聚合服务,提供对各种 AI 模型 API 的统一访问。
|
||||
- 默认值:-
|
||||
- 示例:`sk-xxxxxx...xxxxxx`
|
||||
|
||||
### `NEWAPI_PROXY_URL`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:你的 NewAPI 服务器实例的基础 URL。这应该指向你部署的 NewAPI 服务端点。
|
||||
- 默认值:-
|
||||
- 示例:`https://your-newapi-server.com`
|
||||
|
||||
<Callout type={'info'}>
|
||||
NewAPI
|
||||
是一个多供应商模型聚合服务,支持基于供应商检测的自动模型路由。它提供成本管理功能,并为访问包括
|
||||
OpenAI、Anthropic、Google 等多个供应商的模型提供单一端点。了解更多关于 NewAPI 的信息请访问
|
||||
[https://github.com/Calcium-Ion/new-api](https://github.com/Calcium-Ion/new-api)。
|
||||
</Callout>
|
||||
|
||||
## Vercel AI Gateway
|
||||
|
||||
### `ENABLED_VERCELAIGATEWAY`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:默认启用 Vercel AI Gateway 作为模型供应商,当设为 0 时关闭 Vercel AI Gateway 服务
|
||||
- 默认值:`1`
|
||||
- 示例:`0`
|
||||
|
||||
### `VERCELAIGATEWAY_API_KEY`
|
||||
|
||||
- 类型:必选
|
||||
- 描述:这是你在 Vercel AI Gateway 服务中申请的 API 密钥
|
||||
- 默认值:-
|
||||
- 示例:`vck_xxxxxx...xxxxxx`
|
||||
|
||||
### `VERCELAIGATEWAY_MODEL_LIST`
|
||||
|
||||
- 类型:可选
|
||||
- 描述:用来控制 Vercel AI Gateway 模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。模型定义语法规则与其他 provider 保持一致。
|
||||
- 默认值:`-`
|
||||
- 示例:`-all,+vercel-model-1,+vercel-model-2=vercel-special`
|
||||
|
||||
[model-list]: /zh/docs/self-hosting/advanced/model-list
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user