mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 05:19:51 +00:00
feat: context box
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { authUser } from '@/service/utils/auth';
|
||||
import { connectToDatabase, TrainingData, User, promotionRecord, Chat } from '@/service/mongo';
|
||||
import { PRICE_SCALE } from '@/constants/common';
|
||||
import { connectToDatabase, Chat } from '@/service/mongo';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
|
@@ -1,18 +1,18 @@
|
||||
import React, { useRef } from 'react';
|
||||
import { Box, Flex, useOutsideClick } from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
import { Box, Flex } from '@chakra-ui/react';
|
||||
import { ModuleTemplates } from '@/constants/flow/ModuleTemplate';
|
||||
import type { FlowModuleItemType } from '@/types/app';
|
||||
import { FlowModuleTemplateType } from '@/types/flow';
|
||||
import type { XYPosition } from 'reactflow';
|
||||
import { useGlobalStore } from '@/store/global';
|
||||
import Avatar from '@/components/Avatar';
|
||||
|
||||
const ModuleStoreList = ({
|
||||
const ModuleTemplateList = ({
|
||||
isOpen,
|
||||
onAddNode,
|
||||
onClose
|
||||
}: {
|
||||
isOpen: boolean;
|
||||
onAddNode: (e: { template: FlowModuleItemType; position: XYPosition }) => void;
|
||||
onAddNode: (e: { template: FlowModuleTemplateType; position: XYPosition }) => void;
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
const { isPc } = useGlobalStore();
|
||||
@@ -92,4 +92,4 @@ const ModuleStoreList = ({
|
||||
);
|
||||
};
|
||||
|
||||
export default ModuleStoreList;
|
||||
export default ModuleTemplateList;
|
||||
|
@@ -154,7 +154,7 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
|
||||
[setEdges, setNodes]
|
||||
);
|
||||
const onAddNode = useCallback(
|
||||
({ template, position }: { template: FlowModuleItemType; position: XYPosition }) => {
|
||||
({ template, position }: { template: FlowModuleTemplateType; position: XYPosition }) => {
|
||||
if (!reactFlowWrapper.current) return;
|
||||
const reactFlowBounds = reactFlowWrapper.current.getBoundingClientRect();
|
||||
const mouseX = (position.x - reactFlowBounds.left - x) / zoom - 100;
|
||||
|
@@ -115,7 +115,6 @@ const Share = ({ appId }: { appId: string }) => {
|
||||
<Thead>
|
||||
<Tr>
|
||||
<Th>名称</Th>
|
||||
<Th>最大上下文</Th>
|
||||
<Th>金额消耗</Th>
|
||||
<Th>最后使用时间</Th>
|
||||
<Th>操作</Th>
|
||||
@@ -125,7 +124,6 @@ const Share = ({ appId }: { appId: string }) => {
|
||||
{shareChatList.map((item) => (
|
||||
<Tr key={item._id}>
|
||||
<Td>{item.name}</Td>
|
||||
<Td>{item.maxContext}</Td>
|
||||
<Td>{formatPrice(item.total)}元</Td>
|
||||
<Td>{item.lastTime ? formatTimeToChatTime(item.lastTime) : '未使用'}</Td>
|
||||
<Td>
|
||||
@@ -197,42 +195,6 @@ const Share = ({ appId }: { appId: string }) => {
|
||||
/>
|
||||
</Flex>
|
||||
</FormControl>
|
||||
<FormControl mt={9}>
|
||||
<Flex alignItems={'center'}>
|
||||
<Box flex={'0 0 120px'} w={0}>
|
||||
最长上下文(组)
|
||||
</Box>
|
||||
<Slider
|
||||
aria-label="slider-ex-1"
|
||||
min={1}
|
||||
max={20}
|
||||
step={1}
|
||||
value={getShareChatValues('maxContext')}
|
||||
onChange={(e) => {
|
||||
setShareChatValues('maxContext', e);
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
>
|
||||
<SliderMark
|
||||
value={getShareChatValues('maxContext')}
|
||||
textAlign="center"
|
||||
bg="myBlue.600"
|
||||
color="white"
|
||||
w={'18px'}
|
||||
h={'18px'}
|
||||
borderRadius={'100px'}
|
||||
fontSize={'xs'}
|
||||
transform={'translate(-50%, -200%)'}
|
||||
>
|
||||
{getShareChatValues('maxContext')}
|
||||
</SliderMark>
|
||||
<SliderTrack>
|
||||
<SliderFilledTrack bg={'myBlue.700'} />
|
||||
</SliderTrack>
|
||||
<SliderThumb />
|
||||
</Slider>
|
||||
</Flex>
|
||||
</FormControl>
|
||||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
|
@@ -110,10 +110,10 @@ const ChatHistorySlider = ({
|
||||
|
||||
{/* chat history */}
|
||||
<Box flex={'1 0 0'} h={0} px={[2, 5]} overflow={'overlay'}>
|
||||
{concatHistory.map((item) => (
|
||||
{concatHistory.map((item, i) => (
|
||||
<Flex
|
||||
position={'relative'}
|
||||
key={item.id}
|
||||
key={item.id || `${i}`}
|
||||
alignItems={'center'}
|
||||
py={3}
|
||||
px={4}
|
||||
|
@@ -249,7 +249,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
||||
appName={chatData.app.name}
|
||||
appAvatar={chatData.app.avatar}
|
||||
activeChatId={chatId}
|
||||
history={history.map((item) => ({
|
||||
history={history.map((item, i) => ({
|
||||
id: item.chatId,
|
||||
title: item.title,
|
||||
customTitle: item.customTitle,
|
||||
|
Reference in New Issue
Block a user