mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-15 22:43:43 +08:00
Compare commits
21 Commits
feat/markd
...
eb50f37f81
Author | SHA1 | Date | |
---|---|---|---|
|
eb50f37f81 | ||
|
c30ddfbb07 | ||
|
a2f0149786 | ||
|
03d36f96ed | ||
|
705dffc664 | ||
|
02f7e6de98 | ||
|
843dc52efa | ||
|
3809375694 | ||
|
1b0de25986 | ||
|
865c45dd29 | ||
|
1f5d8e6d9c | ||
|
c9ef6d58ed | ||
|
2d7229d2b8 | ||
|
11b37c15bd | ||
|
1d0038f17d | ||
|
619fa519c0 | ||
|
c261ebc82c | ||
|
f7c747c65f | ||
|
ecc65fa775 | ||
|
da9963d4ee | ||
|
24ff78e1c5 |
@@ -22,7 +22,7 @@ English / [简体中文](./README_CN.md)
|
|||||||
[![MacOS][MacOS-image]][download-url]
|
[![MacOS][MacOS-image]][download-url]
|
||||||
[![Linux][Linux-image]][download-url]
|
[![Linux][Linux-image]][download-url]
|
||||||
|
|
||||||
[NextChatAI](https://nextchat.club?utm_source=readme) / [Web App Demo](https://app.nextchat.dev) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Discord](https://discord.gg/YCkeafCafC) / [Enterprise Edition](#enterprise-edition) / [Twitter](https://twitter.com/NextChatDev)
|
[NextChatAI](https://nextchat.club?utm_source=readme) / [iOS APP](https://apps.apple.com/us/app/nextchat-ai/id6743085599) / [Web App Demo](https://app.nextchat.dev) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Enterprise Edition](#enterprise-edition)
|
||||||
|
|
||||||
|
|
||||||
[saas-url]: https://nextchat.club?utm_source=readme
|
[saas-url]: https://nextchat.club?utm_source=readme
|
||||||
@@ -40,11 +40,12 @@ English / [简体中文](./README_CN.md)
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## 🥳 Cheer for DeepSeek, China's AI star!
|
## 🥳 Cheer for NextChat iOS Version Online!
|
||||||
> Purpose-Built UI for DeepSeek Reasoner Model
|
> [👉 Click Here to Install Now](https://apps.apple.com/us/app/nextchat-ai/id6743085599)
|
||||||
|
|
||||||
<img src="https://github.com/user-attachments/assets/f3952210-3af1-4dc0-9b81-40eaa4847d9a"/>
|
> [❤️ Source Code Coming Soon](https://github.com/ChatGPTNextWeb/NextChat-iOS)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
## 🫣 NextChat Support MCP !
|
## 🫣 NextChat Support MCP !
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { getServerSideConfig } from "../config/server";
|
import { getServerSideConfig } from "../config/server";
|
||||||
import { OPENAI_BASE_URL, ServiceProvider } from "../constant";
|
import { OPENAI_BASE_URL, ServiceProvider, OpenaiPath } from "../constant";
|
||||||
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
||||||
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
authValue = req.headers.get("Authorization") ?? "";
|
authValue = req.headers.get("Authorization") ?? "";
|
||||||
authHeaderName = "Authorization";
|
authHeaderName = "Authorization";
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = `${req.nextUrl.pathname}`.replaceAll("/api/openai/", "");
|
let path = `${req.nextUrl.pathname}`.replaceAll("/api/openai/", "");
|
||||||
|
let isChatRequest = path.includes(OpenaiPath.ChatPath);
|
||||||
|
|
||||||
let baseUrl =
|
let baseUrl =
|
||||||
(isAzure ? serverConfig.azureUrl : serverConfig.baseUrl) || OPENAI_BASE_URL;
|
(isAzure ? serverConfig.azureUrl : serverConfig.baseUrl) || OPENAI_BASE_URL;
|
||||||
@@ -117,14 +117,14 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
const jsonBody = JSON.parse(clonedBody) as { model?: string };
|
||||||
|
|
||||||
// not undefined and is false
|
// not undefined and is false
|
||||||
if (
|
if ( isChatRequest &&
|
||||||
isModelNotavailableInServer(
|
isModelNotavailableInServer(
|
||||||
serverConfig.customModels,
|
serverConfig.customModels,
|
||||||
jsonBody?.model as string,
|
jsonBody?.model as string,
|
||||||
[
|
[
|
||||||
ServiceProvider.OpenAI,
|
ServiceProvider.OpenAI,
|
||||||
ServiceProvider.Azure,
|
ServiceProvider.Azure,
|
||||||
jsonBody?.model as string, // support provider-unspecified model
|
"custom" as string, // support provider-unspecified model
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@@ -56,7 +56,7 @@ export interface OpenAIListModelResponse {
|
|||||||
|
|
||||||
export interface RequestPayload {
|
export interface RequestPayload {
|
||||||
messages: {
|
messages: {
|
||||||
role: "system" | "user" | "assistant";
|
role: "developer" | "system" | "user" | "assistant";
|
||||||
content: string | MultimodalContent[];
|
content: string | MultimodalContent[];
|
||||||
}[];
|
}[];
|
||||||
stream?: boolean;
|
stream?: boolean;
|
||||||
@@ -198,7 +198,8 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
const isDalle3 = _isDalle3(options.config.model);
|
const isDalle3 = _isDalle3(options.config.model);
|
||||||
const isO1OrO3 =
|
const isO1OrO3 =
|
||||||
options.config.model.startsWith("o1") ||
|
options.config.model.startsWith("o1") ||
|
||||||
options.config.model.startsWith("o3");
|
options.config.model.startsWith("o3") ||
|
||||||
|
options.config.model.startsWith("o4-mini");
|
||||||
if (isDalle3) {
|
if (isDalle3) {
|
||||||
const prompt = getMessageTextContent(
|
const prompt = getMessageTextContent(
|
||||||
options.messages.slice(-1)?.pop() as any,
|
options.messages.slice(-1)?.pop() as any,
|
||||||
@@ -237,13 +238,21 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
|
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
|
||||||
};
|
};
|
||||||
|
|
||||||
// O1 使用 max_completion_tokens 控制token数 (https://platform.openai.com/docs/guides/reasoning#controlling-costs)
|
|
||||||
if (isO1OrO3) {
|
if (isO1OrO3) {
|
||||||
|
// by default the o1/o3 models will not attempt to produce output that includes markdown formatting
|
||||||
|
// manually add "Formatting re-enabled" developer message to encourage markdown inclusion in model responses
|
||||||
|
// (https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reasoning?tabs=python-secure#markdown-output)
|
||||||
|
requestPayload["messages"].unshift({
|
||||||
|
role: "developer",
|
||||||
|
content: "Formatting re-enabled",
|
||||||
|
});
|
||||||
|
|
||||||
|
// o1/o3 uses max_completion_tokens to control the number of tokens (https://platform.openai.com/docs/guides/reasoning#controlling-costs)
|
||||||
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
|
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add max_tokens to vision model
|
// add max_tokens to vision model
|
||||||
if (visionModel) {
|
if (visionModel && !isO1OrO3) {
|
||||||
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
|
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ import ReturnIcon from "../icons/return.svg";
|
|||||||
import CopyIcon from "../icons/copy.svg";
|
import CopyIcon from "../icons/copy.svg";
|
||||||
import SpeakIcon from "../icons/speak.svg";
|
import SpeakIcon from "../icons/speak.svg";
|
||||||
import SpeakStopIcon from "../icons/speak-stop.svg";
|
import SpeakStopIcon from "../icons/speak-stop.svg";
|
||||||
|
import LoadingIcon from "../icons/three-dots.svg";
|
||||||
import LoadingButtonIcon from "../icons/loading.svg";
|
import LoadingButtonIcon from "../icons/loading.svg";
|
||||||
import PromptIcon from "../icons/prompt.svg";
|
import PromptIcon from "../icons/prompt.svg";
|
||||||
import MaskIcon from "../icons/mask.svg";
|
import MaskIcon from "../icons/mask.svg";
|
||||||
@@ -78,6 +79,8 @@ import {
|
|||||||
|
|
||||||
import { uploadImage as uploadImageRemote } from "@/app/utils/chat";
|
import { uploadImage as uploadImageRemote } from "@/app/utils/chat";
|
||||||
|
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
|
||||||
import { ChatControllerPool } from "../client/controller";
|
import { ChatControllerPool } from "../client/controller";
|
||||||
import { DalleQuality, DalleStyle, ModelSize } from "../typing";
|
import { DalleQuality, DalleStyle, ModelSize } from "../typing";
|
||||||
import { Prompt, usePromptStore } from "../store/prompt";
|
import { Prompt, usePromptStore } from "../store/prompt";
|
||||||
@@ -122,15 +125,14 @@ import { getModelProvider } from "../utils/model";
|
|||||||
import { RealtimeChat } from "@/app/components/realtime-chat";
|
import { RealtimeChat } from "@/app/components/realtime-chat";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { getAvailableClientsCount, isMcpEnabled } from "../mcp/actions";
|
import { getAvailableClientsCount, isMcpEnabled } from "../mcp/actions";
|
||||||
import { Markdown } from "./markdown";
|
|
||||||
|
|
||||||
const localStorage = safeLocalStorage();
|
const localStorage = safeLocalStorage();
|
||||||
|
|
||||||
const ttsPlayer = createTTSPlayer();
|
const ttsPlayer = createTTSPlayer();
|
||||||
|
|
||||||
// const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
||||||
// loading: () => <LoadingIcon />,
|
loading: () => <LoadingIcon />,
|
||||||
// });
|
});
|
||||||
|
|
||||||
const MCPAction = () => {
|
const MCPAction = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -1982,8 +1984,6 @@ function _Chat() {
|
|||||||
fontFamily={fontFamily}
|
fontFamily={fontFamily}
|
||||||
parentRef={scrollRef}
|
parentRef={scrollRef}
|
||||||
defaultShow={i >= messages.length - 6}
|
defaultShow={i >= messages.length - 6}
|
||||||
immediatelyRender={i >= messages.length - 3}
|
|
||||||
streaming={message.streaming}
|
|
||||||
/>
|
/>
|
||||||
{getMessageImages(message).length == 1 && (
|
{getMessageImages(message).length == 1 && (
|
||||||
<img
|
<img
|
||||||
|
@@ -267,136 +267,6 @@ function tryWrapHtmlCode(text: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split content into paragraphs while preserving code blocks
|
|
||||||
function splitContentIntoParagraphs(content: string) {
|
|
||||||
// Check for unclosed code blocks
|
|
||||||
const codeBlockStartCount = (content.match(/```/g) || []).length;
|
|
||||||
let processedContent = content;
|
|
||||||
|
|
||||||
// Add closing tag if there's an odd number of code block markers
|
|
||||||
if (codeBlockStartCount % 2 !== 0) {
|
|
||||||
processedContent = content + "\n```";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract code blocks
|
|
||||||
const codeBlockRegex = /```[\s\S]*?```/g;
|
|
||||||
const codeBlocks: string[] = [];
|
|
||||||
let codeBlockCounter = 0;
|
|
||||||
|
|
||||||
// Replace code blocks with placeholders
|
|
||||||
const contentWithPlaceholders = processedContent.replace(
|
|
||||||
codeBlockRegex,
|
|
||||||
(match) => {
|
|
||||||
codeBlocks.push(match);
|
|
||||||
const placeholder = `__CODE_BLOCK_${codeBlockCounter++}__`;
|
|
||||||
return placeholder;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Split by double newlines
|
|
||||||
const paragraphs = contentWithPlaceholders
|
|
||||||
.split(/\n\n+/)
|
|
||||||
.filter((p) => p.trim());
|
|
||||||
|
|
||||||
// Restore code blocks
|
|
||||||
return paragraphs.map((p) => {
|
|
||||||
if (p.match(/__CODE_BLOCK_\d+__/)) {
|
|
||||||
return p.replace(/__CODE_BLOCK_\d+__/g, (match) => {
|
|
||||||
const index = parseInt(match.match(/\d+/)?.[0] || "0");
|
|
||||||
return codeBlocks[index] || match;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lazy-loaded paragraph component
|
|
||||||
function MarkdownParagraph({
|
|
||||||
content,
|
|
||||||
onLoad,
|
|
||||||
}: {
|
|
||||||
content: string;
|
|
||||||
onLoad?: () => void;
|
|
||||||
}) {
|
|
||||||
const [isLoaded, setIsLoaded] = useState(false);
|
|
||||||
const placeholderRef = useRef<HTMLDivElement>(null);
|
|
||||||
const [isVisible, setIsVisible] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let observer: IntersectionObserver;
|
|
||||||
if (placeholderRef.current) {
|
|
||||||
observer = new IntersectionObserver(
|
|
||||||
(entries) => {
|
|
||||||
if (entries[0].isIntersecting) {
|
|
||||||
setIsVisible(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ threshold: 0.1, rootMargin: "200px 0px" },
|
|
||||||
);
|
|
||||||
observer.observe(placeholderRef.current);
|
|
||||||
}
|
|
||||||
return () => observer?.disconnect();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isVisible && !isLoaded) {
|
|
||||||
setIsLoaded(true);
|
|
||||||
onLoad?.();
|
|
||||||
}
|
|
||||||
}, [isVisible, isLoaded, onLoad]);
|
|
||||||
|
|
||||||
// Generate preview content
|
|
||||||
const previewContent = useMemo(() => {
|
|
||||||
if (content.startsWith("```")) {
|
|
||||||
return "```" + (content.split("\n")[0] || "").slice(3) + "...```";
|
|
||||||
}
|
|
||||||
return content.length > 60 ? content.slice(0, 60) + "..." : content;
|
|
||||||
}, [content]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="markdown-paragraph" ref={placeholderRef}>
|
|
||||||
{!isLoaded ? (
|
|
||||||
<div className="markdown-paragraph-placeholder">{previewContent}</div>
|
|
||||||
) : (
|
|
||||||
<_MarkDownContent content={content} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Memoized paragraph component to prevent unnecessary re-renders
|
|
||||||
const MemoizedMarkdownParagraph = React.memo(
|
|
||||||
({ content }: { content: string }) => {
|
|
||||||
return <_MarkDownContent content={content} />;
|
|
||||||
},
|
|
||||||
(prevProps, nextProps) => prevProps.content === nextProps.content,
|
|
||||||
);
|
|
||||||
|
|
||||||
MemoizedMarkdownParagraph.displayName = "MemoizedMarkdownParagraph";
|
|
||||||
|
|
||||||
// Specialized component for streaming content
|
|
||||||
function StreamingMarkdownContent({ content }: { content: string }) {
|
|
||||||
const paragraphs = useMemo(
|
|
||||||
() => splitContentIntoParagraphs(content),
|
|
||||||
[content],
|
|
||||||
);
|
|
||||||
const lastParagraphRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="markdown-streaming-content">
|
|
||||||
{paragraphs.map((paragraph, index) => (
|
|
||||||
<div
|
|
||||||
key={`p-${index}-${paragraph.substring(0, 20)}`}
|
|
||||||
className="markdown-paragraph markdown-streaming-paragraph"
|
|
||||||
ref={index === paragraphs.length - 1 ? lastParagraphRef : null}
|
|
||||||
>
|
|
||||||
<MemoizedMarkdownParagraph content={paragraph} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _MarkDownContent(props: { content: string }) {
|
function _MarkDownContent(props: { content: string }) {
|
||||||
const escapedContent = useMemo(() => {
|
const escapedContent = useMemo(() => {
|
||||||
return tryWrapHtmlCode(escapeBrackets(props.content));
|
return tryWrapHtmlCode(escapeBrackets(props.content));
|
||||||
@@ -456,27 +326,9 @@ export function Markdown(
|
|||||||
fontFamily?: string;
|
fontFamily?: string;
|
||||||
parentRef?: RefObject<HTMLDivElement>;
|
parentRef?: RefObject<HTMLDivElement>;
|
||||||
defaultShow?: boolean;
|
defaultShow?: boolean;
|
||||||
immediatelyRender?: boolean;
|
|
||||||
streaming?: boolean; // Whether this is a streaming response
|
|
||||||
} & React.DOMAttributes<HTMLDivElement>,
|
} & React.DOMAttributes<HTMLDivElement>,
|
||||||
) {
|
) {
|
||||||
const mdRef = useRef<HTMLDivElement>(null);
|
const mdRef = useRef<HTMLDivElement>(null);
|
||||||
const paragraphs = useMemo(
|
|
||||||
() => splitContentIntoParagraphs(props.content),
|
|
||||||
[props.content],
|
|
||||||
);
|
|
||||||
const [loadedCount, setLoadedCount] = useState(0);
|
|
||||||
|
|
||||||
// Determine rendering strategy based on props
|
|
||||||
const shouldAsyncRender =
|
|
||||||
!props.immediatelyRender && !props.streaming && paragraphs.length > 1;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// Immediately render all paragraphs if specified
|
|
||||||
if (props.immediatelyRender) {
|
|
||||||
setLoadedCount(paragraphs.length);
|
|
||||||
}
|
|
||||||
}, [props.immediatelyRender, paragraphs.length]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -492,24 +344,6 @@ export function Markdown(
|
|||||||
>
|
>
|
||||||
{props.loading ? (
|
{props.loading ? (
|
||||||
<LoadingIcon />
|
<LoadingIcon />
|
||||||
) : props.streaming ? (
|
|
||||||
// Use specialized component for streaming content
|
|
||||||
<StreamingMarkdownContent content={props.content} />
|
|
||||||
) : shouldAsyncRender ? (
|
|
||||||
<div className="markdown-content">
|
|
||||||
{paragraphs.map((paragraph, index) => (
|
|
||||||
<MarkdownParagraph
|
|
||||||
key={index}
|
|
||||||
content={paragraph}
|
|
||||||
onLoad={() => setLoadedCount((prev) => prev + 1)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
{loadedCount < paragraphs.length && loadedCount > 0 && (
|
|
||||||
<div className="markdown-paragraph-loading">
|
|
||||||
<LoadingIcon />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
) : (
|
) : (
|
||||||
<MarkdownContent content={props.content} />
|
<MarkdownContent content={props.content} />
|
||||||
)}
|
)}
|
||||||
|
@@ -417,6 +417,14 @@ export const KnowledgeCutOffDate: Record<string, string> = {
|
|||||||
"gpt-4-turbo": "2023-12",
|
"gpt-4-turbo": "2023-12",
|
||||||
"gpt-4-turbo-2024-04-09": "2023-12",
|
"gpt-4-turbo-2024-04-09": "2023-12",
|
||||||
"gpt-4-turbo-preview": "2023-12",
|
"gpt-4-turbo-preview": "2023-12",
|
||||||
|
"gpt-4.1": "2024-06",
|
||||||
|
"gpt-4.1-2025-04-14": "2024-06",
|
||||||
|
"gpt-4.1-mini": "2024-06",
|
||||||
|
"gpt-4.1-mini-2025-04-14": "2024-06",
|
||||||
|
"gpt-4.1-nano": "2024-06",
|
||||||
|
"gpt-4.1-nano-2025-04-14": "2024-06",
|
||||||
|
"gpt-4.5-preview": "2023-10",
|
||||||
|
"gpt-4.5-preview-2025-02-27": "2023-10",
|
||||||
"gpt-4o": "2023-10",
|
"gpt-4o": "2023-10",
|
||||||
"gpt-4o-2024-05-13": "2023-10",
|
"gpt-4o-2024-05-13": "2023-10",
|
||||||
"gpt-4o-2024-08-06": "2023-10",
|
"gpt-4o-2024-08-06": "2023-10",
|
||||||
@@ -458,6 +466,7 @@ export const DEFAULT_TTS_VOICES = [
|
|||||||
export const VISION_MODEL_REGEXES = [
|
export const VISION_MODEL_REGEXES = [
|
||||||
/vision/,
|
/vision/,
|
||||||
/gpt-4o/,
|
/gpt-4o/,
|
||||||
|
/gpt-4\.1/,
|
||||||
/claude-3/,
|
/claude-3/,
|
||||||
/gemini-1\.5/,
|
/gemini-1\.5/,
|
||||||
/gemini-exp/,
|
/gemini-exp/,
|
||||||
@@ -469,6 +478,8 @@ export const VISION_MODEL_REGEXES = [
|
|||||||
/^dall-e-3$/, // Matches exactly "dall-e-3"
|
/^dall-e-3$/, // Matches exactly "dall-e-3"
|
||||||
/glm-4v/,
|
/glm-4v/,
|
||||||
/vl/i,
|
/vl/i,
|
||||||
|
/o3/,
|
||||||
|
/o4-mini/,
|
||||||
];
|
];
|
||||||
|
|
||||||
export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
|
export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
|
||||||
@@ -485,6 +496,14 @@ const openaiModels = [
|
|||||||
"gpt-4-32k-0613",
|
"gpt-4-32k-0613",
|
||||||
"gpt-4-turbo",
|
"gpt-4-turbo",
|
||||||
"gpt-4-turbo-preview",
|
"gpt-4-turbo-preview",
|
||||||
|
"gpt-4.1",
|
||||||
|
"gpt-4.1-2025-04-14",
|
||||||
|
"gpt-4.1-mini",
|
||||||
|
"gpt-4.1-mini-2025-04-14",
|
||||||
|
"gpt-4.1-nano",
|
||||||
|
"gpt-4.1-nano-2025-04-14",
|
||||||
|
"gpt-4.5-preview",
|
||||||
|
"gpt-4.5-preview-2025-02-27",
|
||||||
"gpt-4o",
|
"gpt-4o",
|
||||||
"gpt-4o-2024-05-13",
|
"gpt-4o-2024-05-13",
|
||||||
"gpt-4o-2024-08-06",
|
"gpt-4o-2024-08-06",
|
||||||
@@ -499,6 +518,8 @@ const openaiModels = [
|
|||||||
"o1-mini",
|
"o1-mini",
|
||||||
"o1-preview",
|
"o1-preview",
|
||||||
"o3-mini",
|
"o3-mini",
|
||||||
|
"o3",
|
||||||
|
"o4-mini",
|
||||||
];
|
];
|
||||||
|
|
||||||
const googleModels = [
|
const googleModels = [
|
||||||
@@ -525,6 +546,7 @@ const googleModels = [
|
|||||||
"gemini-2.0-flash-thinking-exp-01-21",
|
"gemini-2.0-flash-thinking-exp-01-21",
|
||||||
"gemini-2.0-pro-exp",
|
"gemini-2.0-pro-exp",
|
||||||
"gemini-2.0-pro-exp-02-05",
|
"gemini-2.0-pro-exp-02-05",
|
||||||
|
"gemini-2.5-pro-preview-06-05",
|
||||||
];
|
];
|
||||||
|
|
||||||
const anthropicModels = [
|
const anthropicModels = [
|
||||||
@@ -611,6 +633,18 @@ const xAIModes = [
|
|||||||
"grok-2-vision-1212",
|
"grok-2-vision-1212",
|
||||||
"grok-2-vision",
|
"grok-2-vision",
|
||||||
"grok-2-vision-latest",
|
"grok-2-vision-latest",
|
||||||
|
"grok-3-mini-fast-beta",
|
||||||
|
"grok-3-mini-fast",
|
||||||
|
"grok-3-mini-fast-latest",
|
||||||
|
"grok-3-mini-beta",
|
||||||
|
"grok-3-mini",
|
||||||
|
"grok-3-mini-latest",
|
||||||
|
"grok-3-fast-beta",
|
||||||
|
"grok-3-fast",
|
||||||
|
"grok-3-fast-latest",
|
||||||
|
"grok-3-beta",
|
||||||
|
"grok-3",
|
||||||
|
"grok-3-latest",
|
||||||
];
|
];
|
||||||
|
|
||||||
const chatglmModels = [
|
const chatglmModels = [
|
||||||
|
@@ -99,7 +99,6 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.light {
|
.light {
|
||||||
@@ -359,14 +358,8 @@
|
|||||||
.markdown-body kbd {
|
.markdown-body kbd {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 3px 5px;
|
padding: 3px 5px;
|
||||||
font:
|
font: 11px ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas,
|
||||||
11px ui-monospace,
|
Liberation Mono, monospace;
|
||||||
SFMono-Regular,
|
|
||||||
SF Mono,
|
|
||||||
Menlo,
|
|
||||||
Consolas,
|
|
||||||
Liberation Mono,
|
|
||||||
monospace;
|
|
||||||
line-height: 10px;
|
line-height: 10px;
|
||||||
color: var(--color-fg-default);
|
color: var(--color-fg-default);
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
@@ -455,28 +448,16 @@
|
|||||||
.markdown-body tt,
|
.markdown-body tt,
|
||||||
.markdown-body code,
|
.markdown-body code,
|
||||||
.markdown-body samp {
|
.markdown-body samp {
|
||||||
font-family:
|
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas,
|
||||||
ui-monospace,
|
Liberation Mono, monospace;
|
||||||
SFMono-Regular,
|
|
||||||
SF Mono,
|
|
||||||
Menlo,
|
|
||||||
Consolas,
|
|
||||||
Liberation Mono,
|
|
||||||
monospace;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-body pre {
|
.markdown-body pre {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-family:
|
font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas,
|
||||||
ui-monospace,
|
Liberation Mono, monospace;
|
||||||
SFMono-Regular,
|
|
||||||
SF Mono,
|
|
||||||
Menlo,
|
|
||||||
Consolas,
|
|
||||||
Liberation Mono,
|
|
||||||
monospace;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
}
|
}
|
||||||
@@ -1149,87 +1130,3 @@
|
|||||||
#dmermaid {
|
#dmermaid {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-content {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markdown-paragraph {
|
|
||||||
transition: opacity 0.3s ease;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
|
|
||||||
&.markdown-paragraph-visible {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.markdown-paragraph-hidden {
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.markdown-paragraph-placeholder {
|
|
||||||
padding: 8px;
|
|
||||||
color: var(--color-fg-subtle);
|
|
||||||
background-color: var(--color-canvas-subtle);
|
|
||||||
border-radius: 6px;
|
|
||||||
border-left: 3px solid var(--color-border-muted);
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
font-family: var(--font-family-sans);
|
|
||||||
font-size: 14px;
|
|
||||||
min-height: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markdown-paragraph-loading {
|
|
||||||
height: 20px;
|
|
||||||
background-color: var(--color-canvas-subtle);
|
|
||||||
border-radius: 6px;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 30%;
|
|
||||||
height: 100%;
|
|
||||||
background: linear-gradient(
|
|
||||||
90deg,
|
|
||||||
transparent,
|
|
||||||
rgba(255, 255, 255, 0.1),
|
|
||||||
transparent
|
|
||||||
);
|
|
||||||
animation: shimmer 1.5s infinite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes shimmer {
|
|
||||||
0% {
|
|
||||||
transform: translateX(-100%);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: translateX(200%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.markdown-streaming-content {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.markdown-streaming-paragraph {
|
|
||||||
opacity: 1;
|
|
||||||
animation: fadeIn 0.3s ease-in-out;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -66,8 +66,8 @@ export function collectModelTable(
|
|||||||
|
|
||||||
// default models
|
// default models
|
||||||
models.forEach((m) => {
|
models.forEach((m) => {
|
||||||
// using <modelName>@<providerId> as fullName
|
// using <modelName>@<providerType> as fullName
|
||||||
modelTable[`${m.name}@${m?.provider?.id}`] = {
|
modelTable[`${m.name}@${m?.provider?.providerType}`] = {
|
||||||
...m,
|
...m,
|
||||||
displayName: m.name, // 'provider' is copied over if it exists
|
displayName: m.name, // 'provider' is copied over if it exists
|
||||||
};
|
};
|
||||||
@@ -121,12 +121,14 @@ export function collectModelTable(
|
|||||||
if (displayName && provider.providerName == "ByteDance") {
|
if (displayName && provider.providerName == "ByteDance") {
|
||||||
[customModelName, displayName] = [displayName, customModelName];
|
[customModelName, displayName] = [displayName, customModelName];
|
||||||
}
|
}
|
||||||
modelTable[`${customModelName}@${provider?.id}`] = {
|
modelTable[`${customModelName}@${provider?.providerType}`] = {
|
||||||
name: customModelName,
|
name: customModelName,
|
||||||
displayName: displayName || customModelName,
|
displayName: displayName || customModelName,
|
||||||
available,
|
available,
|
||||||
provider, // Use optional chaining
|
provider, // Use optional chaining
|
||||||
sorted: CustomSeq.next(`${customModelName}@${provider?.id}`),
|
sorted: CustomSeq.next(
|
||||||
|
`${customModelName}@${provider?.providerType}`,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ describe("isModelNotavailableInServer", () => {
|
|||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: 这个测试用例有问题,需要修复
|
// FIXME: 这个测试用例有问题,需要修复 ???
|
||||||
// test("support passing multiple providers, model available on one of the providers will return false", () => {
|
// test("support passing multiple providers, model available on one of the providers will return false", () => {
|
||||||
// const customModels = "-all,gpt-4@google";
|
// const customModels = "-all,gpt-4@google";
|
||||||
// const modelName = "gpt-4";
|
// const modelName = "gpt-4";
|
||||||
@@ -69,7 +69,19 @@ describe("isModelNotavailableInServer", () => {
|
|||||||
test("test custom model without setting provider", () => {
|
test("test custom model without setting provider", () => {
|
||||||
const customModels = "-all,mistral-large";
|
const customModels = "-all,mistral-large";
|
||||||
const modelName = "mistral-large";
|
const modelName = "mistral-large";
|
||||||
const providerNames = modelName;
|
const providerNames = "custom";
|
||||||
|
const result = isModelNotavailableInServer(
|
||||||
|
customModels,
|
||||||
|
modelName,
|
||||||
|
providerNames,
|
||||||
|
);
|
||||||
|
expect(result).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("test custom model with non-standard provider", () => {
|
||||||
|
const customModels = "-all,deepseek-chat@DeepSeek";
|
||||||
|
const modelName = "deepseek-chat";
|
||||||
|
const providerNames = "custom";
|
||||||
const result = isModelNotavailableInServer(
|
const result = isModelNotavailableInServer(
|
||||||
customModels,
|
customModels,
|
||||||
modelName,
|
modelName,
|
||||||
|
Reference in New Issue
Block a user