mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-16 08:01:18 +00:00
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -22,6 +22,6 @@
|
||||
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
|
||||
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key",
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ weight: 816
|
||||
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**。
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/admin/initv48 8' \
|
||||
curl --location --request POST 'https://{{host}}/api/admin/initv488' \
|
||||
--header 'rootkey: {{rootkey}}' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
@@ -40,11 +40,10 @@ curl --location --request POST 'https://{{host}}/api/admin/initv48 8' \
|
||||
6. 优化 - 移动端快速切换应用交互。
|
||||
7. 优化 - 节点图标。
|
||||
8. 优化 - 对话框引用增加额外复制案件,便于复制。增加引用内容折叠。
|
||||
9. 优化 - 对话框底部增加复制,简便复制交互,无需滚动到消息开头。
|
||||
10. 优化 - OpenAI sdk 升级,并自定义了 whisper 模型接口(未仔细查看 sdk 实现,但 sdk 中 whisper 接口,似乎无法适配一般 fastapi 接口)
|
||||
11. 修复 - Permission 表声明问题。
|
||||
12. 修复 - 并行执行节点,运行时间未正确记录。
|
||||
13. 修复 - 运行详情未正确展示嵌套节点信息。
|
||||
14. 修复 - 简易模式,首次进入,无法正确获取知识库配置。
|
||||
15. 修复 - Log debug level 配置无效。
|
||||
16. 修复 - 插件独立运行时,会将插件输入的值进行变量替换,可能导致后续节点变量异常。
|
||||
9. 优化 - OpenAI sdk 升级,并自定义了 whisper 模型接口(未仔细查看 sdk 实现,但 sdk 中 whisper 接口,似乎无法适配一般 fastapi 接口)
|
||||
10. 修复 - Permission 表声明问题。
|
||||
11. 修复 - 并行执行节点,运行时间未正确记录。
|
||||
12. 修复 - 运行详情未正确展示嵌套节点信息。
|
||||
13. 修复 - 简易模式,首次进入,无法正确获取知识库配置。
|
||||
14. 修复 - Log debug level 配置无效。
|
||||
15. 修复 - 插件独立运行时,会将插件输入的值进行变量替换,可能导致后续节点变量异常。
|
@@ -163,6 +163,7 @@ export const readFileContentFromMongo = async ({
|
||||
|
||||
const encoding = file?.metadata?.encoding || detectFileEncoding(fileBuffers);
|
||||
|
||||
// Get raw text
|
||||
const { rawText } = await readRawContentByFileBuffer({
|
||||
extension,
|
||||
isQAImport,
|
||||
|
@@ -2,9 +2,10 @@ import { UploadImgProps } from '@fastgpt/global/common/file/api';
|
||||
import { imageBaseUrl } from '@fastgpt/global/common/file/image/constants';
|
||||
import { MongoImage } from './schema';
|
||||
import { ClientSession } from '../../../common/mongo';
|
||||
import { guessBase64ImageType } from '../utils';
|
||||
|
||||
export function getMongoImgUrl(id: string) {
|
||||
return `${imageBaseUrl}${id}`;
|
||||
export function getMongoImgUrl(id: string, extension: string) {
|
||||
return `${imageBaseUrl}${id}.${extension}`;
|
||||
}
|
||||
|
||||
export const maxImgSize = 1024 * 1024 * 12;
|
||||
@@ -23,9 +24,10 @@ export async function uploadMongoImg({
|
||||
return Promise.reject('Image too large');
|
||||
}
|
||||
|
||||
const [base64Mime, base64Data] = base64Img.split(',')
|
||||
const mime = `image/${base64Mime.match(base64MimeRegex)?.[1] ?? 'jpeg'}`
|
||||
const [base64Mime, base64Data] = base64Img.split(',');
|
||||
const mime = `image/${base64Mime.match(base64MimeRegex)?.[1] ?? 'image/jpeg'}`;
|
||||
const binary = Buffer.from(base64Data, 'base64');
|
||||
const extension = mime.split('/')[1];
|
||||
|
||||
const { _id } = await MongoImage.create({
|
||||
type,
|
||||
@@ -36,15 +38,20 @@ export async function uploadMongoImg({
|
||||
shareId
|
||||
});
|
||||
|
||||
return getMongoImgUrl(String(_id));
|
||||
return getMongoImgUrl(String(_id), extension);
|
||||
}
|
||||
|
||||
export async function readMongoImg({ id }: { id: string }) {
|
||||
const data = await MongoImage.findById(id);
|
||||
const formatId = id.replace(/\.[^/.]+$/, '');
|
||||
|
||||
const data = await MongoImage.findById(formatId);
|
||||
if (!data) {
|
||||
return Promise.reject('Image not found');
|
||||
}
|
||||
return data;
|
||||
return {
|
||||
binary: data.binary,
|
||||
mime: data.metadata?.mime ?? guessBase64ImageType(data.binary.toString('base64'))
|
||||
};
|
||||
}
|
||||
|
||||
export async function delImgByRelatedId({
|
||||
|
@@ -8,7 +8,8 @@ import fs from 'fs';
|
||||
import { detectFileEncoding } from '@fastgpt/global/common/file/tools';
|
||||
import type { ReadFileResponse } from '../../../worker/readFile/type';
|
||||
|
||||
export const initMarkdownText = ({
|
||||
// match md img text and upload to db
|
||||
export const matchMdImgTextAndUpload = ({
|
||||
teamId,
|
||||
md,
|
||||
metadata
|
||||
@@ -79,7 +80,7 @@ export const readRawContentByFileBuffer = async ({
|
||||
|
||||
// markdown data format
|
||||
if (['md', 'html', 'docx'].includes(extension)) {
|
||||
rawText = await initMarkdownText({
|
||||
rawText = await matchMdImgTextAndUpload({
|
||||
teamId: teamId,
|
||||
md: rawText,
|
||||
metadata: metadata
|
||||
|
@@ -46,12 +46,11 @@ export async function connectMongo(): Promise<Mongoose> {
|
||||
});
|
||||
|
||||
console.log('mongo connected');
|
||||
return connectionMongo;
|
||||
} catch (error) {
|
||||
addLog.error('mongo connect error', error);
|
||||
await connectionMongo.disconnect();
|
||||
await delay(1000);
|
||||
connectMongo();
|
||||
return connectMongo();
|
||||
}
|
||||
|
||||
return connectionMongo;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { connectionMongo, getMongoModel, type Model } from '../../common/mongo';
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
import { connectionMongo, getMongoModel } from '../../common/mongo';
|
||||
const { Schema } = connectionMongo;
|
||||
import { ChatSchema as ChatType } from '@fastgpt/global/core/chat/type.d';
|
||||
import { ChatSourceMap } from '@fastgpt/global/core/chat/constants';
|
||||
import {
|
||||
|
@@ -36,6 +36,7 @@ export const iconPaths = {
|
||||
'common/leftArrowLight': () => import('./icons/common/leftArrowLight.svg'),
|
||||
'common/linkBlue': () => import('./icons/common/linkBlue.svg'),
|
||||
'common/loading': () => import('./icons/common/loading.svg'),
|
||||
'common/logLight': () => import('./icons/common/logLight.svg'),
|
||||
'common/navbar/pluginFill': () => import('./icons/common/navbar/pluginFill.svg'),
|
||||
'common/navbar/pluginLight': () => import('./icons/common/navbar/pluginLight.svg'),
|
||||
'common/openai': () => import('./icons/common/openai.svg'),
|
||||
|
@@ -0,0 +1 @@
|
||||
<svg t="1721963050324" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4271" width="200" height="200"><path d="M269.844659 81.4308h44.821057v166.626082h-44.821057zM677.140966 491.719232c52.335426 0 102.092273 19.937769 140.105639 56.13883 38.126482 36.31053 60.461599 85.284073 62.891788 137.900467 2.5056 54.276658-16.27424 106.280032-52.881549 146.431672-36.60731 40.15164-86.65972 63.643469-140.936379 66.150285-3.180653 0.147174-6.401444 0.221369-9.576016 0.221369-52.341508 0-102.102004-19.936552-140.114153-56.136398-38.126482-36.309314-60.461599-85.284073-62.891789-137.902899-2.5056-54.276658 16.27424-106.280032 52.88155-146.431672 36.60731-40.15164 86.65972-63.643469 140.936379-66.149069a208.122961 208.122961 0 0 1 9.576016-0.221369h0.008514m-0.00973-44.822274c-3.859355 0-7.746684 0.088791-11.642528 0.268805-136.951744 6.3236-242.847422 122.470346-236.525038 259.422091 6.143586 133.0559 115.942406 236.793842 247.779562 236.793842 3.859355 0 7.747901-0.088791 11.642529-0.268804 136.951744-6.322384 242.847422-122.470346 236.525037-259.422091-6.143586-133.057117-115.942406-236.798708-247.779562-236.793843z" fill="#4E4D4D" p-id="4272"></path><path d="M490.264524 891.110734a272.361206 272.361206 0 0 1-32.682275-37.369937H180.453104c-20.912034 0-37.927007-17.013757-37.927007-37.92579v-590.263526c0-20.912034 17.013757-37.927007 37.927007-37.927007H732.799354c20.912034 0 37.925791 17.013757 37.925791 37.927007V441.15597a268.605238 268.605238 0 0 1 44.821057 21.463023V225.551481c0-45.70045-37.047614-82.746848-82.746848-82.746849H180.453104c-45.70045 0-82.746848 37.047614-82.746848 82.746849v590.263526c0 45.70045 37.047614 82.746848 82.746848 82.746848h317.980164a273.587248 273.587248 0 0 1-8.168744-7.451121z" fill="#4E4D4D" p-id="4273"></path><path d="M770.725145 489.61623a225.243754 225.243754 0 0 1 44.821057 27.231985v-0.21407a225.182938 225.182938 0 0 0-44.821057-27.114003v0.096088zM812.590566 778.530212H646.820768V576.105667h44.821057v157.604704h120.948741zM209.55091 380.121489h498.255687v44.821057H209.55091zM600.682445 81.4308h44.821058v166.626082h-44.821058zM406.842623 712.17437H209.55091v44.821057h203.864657a272.351476 272.351476 0 0 1-6.572944-44.821057zM450.941192 546.147929H209.55091v44.821057h217.435038a268.707408 268.707408 0 0 1 23.955244-44.821057z" p-id="4274"></path></svg>
|
After Width: | Height: | Size: 2.3 KiB |
@@ -2,7 +2,6 @@
|
||||
Read db file content and response 3000 words
|
||||
*/
|
||||
import type { NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@fastgpt/service/common/response';
|
||||
import { authFile } from '@fastgpt/service/support/permission/auth/file';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { DatasetSourceReadTypeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
|
@@ -2,7 +2,6 @@ import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@fastgpt/service/common/response';
|
||||
import { connectToDatabase } from '@/service/mongo';
|
||||
import { readMongoImg } from '@fastgpt/service/common/file/image/controller';
|
||||
import { guessBase64ImageType } from '@fastgpt/service/common/file/utils';
|
||||
|
||||
// get the models available to the system
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
@@ -10,12 +9,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
await connectToDatabase();
|
||||
const { id } = req.query as { id: string };
|
||||
|
||||
const { binary, metadata } = await readMongoImg({ id });
|
||||
const { binary, mime } = await readMongoImg({ id });
|
||||
|
||||
res.setHeader(
|
||||
'Content-Type',
|
||||
metadata?.mime ?? guessBase64ImageType(binary.toString('base64'))
|
||||
);
|
||||
res.setHeader('Content-Type', mime);
|
||||
res.send(binary);
|
||||
} catch (error) {
|
||||
jsonRes(res, {
|
||||
|
Reference in New Issue
Block a user