Skip to content

Commit

Permalink
fix: CQ module output (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Oct 30, 2023
1 parent 60ee160 commit 661ee79
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
21 changes: 21 additions & 0 deletions packages/global/support/user/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,24 @@ export const InformTypeMap = {
label: '系统通知'
}
};

export enum TeamMemberRoleEnum {
owner = 'owner',
admin = 'admin',
member = 'member',
visitor = 'visitor'
}
export const TeamMemberRoleMap = {
[TeamMemberRoleEnum.owner]: {
label: 'user.team.role.owner'
},
[TeamMemberRoleEnum.admin]: {
label: 'user.team.role.admin'
},
[TeamMemberRoleEnum.member]: {
label: 'user.team.role.member'
},
[TeamMemberRoleEnum.visitor]: {
label: 'user.team.role.visitor'
}
};
21 changes: 21 additions & 0 deletions packages/global/support/user/controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export type CreateTeamProps = {
ownerId: string;
name: string;
avatar?: string;
};
export type UpdateTeamProps = {
id: string;
name?: string;
avatar?: string;
};
export type updateTeamBalanceProps = {
id: string;
balance: number;
};

export type CreateTeamMemberProps = {
ownerId: string;
teamId: string;
userId: string;
name?: string;
};
18 changes: 17 additions & 1 deletion packages/global/support/user/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InformTypeEnum } from './constant';
import { InformTypeEnum, TeamMemberRoleEnum } from './constant';

export type UserModelSchema = {
_id: string;
Expand Down Expand Up @@ -30,3 +30,19 @@ export type UserInformSchema = {
content: string;
read: boolean;
};

export type TeamSchema = {
_id: string;
name: string;
ownerId: string;
avatar: string;
createTime: Date;
};

export type TeamMemberSchema = {
_id: string;
name: string;
teamId: string;
userId: string;
role: `${TeamMemberRoleEnum}`;
};
5 changes: 4 additions & 1 deletion packages/service/support/user/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { hashStr } from '@fastgpt/global/common/string/tools';
import { PRICE_SCALE } from '@fastgpt/global/common/bill/constants';
import type { UserModelSchema } from '@fastgpt/global/support/user/type';

export const userCollectionName = 'users';

const UserSchema = new Schema({
username: {
// 可以是手机/邮箱,新的验证都只用手机
Expand Down Expand Up @@ -60,4 +62,5 @@ const UserSchema = new Schema({
}
});

export const MongoUser: Model<UserModelSchema> = models['user'] || model('user', UserSchema);
export const MongoUser: Model<UserModelSchema> =
models[userCollectionName] || model(userCollectionName, UserSchema);
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@ const NodeCQNode = ({ data }: NodeProps<FlowModuleItemType>) => {

onChangeNode({
moduleId,
type: 'updateOutput',
key: agentKey,
value: outputs.concat({
type: 'addOutput',
value: {
key,
label: '',
type: FlowNodeOutputTypeEnum.hidden,
targets: []
})
}
});
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ ${systemPrompt}
tokens: response.usage?.total_tokens || 0
};
} catch (error) {
console.log(agentFunction.parameters);
console.log(response.choices?.[0]?.message);

console.log('Your model may not support function_call', error);

return {
Expand Down
3 changes: 3 additions & 0 deletions projects/app/src/service/moduleDispatch/agent/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ async function functionCall({
try {
return JSON.parse(response.choices?.[0]?.message?.function_call?.arguments || '{}');
} catch (error) {
console.log(agentFunction.parameters);
console.log(response.choices?.[0]?.message);
console.log('Your model may not support function_call', error);
return {};
}
})();
Expand Down

0 comments on commit 661ee79

Please sign in to comment.