v4.6 -1 (#459)
This commit is contained in:
@@ -1,39 +1,17 @@
|
||||
import { formatPrice } from '@fastgpt/global/common/bill/tools';
|
||||
import type { BillSchema } from '@/types/common/bill';
|
||||
import type { UserBillType } from '@/types/user';
|
||||
import { ChatItemType } from '@/types/chat';
|
||||
import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constant';
|
||||
import { ChatRoleEnum } from '@/constants/chat';
|
||||
import type { MessageItemType } from '@/types/core/chat/type';
|
||||
import type { ChatItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import type { ChatMessageItemType } from '@fastgpt/global/core/ai/type.d';
|
||||
import type { ModuleItemType, FlowModuleItemType } from '@fastgpt/global/core/module/type.d';
|
||||
import type { Edge, Node } from 'reactflow';
|
||||
import { connectionLineStyle } from '@/constants/flow';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import { EmptyModule, ModuleTemplatesFlat } from '@/constants/flow/ModuleTemplate';
|
||||
import { adaptRole_Message2Chat } from './common/adapt/message';
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 6);
|
||||
|
||||
export const adaptBill = (bill: BillSchema): UserBillType => {
|
||||
return {
|
||||
id: bill._id,
|
||||
source: bill.source,
|
||||
time: bill.time,
|
||||
total: formatPrice(bill.total),
|
||||
appName: bill.appName,
|
||||
list: bill.list
|
||||
};
|
||||
};
|
||||
|
||||
export const gptMessage2ChatType = (messages: MessageItemType[]): ChatItemType[] => {
|
||||
const roleMap = {
|
||||
[ChatCompletionRequestMessageRoleEnum.Assistant]: ChatRoleEnum.AI,
|
||||
[ChatCompletionRequestMessageRoleEnum.User]: ChatRoleEnum.Human,
|
||||
[ChatCompletionRequestMessageRoleEnum.System]: ChatRoleEnum.System,
|
||||
[ChatCompletionRequestMessageRoleEnum.Function]: ChatRoleEnum.Human
|
||||
};
|
||||
|
||||
export const gptMessage2ChatType = (messages: ChatMessageItemType[]): ChatItemType[] => {
|
||||
return messages.map((item) => ({
|
||||
dataId: item.dataId,
|
||||
obj: roleMap[item.role],
|
||||
obj: adaptRole_Message2Chat(item.role),
|
||||
value: item.content || ''
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user