This commit is contained in:
Zhang Minghan 2023-10-28 10:42:57 +08:00
parent 0b34d566fe
commit 67b574033b
3 changed files with 33 additions and 11 deletions

View File

@ -4,9 +4,9 @@
# [Chat Nio](https://chatnio.net)
👋 强大精美的 **AI聚合** 聊天平台
🚀 强大精美的 **AI聚合** 聊天平台
👋 Powerful and beautiful **AI Aggregation** chat platform
🚀 Powerful and beautiful **AI Aggregation** chat platform
[官网](https://chatnio.net) | [开放文档](https://docs.chatnio.net) | [SDKs](https://docs.chatnio.net/kuai-su-kai-shi) | [QQ 群](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=YKcvGGlM03LYWlPk-iosqAqL4qHwOtBx&authKey=6cjCqRNKNuOUJltyo%2FNgmKm%2BS%2FUCtAyVHCnirHyxNuxGExUHsJRtlSaW1EeDxhNx&noverify=0&group_code=565902327)

View File

@ -9,6 +9,7 @@ import { useEffect } from "react";
import { Model } from "../../conversation/types.ts";
import { modelEvent } from "../../events/model.ts";
import { isSubscribedSelector } from "../../store/subscription.ts";
import {teenagerSelector} from "../../store/package.ts";
function GetModel(name: string): Model {
return supportModels.find((model) => model.id === name) as Model;
@ -26,6 +27,7 @@ function ModelSelector(props: ModelSelectorProps) {
const model = useSelector(selectModel);
const auth = useSelector(selectAuthenticated);
const subscription = useSelector(isSubscribedSelector);
const student = useSelector(teenagerSelector);
useEffect(() => {
if (auth && model === "gpt-3.5-turbo-0613")
@ -41,17 +43,28 @@ function ModelSelector(props: ModelSelectorProps) {
});
const list = supportModels.map(
(model: Model): SelectItemProps => ({
(model: Model): SelectItemProps => {
const array = ["gpt-4", "claude-2"];
if (subscription && array.includes(model.id)) {
return {
name: model.id,
value: model.name,
badge: { variant: "gold", name: "plus" },
} as SelectItemProps;
} else if (student && model.id === "claude-2") {
return {
name: model.id,
value: model.name,
badge: { variant: "gold", name: "student" },
} as SelectItemProps;
}
return {
name: model.id,
value: model.name,
badge:
model.free || (subscription && model.id === "gpt-4")
? {
variant: model.free ? "default" : "gold",
name: model.free ? "free" : "plus",
}
: undefined,
}),
badge: model.free && { variant: "default", name: "free" }
} as SelectItemProps;
},
);
return (

View File

@ -261,3 +261,12 @@ export function handleGenerationData(data: string): string {
.replace(/}\s*$/g, "");
return handleLine(escapeRegExp(data), 6);
}
export function getSelectionText(): string {
if (window.getSelection) {
return window.getSelection()?.toString() || "";
} else if (document.getSelection && document.getSelection()?.toString()) {
return document.getSelection()?.toString() || "";
}
return "";
}