Skip to content

Commit

Permalink
优化建议模式;修复多索引训练失败问题 (#1043)
Browse files Browse the repository at this point in the history
* doc

* Optimize possible null Pointers and parts of Ux

* fix: mulity index training error
  • Loading branch information
c121914yu authored Mar 21, 2024
1 parent 9d27de1 commit a63467d
Show file tree
Hide file tree
Showing 11 changed files with 407 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: 微信交流群
url: https://doc.fastgpt.in/wechat-fastgpt.webp
url: https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg
about: FastGPT 全是问题群
1 change: 0 additions & 1 deletion packages/service/core/dataset/training/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getCollectionWithDataset } from '../controller';
import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants';
import { simpleText } from '@fastgpt/global/common/string/tools';
import { countPromptTokens } from '@fastgpt/global/common/string/tiktoken';
import type { VectorModelItemType, LLMModelItemType } from '@fastgpt/global/core/ai/model.d';

export const lockTrainingDataByTeamId = async (teamId: string): Promise<any> => {
try {
Expand Down
20 changes: 10 additions & 10 deletions packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ export const runToolWithPromptCall = async (
parseAnswerResult.toolName = toolModule.name;
parseAnswerResult.toolAvatar = toolModule.avatar;

// run tool flow
const startParams = (() => {
try {
return json5.parse(parseAnswerResult.arguments);
} catch (error) {
return {};
}
})();

// SSE response to client
if (stream && detail) {
responseWrite({
Expand All @@ -182,15 +191,6 @@ export const runToolWithPromptCall = async (
});
}

// run tool flow
const startParams = (() => {
try {
return json5.parse(parseAnswerResult.arguments);
} catch (error) {
return {};
}
})();

const moduleRunResponse = await dispatchWorkFlow({
...props,
runtimeModules: runtimeModules.map((module) => ({
Expand Down Expand Up @@ -374,7 +374,7 @@ const parseAnswer = (str: string): FunctionCallCompletion | string => {
return {
id: getNanoid(),
name: toolCall.toolId,
arguments: JSON.stringify(toolCall.arguments)
arguments: JSON.stringify(toolCall.arguments || toolCall.parameters)
};
} catch (error) {
return str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ async function streamResponse({

const responseChoice = part.choices?.[0]?.delta;
// console.log(JSON.stringify(responseChoice, null, 2));
if (responseChoice.content) {
const content = responseChoice?.content || '';
if (responseChoice?.content) {
const content = responseChoice.content || '';
textAnswer += content;

responseWrite({
Expand All @@ -343,7 +343,7 @@ async function streamResponse({
text: content
})
});
} else if (responseChoice.tool_calls?.[0]) {
} else if (responseChoice?.tool_calls?.[0]) {
const toolCall: ChatCompletionMessageToolCall = responseChoice.tool_calls[0];

// 流响应中,每次只会返回一个工具. 如果带了 id,说明是执行一个工具
Expand Down
1 change: 1 addition & 0 deletions projects/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@
"Not sufficient": "Your AI points are insufficient, please upgrade the package or purchase additional AI points before continuing to use.",
"Pay error": "Pay error",
"Pay success": "Pay success",
"Plan expired time": "Plan expired time",
"Standard Plan Detail": "Standard Plan Detail",
"To read plan": "Read plan",
"bill": {
Expand Down
1 change: 1 addition & 0 deletions projects/app/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@
"Not sufficient": "您的 AI 积分不足,请先升级套餐或购买额外 AI 积分后继续使用。",
"Pay error": "支付失败",
"Pay success": "支付成功",
"Plan expired time": "套餐到期时间",
"Standard Plan Detail": "套餐详情",
"To read plan": "查看套餐",
"bill": {
Expand Down
10 changes: 5 additions & 5 deletions projects/app/src/pages/account/components/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ const PlanUsage = () => {
<Box fontWeight={'bold'} fontSize="xl">
{t(planName)}
</Box>
<Flex mt="2" color={'#485264'} fontSize="sm">
<Box>{t('support.wallet.Plan expired time')}:</Box>
<Box ml={2}>{formatTime2YMD(standardPlan?.expiredTime)}</Box>
</Flex>
{isFreeTeam && (
<Box mt="3" color={'#485264'} fontSize="sm">
<Box mt="2" color={'#485264'} fontSize="sm">
免费版用户15天无任何使用记录时,系统会自动清理账号知识库。
</Box>
)}
<Flex mt="3" color={'#485264'} fontSize="sm">
<Box>{t('common.Expired Time')}:</Box>
<Box ml={2}>{formatTime2YMD(standardPlan?.expiredTime)}</Box>
</Flex>
</Box>
<Button onClick={() => router.push('/price')}>
{t('support.wallet.subscription.Upgrade plan')}
Expand Down
4 changes: 2 additions & 2 deletions projects/app/src/pages/account/components/InformTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
import { usePagination } from '@fastgpt/web/hooks/usePagination';
import { useLoading } from '@fastgpt/web/hooks/useLoading';

const BillTable = () => {
const InformTable = () => {
const theme = useTheme();
const { Loading } = useLoading();
const { isPc } = useSystemStore();
Expand Down Expand Up @@ -87,4 +87,4 @@ const BillTable = () => {
);
};

export default BillTable;
export default InformTable;
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const RenderList = React.memo(function RenderList({
return templates.length === 0 && !isLoadingData ? (
<EmptyTip text={t('core.app.ToolCall.No plugin')} />
) : (
<MyBox isLoading={isLoading}>
<MyBox>
{templates.map((item, i) => {
const selected = !!selectedTools.find((tool) => tool.id === item.id);
return (
Expand Down Expand Up @@ -257,6 +257,7 @@ const RenderList = React.memo(function RenderList({
size={'sm'}
variant={'whiteBase'}
leftIcon={<AddIcon fontSize={'10px'} />}
isLoading={isLoading}
onClick={() => onClickAdd(item)}
>
{t('common.Add')}
Expand Down
3 changes: 2 additions & 1 deletion projects/app/src/service/core/dataset/data/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export async function insertData2Dataset({
indexes =
Array.isArray(indexes) && indexes.length > 0
? indexes.map((index) => ({
...index,
// @ts-ignore
...index.toObject(),
dataId: undefined,
defaultIndex: index.text.trim() === qaStr
}))
Expand Down
Loading

0 comments on commit a63467d

Please sign in to comment.