-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f30bd66
commit 93a7786
Showing
13 changed files
with
157 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import { PluginRuntimeType } from '@fastgpt/global/core/workflow/runtime/type'; | ||
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type'; | ||
import { splitCombinePluginId } from './controller'; | ||
import { PluginSourceEnum } from '@fastgpt/global/core/plugin/constants'; | ||
import { SystemPluginTemplateItemType } from '@fastgpt/global/core/workflow/type'; | ||
|
||
/* | ||
1. Commercial plugin: n points per times | ||
2. Other plugin: sum of children points | ||
Plugin points calculation: | ||
1. Return 0 if error | ||
2. Add configured points if commercial plugin | ||
3. Add sum of child nodes points | ||
*/ | ||
export const computedPluginUsage = async ( | ||
plugin: PluginRuntimeType, | ||
childrenUsage: ChatNodeUsageType[] | ||
) => { | ||
// const { source } = await splitCombinePluginId(plugin.id); | ||
export const computedPluginUsage = async ({ | ||
plugin, | ||
childrenUsage, | ||
error | ||
}: { | ||
plugin?: SystemPluginTemplateItemType; | ||
childrenUsage: ChatNodeUsageType[]; | ||
error?: boolean; | ||
}) => { | ||
if (error) { | ||
return 0; | ||
} | ||
|
||
// Commercial plugin: n points per times | ||
// if (source === PluginSourceEnum.commercial) { | ||
// return plugin.currentCost ?? 0; | ||
// } | ||
let tokenFee = 0; | ||
if (plugin && plugin.hasTokenFee) { | ||
tokenFee = plugin.currentCost ?? 0; | ||
} | ||
|
||
return childrenUsage.reduce((sum, item) => sum + (item.totalPoints || 0), 0); | ||
return tokenFee + childrenUsage.reduce((sum, item) => sum + (item.totalPoints || 0), 0); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
packages/web/components/common/Icon/icons/common/pluginFill.svg
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.