Commit Graph

54 Commits

Author SHA1 Message Date
akumatus eb49ffaedb feat(core): support fork session without latestMessageId (#12587)
Close [AI-86](https://linear.app/affine-design/issue/AI-86)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Improved chat session forking to allow creating a fork without specifying the latest message, enabling more flexible session management.

- **Bug Fixes**
  - Forking a chat session with an invalid latest message ID now correctly returns an error.

- **Tests**
  - Added and updated test cases to cover session forking with missing or invalid latest message IDs, ensuring robust behavior in these scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 07:34:23 +00:00
darkskygit 3c0fa429c5 feat(server): switch i2i to gpt (#12238)
fix AI-14
fix AI-17
fix AI-39
fix AI-112

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Expanded and reorganized prompt options for text and image actions, adding new prompts for image generation, style conversions, upscaling, background removal, and sticker creation.
  - Enhanced image editing capabilities with direct support for image attachments in prompts.

- **Improvements**
  - Updated prompt names and descriptions to be more user-friendly and descriptive.
  - Simplified and clarified prompt selection and image processing workflows with improved default behaviors.
  - Better organization of prompts through clear grouping and categorization.

- **Bug Fixes**
  - Improved validation and handling of image attachments during editing requests.

- **Refactor**
  - Internal code restructuring of prompts and provider logic for clarity and maintainability without affecting user workflows.
  - Refined message handling and content merging logic to ensure consistent prompt processing.
  - Adjusted image attachment rendering logic for improved display consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 11:36:47 +00:00
darkskygit b388f92c96 feat(server): refactor provider interface (#11665)
fix AI-4
fix AI-18

better provider/model choose to allow fallback to similar models (e.g., self-hosted) when the provider is not fully configured
split functions of different output types
2025-05-22 06:28:20 +00:00
akumatus fcc9b31da9 feat(core): add get session graphql api (#12237)
Close [AI-116](https://linear.app/affine-design/issue/AI-116)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added the ability to retrieve detailed information for a specific Copilot session by its ID, including model metadata and optional models, via the user interface and API.
  - Session data now includes additional fields such as the model used and a list of optional models.
  - Enhanced GraphQL queries and UI components to support fetching and displaying these new session details.

- **Improvements**
  - Session lists now provide richer information, including model details, for each session.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-15 04:55:50 +00:00
akumatus 74452a0aab feat(core): add optionalModels field in AiPrompt and support the front-end modelId param (#12224)
Close [AI-116](https://linear.app/affine-design/issue/AI-116)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added support for specifying alternative AI models in chat prompts, enabling users to select from multiple available models.
  - Expanded AI model options with new additions: 'gpt-4.1', 'o3', and 'claude-3-5-sonnet-20241022'.

- **Enhancements**
  - Users can now optionally choose a specific AI model during chat interactions.
  - Prompts and chat sessions reflect and support selection of alternative models where applicable.

- **Bug Fixes**
  - Improved handling of prompt configuration defaults for better reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-13 09:17:34 +00:00
darkskygit de8c65f4e6 fix(server): empty mimetype attachments fallback (#11869) 2025-04-22 15:36:35 +00:00
darkskygit b4c643e8bc chore(server): improve gql types (#11441) 2025-04-03 07:30:51 +00:00
forehalo 0ea38680fa refactor(server): config system (#11081) 2025-03-27 12:32:28 +00:00
akumatus daccb2c865 feat(core): add ai file context api (#10842)
Close [BS-2349](https://linear.app/affine-design/issue/BS-2349).

### What Changed?
- Add file context graphql apis
- Pass matched file chunks to LLM

[录屏2025-02-19 23.27.47.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/8e8a98ca-6959-4bb6-9759-b51d97cede49.mov" />](https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/8e8a98ca-6959-4bb6-9759-b51d97cede49.mov)
2025-03-14 04:29:54 +00:00
darkskygit 10605b3793 fix(server): nullable value for parent id (#10725) 2025-03-12 03:53:33 +00:00
darkskygit 91adc533a8 fix(server): reuse params in retry (#10653)
fix BS-2484
2025-03-06 07:32:26 +00:00
darkskygit fbb6df3da8 chore(server): return parent id of sessions (#10638) 2025-03-05 14:03:36 +00:00
darkskygit 985906aa13 feat(server): copilot session prompt query (#10479) 2025-02-27 11:25:52 +00:00
darkskygit 13f1859cdf feat: allow retry with new message (#10307)
fix AF-1630
2025-02-20 06:07:53 +00:00
akumatus 1bf1832211 refactor(core): get copilot sessions api (#10168)
Fix issue [BS-2575](https://linear.app/affine-design/issue/BS-2575).

### What Changed?
- Refactor `getCopilotSessions` api.
  - Add `docId` parameter.
  - Add `action` parameter.
2025-02-14 06:57:58 +00:00
akumatus 79d5f55471 feat(core): move context docs to user prompt (#10162)
Fix issue [BS-2522](https://linear.app/affine-design/issue/BS-2522).

### Why make this change?
If the user data contains illegal content, carrying the user data in the system prompt will run the risk of having the account banned.

### What Changed?
- Move the `Context Documents` to the user prompt.
- Add `withPrompt` in `QueryChatHistoriesInput` options.
- Get chat histories without prompt messages.
- Omit document context when saving messages to the `aiSessionMessage` db.
2025-02-13 12:08:13 +00:00
forehalo 7826e2b7c8 refactor(server): use feature model (#9932) 2025-02-05 10:27:26 +00:00
akumatus 95cf2e047f feat(core): cite source documents in the AI answer (#9863)
Support issue [BS-2424](https://linear.app/affine-design/issue/BS-2424).

### What changed?
- Add relevant document prompt templates.
- Add citation rules in system prompts.
- Change message `params` type to `Record<string, any>`
- Add unit test.

<div class='graphite__hidden'>
          <div>🎥 Video uploaded on Graphite:</div>
            <a href="https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/ec24e664-039e-4fab-bd26-b3312f011daf.mov">
              <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/ec24e664-039e-4fab-bd26-b3312f011daf.mov">
            </a>
          </div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/ec24e664-039e-4fab-bd26-b3312f011daf.mov">录屏2025-01-23 10.40.38.mov</video>
2025-01-24 04:04:01 +00:00
darkskygit 755cebfb18 chore(server): not allow to update action's prompt (#9615) 2025-01-09 10:18:53 +00:00
akumatus 58ce86533e feat(core): support ai network search (#9357)
### What Changed?
- Add `PerplexityProvider` in backend.
- Update session prompt name if user toggle network search mode in chat panel.
- Add experimental flag for AI network search feature.
- Add unit tests and e2e tests.

Search results are streamed and appear word for word:

<div class='graphite__hidden'>
          <div>🎥 Video uploaded on Graphite:</div>
            <a href="https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/56f6ec7b-4b21-405f-9612-43e083f6fb84.mov">
              <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/56f6ec7b-4b21-405f-9612-43e083f6fb84.mov">
            </a>
          </div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/56f6ec7b-4b21-405f-9612-43e083f6fb84.mov">录屏2024-12-27 18.58.40.mov</video>

Click the little globe icon to manually turn on/off Internet search:
<div class='graphite__hidden'>
          <div>🎥 Video uploaded on Graphite:</div>
            <a href="https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/778f1406-bf29-498e-a90d-7dad813392d1.mov">
              <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/778f1406-bf29-498e-a90d-7dad813392d1.mov">
            </a>
          </div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/778f1406-bf29-498e-a90d-7dad813392d1.mov">录屏2024-12-27 19.01.16.mov</video>

When there is an image, it will automatically switch to the openai model:

<div class='graphite__hidden'>
          <div>🎥 Video uploaded on Graphite:</div>
            <a href="https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/56431d8e-75e1-4d84-ab4a-b6636042cc6a.mov">
              <img src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/56431d8e-75e1-4d84-ab4a-b6636042cc6a.mov">
            </a>
          </div>
<video src="https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/56431d8e-75e1-4d84-ab4a-b6636042cc6a.mov">录屏2024-12-27 19.02.13.mov</video>
2025-01-09 04:00:59 +00:00
forehalo 4c23991047 chore: rename fundamentals to base (#9119) 2024-12-13 06:27:13 +00:00
darkskygit fa554b1054 feat: add copilot metrics (#8455)
fix CLOUD-73
2024-10-18 03:30:02 +00:00
DarkSky 075cedabf7 fix: message attachment merge (#8498) 2024-10-16 12:57:53 +08:00
darkskygit 5872b884a5 fix: increase image limit of copilot (#7756)
fix AF-1080 AF-1154
2024-08-06 09:15:40 +00:00
darkskygit 73a6723d15 fix: use correct user id in forked session (#7710) 2024-08-05 09:03:11 +00:00
darkskygit 386d766597 fix: forked session query condition (#7568) 2024-07-22 12:28:05 +00:00
DarkSky dcb9d75db7 feat: allow sort and filter forked session (#7519) 2024-07-18 11:08:47 +08:00
darkskygit bf6c9a5955 feat: add prompt level config (#7445) 2024-07-08 08:11:22 +00:00
darkskygit e8285289fe feat: improve histories query for forked session (#7414) 2024-07-03 04:49:19 +00:00
darkskygit 61870c04d0 feat: fork session support (#7367) 2024-07-03 03:10:09 +00:00
liuyi 54fc1197ad feat(server): introduce user friendly server errors (#7111) 2024-06-17 11:30:58 +08:00
darkskygit a5f9bfdda9 fix: gql result check for clean history (#7154) 2024-06-05 07:49:40 +00:00
darkskygit 937b8bf166 feat: history cleanup (#7007)
fix AFF-1069
2024-05-24 08:00:05 +00:00
darkskygit f8fee55b3d fix: combine message correctly (#7038) 2024-05-23 06:16:31 +00:00
Brooooooklyn c7ddd679fd feat(server): use native tokenizer impl (#6960)
### Benchmark

`yarn workspace @affine/server-native bench`

```
┌─────────┬────────────┬─────────┬────────────────────┬──────────┬─────────┐
│ (index) │ Task Name  │ ops/sec │ Average Time (ns)  │ Margin   │ Samples │
├─────────┼────────────┼─────────┼────────────────────┼──────────┼─────────┤
│ 0       │ 'tiktoken' │ '5'     │ 176932518.76000002 │ '±4.71%' │ 100     │
│ 1       │ 'native'   │ '16'    │ 61041597.51000003  │ '±0.60%' │ 100     │
└─────────┴────────────┴─────────┴────────────────────┴──────────┴─────────┘
```
2024-05-16 07:55:10 +00:00
darkskygit 0076359d6a feat: add retry support for copilot (#6947) 2024-05-15 11:02:37 +00:00
darkskygit 13f40f435d feat: improve query performence (#6764) 2024-05-06 09:12:04 +00:00
pengx17 eb7904bf62 fix(core): prompt message tunning (#6747)
fix AFF-1003
2024-04-30 13:18:20 +08:00
darkskygit 850bbee629 test: copilot unit & e2e test (#6649)
fix CLOUD-31
2024-04-26 09:43:35 +00:00
darkskygit a0c219e036 feat: use default params if not provided (#6701) 2024-04-25 10:59:46 +00:00
darkskygit 01a0f60d03 fix: history attachment query (#6670) 2024-04-23 03:34:59 +00:00
forehalo 94de6f5853 fix(server): always return created timestamp of chat messages (#6658) 2024-04-22 08:39:42 +00:00
darkskygit 657a5250ad feat: update chat prompt (#6639)
fix AFF-878
fix AFF-852 (maybe)
2024-04-19 12:34:02 +00:00
darkskygit 97669acb40 chore: enable ai feature in dev (#6618) 2024-04-19 08:12:53 +00:00
forehalo d9e6561762 feat(server): add created timestamp to history (#6607) 2024-04-18 07:06:47 +00:00
DarkSky ccb3bed91e feat: add blob upload support for copilot (#6584) 2024-04-17 14:05:38 +00:00
darkskygit 1b0864eb60 feat: check quota correctly (#6561) 2024-04-16 09:41:48 +00:00
darkskygit 2336638996 fix: cannot query chat history (#6539) 2024-04-12 12:16:43 +00:00
darkskygit e77475aca5 feat: detailed copilot histories (#6523) 2024-04-12 08:39:32 +00:00
DarkSky db1206dbd5 fix: re-create session should skip rewrite messages (#6513) 2024-04-11 12:22:45 +08:00