fix: Update model handling and pricing display
- Changed model names to chatModels and updated related logic - Added model pricing details to Menu.Item title for clarity - Updated localization strings for input and output pricing
This commit is contained in:
parent
faf35d47ea
commit
415d61b525
@ -356,7 +356,7 @@ const InputMessage = observer((props: any) => {
|
||||
withArrow
|
||||
shadow="md"
|
||||
styles={menuStyles}
|
||||
disabled={config.modelNames.length === 0}
|
||||
disabled={config.chatModels.length === 0}
|
||||
>
|
||||
<Menu.Target>
|
||||
<Button
|
||||
@ -372,13 +372,14 @@ const InputMessage = observer((props: any) => {
|
||||
</Menu.Target>
|
||||
<Menu.Dropdown>
|
||||
<ScrollArea.Autosize placeholder="" type="always" mah={240}>
|
||||
{config.modelNames.map((modelName) => {
|
||||
{config.chatModels.map((model) => {
|
||||
return (
|
||||
<Menu.Item
|
||||
key={modelName}
|
||||
onClick={() => changeModel(modelName)}
|
||||
key={model.name}
|
||||
title={model.input_price!== -1? (t("input price:") + `${model.currency !== 'CNY' ? '$' : ''}${model.input_price}`+t("/1M tokens") + "\n" + t("output price:") + `${model.currency !== 'CNY' ? '$' : ''}${model.output_price}`+ t("/1M tokens")) : ""}
|
||||
onClick={() => changeModel(model.name)}
|
||||
>
|
||||
{getModelShowName(modelName)}
|
||||
{getModelShowName(model.name)}
|
||||
</Menu.Item>
|
||||
);
|
||||
})}
|
||||
|
@ -37,6 +37,9 @@
|
||||
"API Base of OpenAI": "OpenAI API 地址",
|
||||
"Access Key of Devchat": "DevChat 访问密钥",
|
||||
"Model Config": "模型配置",
|
||||
"/1M tokens": "/每百万token",
|
||||
"output price:": "输出价格:",
|
||||
"input price:": "输入价格",
|
||||
"Leave it blank if you won't use this llm model": "如果你不使用这个 LLM 模型,请不要配置",
|
||||
"the maximum number of tokens that can be used in the input": "输入中可以使用的最大令牌数",
|
||||
"Provider": "提供商",
|
||||
|
@ -36,13 +36,17 @@ export const Model = types.model({
|
||||
temperature: types.number,
|
||||
max_tokens: types.number,
|
||||
json_mode: types.boolean,
|
||||
input_price: types.number,
|
||||
output_price: types.number,
|
||||
currency: types.string
|
||||
});
|
||||
|
||||
|
||||
export const ConfigStore = types
|
||||
.model("Config", {
|
||||
config: types.optional(types.frozen(), {}),
|
||||
modelsTemplate: types.optional(types.array(Model), modelsTemplate),
|
||||
modelNames: types.optional(types.array(types.string),modelsTemplate.map((item)=>item.name)),
|
||||
chatModels: types.optional(types.array(Model), []),
|
||||
settle: types.optional(types.boolean, false),
|
||||
defaultModel: types.optional(types.string, ""),
|
||||
devchatApiKey: "DC.xxxxxxx",
|
||||
@ -63,11 +67,13 @@ export const ConfigStore = types
|
||||
temperature: item.temperature ?? 0.3,
|
||||
max_tokens: item.max_tokens ?? 2000,
|
||||
json_mode: item.json_mode ?? false,
|
||||
input_price: item.input_price ?? -1,
|
||||
output_price: item.output_price ?? -1,
|
||||
currency: item.currency ?? "CNY",
|
||||
};
|
||||
});
|
||||
self.modelNames = value
|
||||
.filter((item) => item.category === "chat")
|
||||
.map((item) => item.model ?? item.id);
|
||||
self.chatModels = models
|
||||
.filter((item) => item.category === "chat");
|
||||
self.modelsTemplate = models;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user