Skip to content

Commit de11112

Browse files
authored
Merge pull request ChatGPTNextWeb#4743 from ChatGPTNextWeb/revert-4710-chatGPT
Revert "Chat gpt"
2 parents 754acd7 + d89a12a commit de11112

38 files changed

+715
-658
lines changed

app/api/common.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,24 @@ export async function requestOpenai(req: NextRequest) {
112112
try {
113113
const res = await fetch(fetchUrl, fetchOptions);
114114

115-
// Extract the OpenAI-Organization header from the response
116-
const openaiOrganizationHeader = res.headers.get("OpenAI-Organization");
117-
118-
// Check if serverConfig.openaiOrgId is defined and not an empty string
119-
if (serverConfig.openaiOrgId && serverConfig.openaiOrgId.trim() !== "") {
120-
// If openaiOrganizationHeader is present, log it; otherwise, log that the header is not present
121-
console.log("[Org ID]", openaiOrganizationHeader);
122-
} else {
123-
console.log("[Org ID] is not set up.");
124-
}
115+
// Extract the OpenAI-Organization header from the response
116+
const openaiOrganizationHeader = res.headers.get("OpenAI-Organization");
117+
118+
// Check if serverConfig.openaiOrgId is defined and not an empty string
119+
if (serverConfig.openaiOrgId && serverConfig.openaiOrgId.trim() !== "") {
120+
// If openaiOrganizationHeader is present, log it; otherwise, log that the header is not present
121+
console.log("[Org ID]", openaiOrganizationHeader);
122+
} else {
123+
console.log("[Org ID] is not set up.");
124+
}
125125

126126
// to prevent browser prompt for credentials
127127
const newHeaders = new Headers(res.headers);
128128
newHeaders.delete("www-authenticate");
129129
// to disable nginx buffering
130130
newHeaders.set("X-Accel-Buffering", "no");
131131

132+
132133
// Conditionally delete the OpenAI-Organization header from the response if [Org ID] is undefined or empty (not setup in ENV)
133134
// Also, this is to prevent the header from being sent to the client
134135
if (!serverConfig.openaiOrgId || serverConfig.openaiOrgId.trim() === "") {
@@ -141,6 +142,7 @@ export async function requestOpenai(req: NextRequest) {
141142
// The browser will try to decode the response with brotli and fail
142143
newHeaders.delete("content-encoding");
143144

145+
144146
return new Response(res.body, {
145147
status: res.status,
146148
statusText: res.statusText,

app/client/platforms/google.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ export class GeminiProApi implements LLMApi {
120120

121121
if (!baseUrl) {
122122
baseUrl = isApp
123-
? DEFAULT_API_HOST +
124-
"/api/proxy/google/" +
125-
Google.ChatPath(modelConfig.model)
123+
? DEFAULT_API_HOST + "/api/proxy/google/" + Google.ChatPath(modelConfig.model)
126124
: this.path(Google.ChatPath(modelConfig.model));
127125
}
128126

@@ -141,7 +139,7 @@ export class GeminiProApi implements LLMApi {
141139
() => controller.abort(),
142140
REQUEST_TIMEOUT_MS,
143141
);
144-
142+
145143
if (shouldStream) {
146144
let responseText = "";
147145
let remainText = "";

app/components/auth.tsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,33 @@ export function AuthPage() {
5050
);
5151
}}
5252
/>
53-
{/*{!accessStore.hideUserApiKey ? (*/}
54-
{/* <>*/}
55-
{/* <div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>*/}
56-
{/* <input*/}
57-
{/* className={styles["auth-input"]}*/}
58-
{/* type="password"*/}
59-
{/* placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}*/}
60-
{/* value={accessStore.openaiApiKey}*/}
61-
{/* onChange={(e) => {*/}
62-
{/* accessStore.update(*/}
63-
{/* (access) => (access.openaiApiKey = e.currentTarget.value),*/}
64-
{/* );*/}
65-
{/* }}*/}
66-
{/* />*/}
67-
{/* <input*/}
68-
{/* className={styles["auth-input"]}*/}
69-
{/* type="password"*/}
70-
{/* placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}*/}
71-
{/* value={accessStore.googleApiKey}*/}
72-
{/* onChange={(e) => {*/}
73-
{/* accessStore.update(*/}
74-
{/* (access) => (access.googleApiKey = e.currentTarget.value),*/}
75-
{/* );*/}
76-
{/* }}*/}
77-
{/* />*/}
78-
{/* </>*/}
79-
{/*) : null}*/}
53+
{!accessStore.hideUserApiKey ? (
54+
<>
55+
<div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>
56+
<input
57+
className={styles["auth-input"]}
58+
type="password"
59+
placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}
60+
value={accessStore.openaiApiKey}
61+
onChange={(e) => {
62+
accessStore.update(
63+
(access) => (access.openaiApiKey = e.currentTarget.value),
64+
);
65+
}}
66+
/>
67+
<input
68+
className={styles["auth-input"]}
69+
type="password"
70+
placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}
71+
value={accessStore.googleApiKey}
72+
onChange={(e) => {
73+
accessStore.update(
74+
(access) => (access.googleApiKey = e.currentTarget.value),
75+
);
76+
}}
77+
/>
78+
</>
79+
) : null}
8080

8181
<div className={styles["auth-actions"]}>
8282
<IconButton

app/components/chat.tsx

Lines changed: 93 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -491,79 +491,79 @@ export function ChatActions(props: {
491491

492492
return (
493493
<div className={styles["chat-input-actions"]}>
494-
{/*{couldStop && (*/}
495-
{/* <ChatAction*/}
496-
{/* onClick={stopAll}*/}
497-
{/* text={Locale.Chat.InputActions.Stop}*/}
498-
{/* icon={<StopIcon />}*/}
499-
{/* />*/}
500-
{/*)}*/}
501-
{/*{!props.hitBottom && (*/}
502-
{/* <ChatAction*/}
503-
{/* onClick={props.scrollToBottom}*/}
504-
{/* text={Locale.Chat.InputActions.ToBottom}*/}
505-
{/* icon={<BottomIcon />}*/}
506-
{/* />*/}
507-
{/*)}*/}
508-
{/*{props.hitBottom && (*/}
509-
{/* <ChatAction*/}
510-
{/* onClick={props.showPromptModal}*/}
511-
{/* text={Locale.Chat.InputActions.Settings}*/}
512-
{/* icon={<SettingsIcon />}*/}
513-
{/* />*/}
514-
{/*)}*/}
515-
516-
{/*{showUploadImage && (*/}
517-
{/* <ChatAction*/}
518-
{/* onClick={props.uploadImage}*/}
519-
{/* text={Locale.Chat.InputActions.UploadImage}*/}
520-
{/* icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}*/}
521-
{/* />*/}
522-
{/*)}*/}
523-
{/*<ChatAction*/}
524-
{/* onClick={nextTheme}*/}
525-
{/* text={Locale.Chat.InputActions.Theme[theme]}*/}
526-
{/* icon={*/}
527-
{/* <>*/}
528-
{/* {theme === Theme.Auto ? (*/}
529-
{/* <AutoIcon />*/}
530-
{/* ) : theme === Theme.Light ? (*/}
531-
{/* <LightIcon />*/}
532-
{/* ) : theme === Theme.Dark ? (*/}
533-
{/* <DarkIcon />*/}
534-
{/* ) : null}*/}
535-
{/* </>*/}
536-
{/* }*/}
537-
{/*/>*/}
538-
539-
{/*<ChatAction*/}
540-
{/* onClick={props.showPromptHints}*/}
541-
{/* text={Locale.Chat.InputActions.Prompt}*/}
542-
{/* icon={<PromptIcon />}*/}
543-
{/*/>*/}
544-
545-
{/*<ChatAction*/}
546-
{/* onClick={() => {*/}
547-
{/* navigate(Path.Masks);*/}
548-
{/* }}*/}
549-
{/* text={Locale.Chat.InputActions.Masks}*/}
550-
{/* icon={<MaskIcon />}*/}
551-
{/*/>*/}
552-
553-
{/*<ChatAction*/}
554-
{/* text={Locale.Chat.InputActions.Clear}*/}
555-
{/* icon={<BreakIcon />}*/}
556-
{/* onClick={() => {*/}
557-
{/* chatStore.updateCurrentSession((session) => {*/}
558-
{/* if (session.clearContextIndex === session.messages.length) {*/}
559-
{/* session.clearContextIndex = undefined;*/}
560-
{/* } else {*/}
561-
{/* session.clearContextIndex = session.messages.length;*/}
562-
{/* session.memoryPrompt = ""; // will clear memory*/}
563-
{/* }*/}
564-
{/* });*/}
565-
{/* }}*/}
566-
{/*/>*/}
494+
{couldStop && (
495+
<ChatAction
496+
onClick={stopAll}
497+
text={Locale.Chat.InputActions.Stop}
498+
icon={<StopIcon />}
499+
/>
500+
)}
501+
{!props.hitBottom && (
502+
<ChatAction
503+
onClick={props.scrollToBottom}
504+
text={Locale.Chat.InputActions.ToBottom}
505+
icon={<BottomIcon />}
506+
/>
507+
)}
508+
{props.hitBottom && (
509+
<ChatAction
510+
onClick={props.showPromptModal}
511+
text={Locale.Chat.InputActions.Settings}
512+
icon={<SettingsIcon />}
513+
/>
514+
)}
515+
516+
{showUploadImage && (
517+
<ChatAction
518+
onClick={props.uploadImage}
519+
text={Locale.Chat.InputActions.UploadImage}
520+
icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}
521+
/>
522+
)}
523+
<ChatAction
524+
onClick={nextTheme}
525+
text={Locale.Chat.InputActions.Theme[theme]}
526+
icon={
527+
<>
528+
{theme === Theme.Auto ? (
529+
<AutoIcon />
530+
) : theme === Theme.Light ? (
531+
<LightIcon />
532+
) : theme === Theme.Dark ? (
533+
<DarkIcon />
534+
) : null}
535+
</>
536+
}
537+
/>
538+
539+
<ChatAction
540+
onClick={props.showPromptHints}
541+
text={Locale.Chat.InputActions.Prompt}
542+
icon={<PromptIcon />}
543+
/>
544+
545+
<ChatAction
546+
onClick={() => {
547+
navigate(Path.Masks);
548+
}}
549+
text={Locale.Chat.InputActions.Masks}
550+
icon={<MaskIcon />}
551+
/>
552+
553+
<ChatAction
554+
text={Locale.Chat.InputActions.Clear}
555+
icon={<BreakIcon />}
556+
onClick={() => {
557+
chatStore.updateCurrentSession((session) => {
558+
if (session.clearContextIndex === session.messages.length) {
559+
session.clearContextIndex = undefined;
560+
} else {
561+
session.clearContextIndex = session.messages.length;
562+
session.memoryPrompt = ""; // will clear memory
563+
}
564+
});
565+
}}
566+
/>
567567

568568
<ChatAction
569569
onClick={() => setShowModelSelector(true)}
@@ -1089,6 +1089,7 @@ function _Chat() {
10891089
if (payload.url) {
10901090
accessStore.update((access) => (access.openaiUrl = payload.url!));
10911091
}
1092+
accessStore.update((access) => (access.useCustomConfig = true));
10921093
});
10931094
}
10941095
} catch {
@@ -1233,25 +1234,25 @@ function _Chat() {
12331234
</div>
12341235
</div>
12351236
<div className="window-actions">
1236-
{/*{!isMobileScreen && (*/}
1237-
{/* <div className="window-action-button">*/}
1238-
{/* <IconButton*/}
1239-
{/* icon={<RenameIcon />}*/}
1240-
{/* bordered*/}
1241-
{/* onClick={() => setIsEditingMessage(true)}*/}
1242-
{/* />*/}
1243-
{/* </div>*/}
1244-
{/*)}*/}
1245-
{/*<div className="window-action-button">*/}
1246-
{/* <IconButton*/}
1247-
{/* icon={<ExportIcon />}*/}
1248-
{/* bordered*/}
1249-
{/* title={Locale.Chat.Actions.Export}*/}
1250-
{/* onClick={() => {*/}
1251-
{/* setShowExport(true);*/}
1252-
{/* }}*/}
1253-
{/* />*/}
1254-
{/*</div>*/}
1237+
{!isMobileScreen && (
1238+
<div className="window-action-button">
1239+
<IconButton
1240+
icon={<RenameIcon />}
1241+
bordered
1242+
onClick={() => setIsEditingMessage(true)}
1243+
/>
1244+
</div>
1245+
)}
1246+
<div className="window-action-button">
1247+
<IconButton
1248+
icon={<ExportIcon />}
1249+
bordered
1250+
title={Locale.Chat.Actions.Export}
1251+
onClick={() => {
1252+
setShowExport(true);
1253+
}}
1254+
/>
1255+
</div>
12551256
{showMaxIcon && (
12561257
<div className="window-action-button">
12571258
<IconButton

0 commit comments

Comments
 (0)