Не подтверждена Коммит 7c5a259e создал по автору pengx17's avatar pengx17
Просмотр файлов

fix(core): update prompts (#6738)

Update prompts:

When sending a message to openai, we actually send two messages.
There are two issues here:

1. the role in the first message shall be user or system
2. the content in the first message is not being interpolated at all.

```
[
  {
    role: "assistant",
    createdAt: "2024-04-27T06:30:34.820Z",
    params: {
      language: "French",
    },
    content: "You are a translation expert, please translate the following content into French, and only perform the translation action, keeping the translated content in the same format as the original content:\n\n          \"\"\"\"\n\n          \n\n          \"\"\"\"",
  },
  {
    role: "user",
    content: "Basic things you should know:",
    attachments: undefined,
    params: {
      language: "French",
    },
    createdAt: "2024-04-29T09:42:11.466Z",
  },
]
```

In this PR I removed `content` from prompts and let open ai use the second message (user) as the input.
владелец 1d3c477c
import { PrismaClient } from '@prisma/client';
import { refreshPrompts } from './utils/prompts';
export class UpdatePrompts1714386922280 {
// do the migration
static async up(db: PrismaClient) {
await refreshPrompts(db);
}
// revert the migration
static async down(_db: PrismaClient) {}
}
Это отличие свёрнуто
...@@ -120,6 +120,9 @@ export function setupAIProvider() { ...@@ -120,6 +120,9 @@ export function setupAIProvider() {
provideAction('changeTone', options => { provideAction('changeTone', options => {
return textToText({ return textToText({
...options, ...options,
params: {
tone: options.tone,
},
content: options.input, content: options.input,
promptName: 'Change tone to', promptName: 'Change tone to',
}); });
...@@ -256,6 +259,10 @@ export function setupAIProvider() { ...@@ -256,6 +259,10 @@ export function setupAIProvider() {
provideAction('expandMindmap', options => { provideAction('expandMindmap', options => {
return textToText({ return textToText({
...options, ...options,
params: {
mindmap: options.mindmap,
node: options.input,
},
content: options.input, content: options.input,
promptName: 'Expand mind map', promptName: 'Expand mind map',
}); });
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать