From 950dffaedf952cfa598cabb0353dca40ef3f958f Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 28 Jul 2023 20:47:20 +0800 Subject: [PATCH] docs --- client/public/docs/chatProblem.md | 6 +++- client/public/docs/csvSelect.md | 9 ----- client/public/docs/intro.md | 34 ------------------- client/public/docs/shareHint.md | 3 -- client/public/docs/versionIntro.md | 8 ++--- client/src/components/Markdown/Link.tsx | 34 +++++++++++++------ client/src/pages/api/admin/initOutlink.ts | 27 +++++++++++++++ client/src/pages/api/chat/shareChat/create.ts | 4 ++- 8 files changed, 62 insertions(+), 63 deletions(-) delete mode 100644 client/public/docs/csvSelect.md delete mode 100644 client/public/docs/intro.md delete mode 100644 client/public/docs/shareHint.md create mode 100644 client/src/pages/api/admin/initOutlink.ts diff --git a/client/public/docs/chatProblem.md b/client/public/docs/chatProblem.md index 7802d77a3..a2eb9ab01 100644 --- a/client/public/docs/chatProblem.md +++ b/client/public/docs/chatProblem.md @@ -1,7 +1,11 @@ ### 常见问题 +**一键部署**:V4 版本未正式开源,目前仅提供一键部署方案: + +[![](https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg)](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Dfastgpt) + +**Git 地址**: [项目地址。V4-beta 暂未开源,在正式版发布后会开源。](https://github.com/labring/FastGPT) **反馈问卷**: 如果你遇到任何使用问题或有期望的功能,可以[填写该问卷](https://www.wjx.cn/vm/rLIw1uD.aspx#) -**Git 地址**: [项目地址。V4-preview 暂未开源,在正式版发布后会开源。](https://github.com/labring/FastGPT) **问题文档**: [先看文档,再提问](https://kjqvjse66l.feishu.cn/docx/HtrgdT0pkonP4kxGx8qcu6XDnGh) **价格表** | 计费项 | 价格: 元/ 1K tokens(包含上下文)| diff --git a/client/public/docs/csvSelect.md b/client/public/docs/csvSelect.md deleted file mode 100644 index 94d8fe3e8..000000000 --- a/client/public/docs/csvSelect.md +++ /dev/null @@ -1,9 +0,0 @@ -接受一个 csv 文件,表格头包含 question 和 answer。question 代表问题,answer 代表答案。 -导入前会进行去重,如果问题和答案完全相同,则不会被导入,所以最终导入的内容可能会比文件的内容少。但是,对于带有换行的内容,目前无法去重。 - -### 请保证 csv 文件为 utf-8 编码 - -| question | answer | -| ------------- | ------------------------------------------------------ | -| 什么是 laf | laf 是一个云函数开发平台…… | -| 什么是 sealos | Sealos 是以 kubernetes 为内核的云操作系统发行版,可以…… | diff --git a/client/public/docs/intro.md b/client/public/docs/intro.md deleted file mode 100644 index 436c27a01..000000000 --- a/client/public/docs/intro.md +++ /dev/null @@ -1,34 +0,0 @@ -## 欢迎使用 Fast GPT - -### 项目开源 - -FastGpt 项目完全开源,可随意私有化部署,去除平台风险忧虑。项目地址:[Git 仓库](https://github.com/labring/FastGPT) - -### 开始使用知识库 - -1. AI 助手详情里,有一个模型效果。打开知识库搜索开关即可使用知识库搜索功能。 -2. 导入知识库数据。可以手动输入或文件导入。 -3. 开始对话。 -4. 对话结束后,会看到聊天下方有一个“查看提示词”,可以看到搜索到了哪些内容。 - -注意:使用知识库模型对话时,tokens 消耗会加快。 - -### 价格表 - -如果使用了自己的 Api Key,网页上 openai 模型聊天不会计费。可以在账号页,看到详细账单。 -| 计费项 | 价格: 元/ 1K tokens(包含上下文)| -| --- | --- | -| 知识库 - 索引 | 0.001 | -| FastAI4k - 对话 | 0.015 | -| FastAI16k - 对话 | 0.03 | -| FastAI-Plus - 对话 | 0.45 | -| 文件拆分 | 0.03 | - -### 交流群/问题反馈 - -如果群满了,可加个小助手,定时拉 -wx 号: YNyiqi - -| 交流群 | 小助手 | -| ------------------------------------------------- | ---------------------------------------------- | -| ![](https://otnvvf-imgs.oss.laf.run/wxqun300.jpg) | ![](https://otnvvf-imgs.oss.laf.run/wx300.jpg) | diff --git a/client/public/docs/shareHint.md b/client/public/docs/shareHint.md deleted file mode 100644 index 451815505..000000000 --- a/client/public/docs/shareHint.md +++ /dev/null @@ -1,3 +0,0 @@ -你正准备分享对话,请确保分享链接不会滥用,因为它是使用的是你的 API key。 -* 分享空白对话:为该模型创建一个空白的聊天分享出去。 -* 分享当前对话:会把当前聊天的内容也分享出去,但是要注意不要多个人同时用一个聊天内容。 diff --git a/client/public/docs/versionIntro.md b/client/public/docs/versionIntro.md index 5d8f6bf47..4dd9cfc5d 100644 --- a/client/public/docs/versionIntro.md +++ b/client/public/docs/versionIntro.md @@ -1,10 +1,8 @@ -### Fast GPT V4.1-preview - -preview 版本尚未稳定,请以测试为主。正式版上线前可能会初始化或删除部分对话/应用数据。 +### Fast GPT V4.0-beta 1. 全新交互,增加采用模块组合的方式构建知识库,同时保留表单的简易模式。 2. 问题分类 - 可以对用户的问题进行分类,再执行不同的操作。 3. 对话引导 - 增加开场引导和变量,提高对话可玩性。 4. 新增 - 每轮对话均可展示完整的上下文状态。 -5. 优化 - OpenAPI 接口可直接传入 chatId 作为上下文标记。 -6. 优化 - 模块调度方案。 +5. 新增 - 网页嵌入(简单版),可直接接入现有网页。在 【应用详情-外部使用-创建新链接-嵌入网页】 中获取嵌入脚本。 +6. 新增 - 个人 openai 账号可以使用网页上 OpenAI 对话模型。 diff --git a/client/src/components/Markdown/Link.tsx b/client/src/components/Markdown/Link.tsx index 26e90eb4d..b212f4595 100644 --- a/client/src/components/Markdown/Link.tsx +++ b/client/src/components/Markdown/Link.tsx @@ -1,18 +1,32 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { Box } from '@chakra-ui/react'; +import Image from './img/Image'; const regex = /((http|https|ftp):\/\/[^\s\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]+)/gi; -const Link = (props: { href?: string; children?: React.ReactNode[] }) => { - const decText = decodeURIComponent(props.href || ''); - const replaceText = decText.replace(regex, (match, p1) => { - const text = decText === props.children?.[0] ? p1 : props.children?.[0]; - const isInternal = /^\/#/i.test(p1); - const target = isInternal ? '_self' : '_blank'; - return `${text}`; - }); +const Link = (props: { href?: string; children?: any }) => { + const Html = useMemo(() => { + const decText = decodeURIComponent(props.href || ''); - return ; + return decText.replace(regex, (match, p1) => { + let text = decText === props.children?.[0] ? p1 : props.children?.[0]; + const isInternal = /^\/#/i.test(p1); + const target = isInternal ? '_self' : '_blank'; + + if (props?.children?.[0]?.props?.node?.tagName === 'img') { + // eslint-disable-next-line @next/next/no-img-element + text = ``; + } + + return `${text}`; + }); + }, [props.children, props.href]); + + return typeof Html === 'string' ? ( + + ) : ( + Html + ); }; export default React.memo(Link); diff --git a/client/src/pages/api/admin/initOutlink.ts b/client/src/pages/api/admin/initOutlink.ts new file mode 100644 index 000000000..6d94e17dd --- /dev/null +++ b/client/src/pages/api/admin/initOutlink.ts @@ -0,0 +1,27 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import type { NextApiRequest, NextApiResponse } from 'next'; +import { jsonRes } from '@/service/response'; +import { authUser } from '@/service/utils/auth'; +import { connectToDatabase, OutLink } from '@/service/mongo'; +import { OutLinkTypeEnum } from '@/constants/chat'; + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + try { + await authUser({ req, authRoot: true }); + await connectToDatabase(); + + await OutLink.updateMany( + {}, + { + $set: { type: OutLinkTypeEnum.share } + } + ); + + jsonRes(res, {}); + } catch (error) { + jsonRes(res, { + code: 500, + error + }); + } +} diff --git a/client/src/pages/api/chat/shareChat/create.ts b/client/src/pages/api/chat/shareChat/create.ts index 4c8eb5f10..51476e0bd 100644 --- a/client/src/pages/api/chat/shareChat/create.ts +++ b/client/src/pages/api/chat/shareChat/create.ts @@ -4,6 +4,7 @@ import { connectToDatabase, OutLink } from '@/service/mongo'; import { authApp, authUser } from '@/service/utils/auth'; import type { ShareChatEditType } from '@/types/app'; import { customAlphabet } from 'nanoid'; +import { OutLinkTypeEnum } from '@/constants/chat'; const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 24); /* create a shareChat */ @@ -27,7 +28,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) shareId, userId, appId, - name + name, + type: OutLinkTypeEnum.share }); jsonRes(res, {