正在显示
9 个修改的文件
包含
35 行增加
和
23 行删除
| @@ -30,7 +30,10 @@ export async function handle( | @@ -30,7 +30,10 @@ export async function handle( | ||
| 30 | req: NextRequest, | 30 | req: NextRequest, |
| 31 | { params }: { params: { path: string[] } }, | 31 | { params }: { params: { path: string[] } }, |
| 32 | ) { | 32 | ) { |
| 33 | - console.log("[OpenAI Route] params ", params); | 33 | + console.log( |
| 34 | + "************************************************[OpenAI Route] params ", | ||
| 35 | + params, | ||
| 36 | + ); | ||
| 34 | 37 | ||
| 35 | if (req.method === "OPTIONS") { | 38 | if (req.method === "OPTIONS") { |
| 36 | return NextResponse.json({ body: "OK" }, { status: 200 }); | 39 | return NextResponse.json({ body: "OK" }, { status: 200 }); |
| @@ -248,7 +248,7 @@ export class ChatGPTApi implements LLMApi { | @@ -248,7 +248,7 @@ export class ChatGPTApi implements LLMApi { | ||
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | - console.log("[Request] openai payload: ", requestPayload); | 251 | + console.log("****************[Request] openai payload: ", requestPayload); |
| 252 | 252 | ||
| 253 | const shouldStream = !isDalle3 && !!options.config.stream; | 253 | const shouldStream = !isDalle3 && !!options.config.stream; |
| 254 | const controller = new AbortController(); | 254 | const controller = new AbortController(); |
| @@ -4,7 +4,7 @@ import styles from "./bg-removal-panel.module.scss"; | @@ -4,7 +4,7 @@ import styles from "./bg-removal-panel.module.scss"; | ||
| 4 | import { useState } from "react"; | 4 | import { useState } from "react"; |
| 5 | import { message } from "antd"; | 5 | import { message } from "antd"; |
| 6 | import type { LocalData, PanelProps } from "@/app/types/zuotang"; | 6 | import type { LocalData, PanelProps } from "@/app/types/zuotang"; |
| 7 | -import { ApiPath, Path } from "@/app/constant"; | 7 | +import { ApiPath, bgremovalModel, Path } from "@/app/constant"; |
| 8 | import { useAccessStore } from "@/app/store"; | 8 | import { useAccessStore } from "@/app/store"; |
| 9 | import Locale from "@/app/locales"; | 9 | import Locale from "@/app/locales"; |
| 10 | import LoadingIcon from "@/app/icons/three-dots.svg"; | 10 | import LoadingIcon from "@/app/icons/three-dots.svg"; |
| @@ -13,7 +13,7 @@ import { useChatStore } from "@/app/store"; | @@ -13,7 +13,7 @@ import { useChatStore } from "@/app/store"; | ||
| 13 | import { getBgPrompt } from "@/app/utils/prompt"; | 13 | import { getBgPrompt } from "@/app/utils/prompt"; |
| 14 | import { cosUploadImage } from "@/app/utils/tencentCos"; | 14 | import { cosUploadImage } from "@/app/utils/tencentCos"; |
| 15 | import { getFileByUrl } from "@/app/utils/fileUtil"; | 15 | import { getFileByUrl } from "@/app/utils/fileUtil"; |
| 16 | - | 16 | +import { getServerSideConfig } from "@/app/config/server"; |
| 17 | // 错误消息映射函数 | 17 | // 错误消息映射函数 |
| 18 | const getErrorMessage = (state: number): string => { | 18 | const getErrorMessage = (state: number): string => { |
| 19 | const errorMap: { [key: number]: string } = { | 19 | const errorMap: { [key: number]: string } = { |
| @@ -440,7 +440,7 @@ export function BgPanel(props: PanelProps) { | @@ -440,7 +440,7 @@ export function BgPanel(props: PanelProps) { | ||
| 440 | } | 440 | } |
| 441 | const input = getBgPrompt(prompt); | 441 | const input = getBgPrompt(prompt); |
| 442 | setLoading(true); | 442 | setLoading(true); |
| 443 | - const response = await chatStore.directLlmInvoke(input, "gpt-4o-mini"); | 443 | + const response = await chatStore.directLlmInvoke(input, bgremovalModel); |
| 444 | const items = response.split("'").filter((item) => item.trim() !== ""); | 444 | const items = response.split("'").filter((item) => item.trim() !== ""); |
| 445 | setPromptList(items); | 445 | setPromptList(items); |
| 446 | } catch (error) { | 446 | } catch (error) { |
| @@ -519,6 +519,17 @@ export function BgPanel(props: PanelProps) { | @@ -519,6 +519,17 @@ export function BgPanel(props: PanelProps) { | ||
| 519 | onClick={() => handleProcessImage("visual/r-background")} | 519 | onClick={() => handleProcessImage("visual/r-background")} |
| 520 | disabled={isLoading} | 520 | disabled={isLoading} |
| 521 | /> | 521 | /> |
| 522 | + <IconButton | ||
| 523 | + text="测试" | ||
| 524 | + type="primary" | ||
| 525 | + shadow | ||
| 526 | + onClick={() => { | ||
| 527 | + const config = getServerSideConfig(); | ||
| 528 | + | ||
| 529 | + console.log("**********************************", bgremovalModel); | ||
| 530 | + }} | ||
| 531 | + disabled={isLoading} | ||
| 532 | + /> | ||
| 522 | </div> | 533 | </div> |
| 523 | </ControlParamItem> | 534 | </ControlParamItem> |
| 524 | </> | 535 | </> |
| @@ -7,6 +7,7 @@ import { useChatStore } from "@/app/store"; | @@ -7,6 +7,7 @@ import { useChatStore } from "@/app/store"; | ||
| 7 | import { type MindElixirData } from "mind-elixir"; | 7 | import { type MindElixirData } from "mind-elixir"; |
| 8 | import { message } from "antd"; | 8 | import { message } from "antd"; |
| 9 | import Locale from "@/app/locales"; | 9 | import Locale from "@/app/locales"; |
| 10 | +import { mindModel } from "@/app/constant"; | ||
| 10 | 11 | ||
| 11 | export interface MindPanelProps { | 12 | export interface MindPanelProps { |
| 12 | setData: React.Dispatch<React.SetStateAction<MindElixirData>>; | 13 | setData: React.Dispatch<React.SetStateAction<MindElixirData>>; |
| @@ -24,7 +25,7 @@ export function MindPanel(props: MindPanelProps) { | @@ -24,7 +25,7 @@ export function MindPanel(props: MindPanelProps) { | ||
| 24 | setIsLoading(true); | 25 | setIsLoading(true); |
| 25 | try { | 26 | try { |
| 26 | const prompt = getMindPrompt(inputValue, false); | 27 | const prompt = getMindPrompt(inputValue, false); |
| 27 | - const response = await chatStore.directLlmInvoke(prompt, "gpt-4o-mini"); | 28 | + const response = await chatStore.directLlmInvoke(prompt, mindModel); |
| 28 | const cleanedContent = response.replace(/^```json|```$/g, ""); | 29 | const cleanedContent = response.replace(/^```json|```$/g, ""); |
| 29 | const parsedData: MindElixirData = JSON.parse(cleanedContent); | 30 | const parsedData: MindElixirData = JSON.parse(cleanedContent); |
| 30 | setData(parsedData); | 31 | setData(parsedData); |
| @@ -11,7 +11,7 @@ import { WindowContent } from "@/app/components/home"; | @@ -11,7 +11,7 @@ import { WindowContent } from "@/app/components/home"; | ||
| 11 | import { useMobileScreen } from "@/app/utils"; | 11 | import { useMobileScreen } from "@/app/utils"; |
| 12 | import { IconButton } from "../button"; | 12 | import { IconButton } from "../button"; |
| 13 | import Locale from "@/app/locales"; | 13 | import Locale from "@/app/locales"; |
| 14 | -import { Path } from "@/app/constant"; | 14 | +import { mindModel, Path } from "@/app/constant"; |
| 15 | import { useNavigate, useLocation } from "react-router-dom"; | 15 | import { useNavigate, useLocation } from "react-router-dom"; |
| 16 | import clsx from "clsx"; | 16 | import clsx from "clsx"; |
| 17 | import { getClientConfig } from "@/app/config/client"; | 17 | import { getClientConfig } from "@/app/config/client"; |
| @@ -102,7 +102,7 @@ export function MindPage() { | @@ -102,7 +102,7 @@ export function MindPage() { | ||
| 102 | if (!content) return; | 102 | if (!content) return; |
| 103 | setIsLoading(true); | 103 | setIsLoading(true); |
| 104 | try { | 104 | try { |
| 105 | - const response = await chatStore.sendContext(newMessages, "gpt-4o-mini"); | 105 | + const response = await chatStore.sendContext(newMessages, mindModel); |
| 106 | const cleanedContent = response.replace(/^```json|```$/g, ""); | 106 | const cleanedContent = response.replace(/^```json|```$/g, ""); |
| 107 | const parsedData: MindElixirData = JSON.parse(cleanedContent); | 107 | const parsedData: MindElixirData = JSON.parse(cleanedContent); |
| 108 | // 增强校验逻辑 | 108 | // 增强校验逻辑 |
| @@ -19,6 +19,7 @@ import { | @@ -19,6 +19,7 @@ import { | ||
| 19 | writeMessage, | 19 | writeMessage, |
| 20 | WritePanelProps, | 20 | WritePanelProps, |
| 21 | } from "./menuData"; | 21 | } from "./menuData"; |
| 22 | +import { writeModel } from "@/app/constant"; | ||
| 22 | 23 | ||
| 23 | export function WritingPanel(props: WritePanelProps) { | 24 | export function WritingPanel(props: WritePanelProps) { |
| 24 | const { | 25 | const { |
| @@ -134,11 +135,8 @@ export function WritingPanel(props: WritePanelProps) { | @@ -134,11 +135,8 @@ export function WritingPanel(props: WritePanelProps) { | ||
| 134 | const input = getWrtingPrompt(param); | 135 | const input = getWrtingPrompt(param); |
| 135 | setLoading(true); | 136 | setLoading(true); |
| 136 | console.log("------------------------" + input); | 137 | console.log("------------------------" + input); |
| 137 | - | ||
| 138 | messages.push({ role: "user", content: input }); | 138 | messages.push({ role: "user", content: input }); |
| 139 | - | ||
| 140 | - const response = await chatStore.sendContext(messages, "gpt-4o-mini"); | ||
| 141 | - | 139 | + const response = await chatStore.sendContext(messages, writeModel); |
| 142 | messages.push({ role: "assistant", content: response }); | 140 | messages.push({ role: "assistant", content: response }); |
| 143 | 141 | ||
| 144 | let cleanedContent = response.startsWith("```html") | 142 | let cleanedContent = response.startsWith("```html") |
| @@ -8,7 +8,7 @@ import { WindowContent } from "@/app/components/home"; | @@ -8,7 +8,7 @@ import { WindowContent } from "@/app/components/home"; | ||
| 8 | import { useMobileScreen } from "@/app/utils"; | 8 | import { useMobileScreen } from "@/app/utils"; |
| 9 | import { IconButton } from "../button"; | 9 | import { IconButton } from "../button"; |
| 10 | import Locale from "@/app/locales"; | 10 | import Locale from "@/app/locales"; |
| 11 | -import { Path } from "@/app/constant"; | 11 | +import { Path, writeModel } from "@/app/constant"; |
| 12 | import { useLocation, useNavigate } from "react-router-dom"; | 12 | import { useLocation, useNavigate } from "react-router-dom"; |
| 13 | import { getClientConfig } from "@/app/config/client"; | 13 | import { getClientConfig } from "@/app/config/client"; |
| 14 | import React, { | 14 | import React, { |
| @@ -114,7 +114,7 @@ export function WritingPage() { | @@ -114,7 +114,7 @@ export function WritingPage() { | ||
| 114 | const input = getWrtingPrompt(param); | 114 | const input = getWrtingPrompt(param); |
| 115 | setLoading(true); | 115 | setLoading(true); |
| 116 | console.log("------------------------" + input); | 116 | console.log("------------------------" + input); |
| 117 | - const response = await chatStore.directLlmInvoke(input, "gpt-4o-mini"); | 117 | + const response = await chatStore.directLlmInvoke(input, writeModel); |
| 118 | let cleanedContent = response.startsWith("```html") | 118 | let cleanedContent = response.startsWith("```html") |
| 119 | ? response.substring(8) | 119 | ? response.substring(8) |
| 120 | : response; | 120 | : response; |
| @@ -260,7 +260,7 @@ export function WritingPage() { | @@ -260,7 +260,7 @@ export function WritingPage() { | ||
| 260 | try { | 260 | try { |
| 261 | setLoading(true); | 261 | setLoading(true); |
| 262 | messages.push({ role: "user", content: msg }); | 262 | messages.push({ role: "user", content: msg }); |
| 263 | - const response = await chatStore.sendContext(messages, "gpt-4o-mini"); | 263 | + const response = await chatStore.sendContext(messages, writeModel); |
| 264 | messages.push({ role: "assistant", content: response }); | 264 | messages.push({ role: "assistant", content: response }); |
| 265 | let cleanedContent = response.startsWith("```html") | 265 | let cleanedContent = response.startsWith("```html") |
| 266 | ? response.substring(8) | 266 | ? response.substring(8) |
| @@ -103,9 +103,6 @@ declare global { | @@ -103,9 +103,6 @@ declare global { | ||
| 103 | DOCMEE_API_KEY: string; | 103 | DOCMEE_API_KEY: string; |
| 104 | DOCMEE_MAX_DAILY_USES: number; | 104 | DOCMEE_MAX_DAILY_USES: number; |
| 105 | 105 | ||
| 106 | - NXET_PUBLIC_BGREMOVAL_MODEL: string; | ||
| 107 | - NXET_PUBLIC_WRITING_MODEL: string; | ||
| 108 | - | ||
| 109 | //腾讯云 | 106 | //腾讯云 |
| 110 | TENCENT_COS_SECRETKEY: string; | 107 | TENCENT_COS_SECRETKEY: string; |
| 111 | TENCENT_COS_SECRETID: string; | 108 | TENCENT_COS_SECRETID: string; |
| @@ -294,11 +291,6 @@ export const getServerSideConfig = () => { | @@ -294,11 +291,6 @@ export const getServerSideConfig = () => { | ||
| 294 | docmeeApiKey: process.env.DOCMEE_API_KEY ?? "", | 291 | docmeeApiKey: process.env.DOCMEE_API_KEY ?? "", |
| 295 | docmeeMaxDailyUses: process.env.DOCMEE_MAX_DAILY_USES, | 292 | docmeeMaxDailyUses: process.env.DOCMEE_MAX_DAILY_USES, |
| 296 | 293 | ||
| 297 | - //生成图片模型名称 | ||
| 298 | - bgRemovalModel: process.env.NXET_PUBLIC_BGREMOVAL_MODEL, | ||
| 299 | - //生成文章模型名称 | ||
| 300 | - writingModel: process.env.NXET_PUBLIC_WRITING_MODEL, | ||
| 301 | - | ||
| 302 | //腾讯云 | 294 | //腾讯云 |
| 303 | tencentCosSecretKey: process.env.TENCENT_COS_SECRETKEY, | 295 | tencentCosSecretKey: process.env.TENCENT_COS_SECRETKEY, |
| 304 | tencentCosSecretId: process.env.TENCENT_COS_SECRETID, | 296 | tencentCosSecretId: process.env.TENCENT_COS_SECRETID, |
| @@ -842,3 +842,10 @@ export const DEFAULT_GA_ID = "G-89WN60ZK2E"; | @@ -842,3 +842,10 @@ export const DEFAULT_GA_ID = "G-89WN60ZK2E"; | ||
| 842 | export const SAAS_CHAT_URL = "https://nextchat.club"; | 842 | export const SAAS_CHAT_URL = "https://nextchat.club"; |
| 843 | export const SAAS_CHAT_UTM_URL = "https://nextchat.club?utm=github"; | 843 | export const SAAS_CHAT_UTM_URL = "https://nextchat.club?utm=github"; |
| 844 | export const UPLOAD_FILE_MAX_LINE = 100; | 844 | export const UPLOAD_FILE_MAX_LINE = 100; |
| 845 | + | ||
| 846 | +//抠图页面模型 | ||
| 847 | +export const bgremovalModel = "gpt-4o-mini"; | ||
| 848 | +//生成文章页面模型 | ||
| 849 | +export const writeModel = "gpt-4o-mini"; | ||
| 850 | +//思维导图页面模型 | ||
| 851 | +export const mindModel = "gpt-4o-mini"; |
-
请 注册 或 登录 后发表评论