作者 202304001

页面模型名称抽取

... ... @@ -30,7 +30,10 @@ export async function handle(
req: NextRequest,
{ params }: { params: { path: string[] } },
) {
console.log("[OpenAI Route] params ", params);
console.log(
"************************************************[OpenAI Route] params ",
params,
);
if (req.method === "OPTIONS") {
return NextResponse.json({ body: "OK" }, { status: 200 });
... ...
... ... @@ -248,7 +248,7 @@ export class ChatGPTApi implements LLMApi {
}
}
console.log("[Request] openai payload: ", requestPayload);
console.log("****************[Request] openai payload: ", requestPayload);
const shouldStream = !isDalle3 && !!options.config.stream;
const controller = new AbortController();
... ...
... ... @@ -4,7 +4,7 @@ import styles from "./bg-removal-panel.module.scss";
import { useState } from "react";
import { message } from "antd";
import type { LocalData, PanelProps } from "@/app/types/zuotang";
import { ApiPath, Path } from "@/app/constant";
import { ApiPath, bgremovalModel, Path } from "@/app/constant";
import { useAccessStore } from "@/app/store";
import Locale from "@/app/locales";
import LoadingIcon from "@/app/icons/three-dots.svg";
... ... @@ -13,7 +13,7 @@ import { useChatStore } from "@/app/store";
import { getBgPrompt } from "@/app/utils/prompt";
import { cosUploadImage } from "@/app/utils/tencentCos";
import { getFileByUrl } from "@/app/utils/fileUtil";
import { getServerSideConfig } from "@/app/config/server";
// 错误消息映射函数
const getErrorMessage = (state: number): string => {
const errorMap: { [key: number]: string } = {
... ... @@ -440,7 +440,7 @@ export function BgPanel(props: PanelProps) {
}
const input = getBgPrompt(prompt);
setLoading(true);
const response = await chatStore.directLlmInvoke(input, "gpt-4o-mini");
const response = await chatStore.directLlmInvoke(input, bgremovalModel);
const items = response.split("'").filter((item) => item.trim() !== "");
setPromptList(items);
} catch (error) {
... ... @@ -519,6 +519,17 @@ export function BgPanel(props: PanelProps) {
onClick={() => handleProcessImage("visual/r-background")}
disabled={isLoading}
/>
<IconButton
text="测试"
type="primary"
shadow
onClick={() => {
const config = getServerSideConfig();
console.log("**********************************", bgremovalModel);
}}
disabled={isLoading}
/>
</div>
</ControlParamItem>
</>
... ...
... ... @@ -7,6 +7,7 @@ import { useChatStore } from "@/app/store";
import { type MindElixirData } from "mind-elixir";
import { message } from "antd";
import Locale from "@/app/locales";
import { mindModel } from "@/app/constant";
export interface MindPanelProps {
setData: React.Dispatch<React.SetStateAction<MindElixirData>>;
... ... @@ -24,7 +25,7 @@ export function MindPanel(props: MindPanelProps) {
setIsLoading(true);
try {
const prompt = getMindPrompt(inputValue, false);
const response = await chatStore.directLlmInvoke(prompt, "gpt-4o-mini");
const response = await chatStore.directLlmInvoke(prompt, mindModel);
const cleanedContent = response.replace(/^```json|```$/g, "");
const parsedData: MindElixirData = JSON.parse(cleanedContent);
setData(parsedData);
... ...
... ... @@ -11,7 +11,7 @@ import { WindowContent } from "@/app/components/home";
import { useMobileScreen } from "@/app/utils";
import { IconButton } from "../button";
import Locale from "@/app/locales";
import { Path } from "@/app/constant";
import { mindModel, Path } from "@/app/constant";
import { useNavigate, useLocation } from "react-router-dom";
import clsx from "clsx";
import { getClientConfig } from "@/app/config/client";
... ... @@ -102,7 +102,7 @@ export function MindPage() {
if (!content) return;
setIsLoading(true);
try {
const response = await chatStore.sendContext(newMessages, "gpt-4o-mini");
const response = await chatStore.sendContext(newMessages, mindModel);
const cleanedContent = response.replace(/^```json|```$/g, "");
const parsedData: MindElixirData = JSON.parse(cleanedContent);
// 增强校验逻辑
... ...
... ... @@ -19,6 +19,7 @@ import {
writeMessage,
WritePanelProps,
} from "./menuData";
import { writeModel } from "@/app/constant";
export function WritingPanel(props: WritePanelProps) {
const {
... ... @@ -134,11 +135,8 @@ export function WritingPanel(props: WritePanelProps) {
const input = getWrtingPrompt(param);
setLoading(true);
console.log("------------------------" + input);
messages.push({ role: "user", content: input });
const response = await chatStore.sendContext(messages, "gpt-4o-mini");
const response = await chatStore.sendContext(messages, writeModel);
messages.push({ role: "assistant", content: response });
let cleanedContent = response.startsWith("```html")
... ...
... ... @@ -8,7 +8,7 @@ import { WindowContent } from "@/app/components/home";
import { useMobileScreen } from "@/app/utils";
import { IconButton } from "../button";
import Locale from "@/app/locales";
import { Path } from "@/app/constant";
import { Path, writeModel } from "@/app/constant";
import { useLocation, useNavigate } from "react-router-dom";
import { getClientConfig } from "@/app/config/client";
import React, {
... ... @@ -114,7 +114,7 @@ export function WritingPage() {
const input = getWrtingPrompt(param);
setLoading(true);
console.log("------------------------" + input);
const response = await chatStore.directLlmInvoke(input, "gpt-4o-mini");
const response = await chatStore.directLlmInvoke(input, writeModel);
let cleanedContent = response.startsWith("```html")
? response.substring(8)
: response;
... ... @@ -260,7 +260,7 @@ export function WritingPage() {
try {
setLoading(true);
messages.push({ role: "user", content: msg });
const response = await chatStore.sendContext(messages, "gpt-4o-mini");
const response = await chatStore.sendContext(messages, writeModel);
messages.push({ role: "assistant", content: response });
let cleanedContent = response.startsWith("```html")
? response.substring(8)
... ...
... ... @@ -103,9 +103,6 @@ declare global {
DOCMEE_API_KEY: string;
DOCMEE_MAX_DAILY_USES: number;
NXET_PUBLIC_BGREMOVAL_MODEL: string;
NXET_PUBLIC_WRITING_MODEL: string;
//腾讯云
TENCENT_COS_SECRETKEY: string;
TENCENT_COS_SECRETID: string;
... ... @@ -294,11 +291,6 @@ export const getServerSideConfig = () => {
docmeeApiKey: process.env.DOCMEE_API_KEY ?? "",
docmeeMaxDailyUses: process.env.DOCMEE_MAX_DAILY_USES,
//生成图片模型名称
bgRemovalModel: process.env.NXET_PUBLIC_BGREMOVAL_MODEL,
//生成文章模型名称
writingModel: process.env.NXET_PUBLIC_WRITING_MODEL,
//腾讯云
tencentCosSecretKey: process.env.TENCENT_COS_SECRETKEY,
tencentCosSecretId: process.env.TENCENT_COS_SECRETID,
... ...
... ... @@ -842,3 +842,10 @@ export const DEFAULT_GA_ID = "G-89WN60ZK2E";
export const SAAS_CHAT_URL = "https://nextchat.club";
export const SAAS_CHAT_UTM_URL = "https://nextchat.club?utm=github";
export const UPLOAD_FILE_MAX_LINE = 100;
//抠图页面模型
export const bgremovalModel = "gpt-4o-mini";
//生成文章页面模型
export const writeModel = "gpt-4o-mini";
//思维导图页面模型
export const mindModel = "gpt-4o-mini";
... ...