fix: index (#5458)

* doc

* fix: home app name

* fix: char init error status

* fix: index

* fix: secret input
This commit is contained in:
Archer
2025-08-14 18:54:47 +08:00
committed by GitHub
parent 9a9f094e15
commit eadf2fd54c
14 changed files with 64 additions and 43 deletions

View File

@@ -382,7 +382,7 @@ event取值
对于用户选择,你只需要直接传递一个选择的结果给 messages 即可。
```bash
curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \
curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
@@ -404,7 +404,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions'
表单输入稍微麻烦一点,需要将输入的内容,以对象形式并序列化成字符串,作为`messages`的值。对象的 key 对应表单的 keyvalue 为用户输入的值。务必确保`chatId`是一致的。
```bash
curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \
curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{

View File

@@ -935,7 +935,7 @@ curl --location --request DELETE 'http://localhost:3000/api/core/dataset/collect
<Tab value="请求示例" >
```bash
curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/data/pushData' \
curl --location --request POST 'https://localhost:3000/api/core/dataset/data/pushData' \
--header 'Authorization: Bearer apikey' \
--header 'Content-Type: application/json' \
--data-raw '{
@@ -1238,7 +1238,7 @@ curl --location --request DELETE 'http://localhost:3000/api/core/dataset/data/de
<Tab value="请求示例" >
```bash
curl --location --request POST 'https://api.fastgpt.in/api/core/dataset/searchTest' \
curl --location --request POST 'https://localhost:3000/api/core/dataset/searchTest' \
--header 'Authorization: Bearer fastgpt-xxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{

View File

@@ -29,7 +29,7 @@ FastGPT 的 API Key **有 2 类**,一类是全局通用的 key (无法直接
OpenAPI 中,所有的接口都通过 Header.Authorization 进行鉴权。
```
baseUrl: "https://api.fastgpt.in/api"
baseUrl: "https://localhost:3000/api"
headers: {
Authorization: "Bearer {{apikey}}"
}
@@ -38,7 +38,7 @@ headers: {
**发起应用对话示例**
```sh
curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \
curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
@@ -59,7 +59,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions'
`v4.8.13`后支持传入自定义的用户 ID, 并且存入历史记录中。
```sh
curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions' \
curl --location --request POST 'https://localhost:3000/api/v1/chat/completions' \
--header 'Authorization: Bearer fastgpt-xxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{

View File

@@ -15,5 +15,6 @@ description: 'FastGPT V4.12.1 更新说明'
## 🐛 修复
1. 工具密钥输入boolean 值无法通过 form 校验。
## 🔨 工具更新

View File

@@ -24,7 +24,7 @@ import { Alert } from '@/components/docs/Alert';
## 替换三方应用的变量
```bash
OPENAI_API_BASE_URL: https://api.fastgpt.in/api (改成自己部署的域名)
OPENAI_API_BASE_URL: https://localhost:3000/api (改成自己部署的域名)
OPENAI_API_KEY = 上一步获取到的密钥
```

View File

@@ -30,9 +30,9 @@
"document/content/docs/introduction/development/modelConfig/one-api.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/introduction/development/modelConfig/ppio.mdx": "2025-08-05T23:20:39+08:00",
"document/content/docs/introduction/development/modelConfig/siliconCloud.mdx": "2025-08-05T23:20:39+08:00",
"document/content/docs/introduction/development/openapi/chat.mdx": "2025-08-05T23:20:39+08:00",
"document/content/docs/introduction/development/openapi/dataset.mdx": "2025-08-13T16:31:28+08:00",
"document/content/docs/introduction/development/openapi/intro.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/introduction/development/openapi/chat.mdx": "2025-08-14T16:11:54+08:00",
"document/content/docs/introduction/development/openapi/dataset.mdx": "2025-08-14T16:11:54+08:00",
"document/content/docs/introduction/development/openapi/intro.mdx": "2025-08-14T16:11:54+08:00",
"document/content/docs/introduction/development/openapi/share.mdx": "2025-08-05T23:20:39+08:00",
"document/content/docs/introduction/development/proxy/cloudflare.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/introduction/development/proxy/http_proxy.mdx": "2025-07-23T21:35:03+08:00",
@@ -103,7 +103,7 @@
"document/content/docs/upgrading/4-11/4110.mdx": "2025-08-05T23:20:39+08:00",
"document/content/docs/upgrading/4-11/4111.mdx": "2025-08-07T22:49:09+08:00",
"document/content/docs/upgrading/4-12/4120.mdx": "2025-08-12T22:45:19+08:00",
"document/content/docs/upgrading/4-12/4121.mdx": "2025-08-13T21:31:30+08:00",
"document/content/docs/upgrading/4-12/4121.mdx": "2025-08-14T15:48:22+08:00",
"document/content/docs/upgrading/4-8/40.mdx": "2025-08-02T19:38:37+08:00",
"document/content/docs/upgrading/4-8/41.mdx": "2025-08-02T19:38:37+08:00",
"document/content/docs/upgrading/4-8/42.mdx": "2025-08-02T19:38:37+08:00",
@@ -182,6 +182,6 @@
"document/content/docs/use-cases/external-integration/dingtalk.mdx": "2025-07-23T21:35:03+08:00",
"document/content/docs/use-cases/external-integration/feishu.mdx": "2025-07-24T14:23:04+08:00",
"document/content/docs/use-cases/external-integration/official_account.mdx": "2025-08-05T23:20:39+08:00",
"document/content/docs/use-cases/external-integration/openapi.mdx": "2025-08-04T18:10:58+08:00",
"document/content/docs/use-cases/external-integration/openapi.mdx": "2025-08-14T16:11:54+08:00",
"document/content/docs/use-cases/index.mdx": "2025-07-24T14:23:04+08:00"
}

View File

@@ -89,7 +89,10 @@ const ChatSchema = new Schema({
});
try {
ChatSchema.index({ initCharts: 1 });
// Tmp
ChatSchema.index({ initStatistics: 1 });
ChatSchema.index({ appId: 1, tmbId: 1, outLinkUid: 1 });
ChatSchema.index({ chatId: 1 });
// get user history
ChatSchema.index({ tmbId: 1, appId: 1, top: -1, updateTime: -1 });

View File

@@ -40,7 +40,7 @@
"file_input": "系统文件",
"file_input_tip": "可通过【插件开始】节点的“文件链接”获取对应文件的链接",
"history_slider.home.title": "聊天",
"home.chat_app": "首页聊天-{{name}}",
"home.chat_app": "首页聊天",
"home.no_available_tools": "暂无可用工具",
"home.select_tools": "选择工具",
"home.tools": "工具:{{num}}",

View File

@@ -40,7 +40,7 @@
"file_input": "檔案輸入",
"file_input_tip": "可透過「外掛程式啟動」節點的「檔案連結」取得對應檔案的連結",
"history_slider.home.title": "聊天",
"home.chat_app": "首页聊天-{{name}}",
"home.chat_app": "首页聊天",
"home.chat_id": "會話ID",
"home.no_available_tools": "暫無可用工具",
"home.select_tools": "選擇工具",

View File

@@ -25,6 +25,7 @@ import { secretInputTypeToInputType } from '@/components/core/app/formRender/uti
import { getSystemPlugTemplates } from '@/web/core/app/api/plugin';
import type { NodeTemplateListItemType } from '@fastgpt/global/core/workflow/type/node';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { InputTypeEnum } from '@/components/core/app/formRender/constant';
export type ToolParamsFormType = {
type: SystemToolInputTypeEnum;
@@ -262,18 +263,33 @@ const SecretInputModal = ({
<Controller
control={control}
name={inputKey}
rules={{ required: item.required }}
render={({ field: { onChange, value }, fieldState: { error } }) => (
<InputRender
inputType={secretInputTypeToInputType(item.inputType)}
value={value}
onChange={onChange}
placeholder={item.description}
bg={'myGray.50'}
list={item.list}
isInvalid={!!error}
/>
)}
rules={{
required:
item.required &&
secretInputTypeToInputType(item.inputType) !==
InputTypeEnum.switch
? true
: false,
validate:
item.required &&
secretInputTypeToInputType(item.inputType) ===
InputTypeEnum.switch
? (value) => value !== undefined && value !== null
: undefined
}}
render={({ field: { onChange, value }, fieldState: { error } }) => {
return (
<InputRender
inputType={secretInputTypeToInputType(item.inputType)}
value={value}
onChange={onChange}
placeholder={item.description}
bg={'myGray.50'}
list={item.list}
isInvalid={!!error}
/>
);
}}
/>
)}
</Box>

View File

@@ -217,7 +217,7 @@ const HomeChatWindow = ({ myApps }: Props) => {
variables,
responseChatItemId,
appId,
appName: t('chat:home.chat_app', { name: 'FastGPT' }),
appName: t('chat:home.chat_app'),
chatId,
...form2AppWorkflow(formData, t)
},

View File

@@ -62,8 +62,8 @@ async function handler(
}
async function processChatRecord(chat: ChatSchemaType) {
async function calculateChatItemStats(chatId: string) {
const chatItems = await MongoChatItem.find({ chatId }).lean();
async function calculateChatItemStats() {
const chatItems = await MongoChatItem.find({ appId: chat.appId, chatId: chat.chatId }).lean();
let chatItemCount = chatItems.length;
let errorCount = 0;
@@ -122,21 +122,21 @@ async function processChatRecord(chat: ChatSchemaType) {
};
}
async function checkIsFirstChat(chat: any): Promise<boolean> {
async function checkIsFirstChat(): Promise<boolean> {
const earliestChat = await MongoChat.findOne(
{
userId: chat.userId,
appId: chat.appId
appId: chat.appId,
tmbId: chat.tmbId,
...(chat.outLinkUid && { outLinkUid: chat.outLinkUid })
},
{},
{ sort: { createTime: 1 } }
'_id'
).lean();
return earliestChat?._id.toString() === chat._id.toString();
}
const chatItemStats = await calculateChatItemStats(chat.chatId);
const isFirstChat = await checkIsFirstChat(chat);
const chatItemStats = await calculateChatItemStats();
const isFirstChat = await checkIsFirstChat();
const chatLogData = {
appId: chat.appId,

View File

@@ -152,12 +152,12 @@ export const pushQuestionGuideUsage = ({
createUsage({
teamId,
tmbId,
appName: 'core.app.Question Guide',
appName: i18nT('common:core.app.Question Guide'),
totalPoints,
source: UsageSourceEnum.fastgpt,
list: [
{
moduleName: 'core.app.Question Guide',
moduleName: i18nT('common:core.app.Question Guide'),
amount: totalPoints,
model: modelName,
inputTokens,

View File

@@ -77,8 +77,6 @@ const ChatRecordContextProvider = ({
scrollToBottom();
}
setIsChatRecordsLoaded(true);
return {
...res,
list: res.list.map((item) => ({
@@ -93,7 +91,10 @@ const ChatRecordContextProvider = ({
refreshDeps: [params],
params,
scrollLoadType: 'top',
showErrorToast: false
showErrorToast: false,
onFinally() {
setIsChatRecordsLoaded(true);
}
}
);