Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#4743 from ChatGPTNextWeb/revert-471…
Browse files Browse the repository at this point in the history
…0-chatGPT

Revert "Chat gpt"
  • Loading branch information
Dean-YZG authored May 20, 2024
2 parents 754acd7 + d89a12a commit de11112
Show file tree
Hide file tree
Showing 38 changed files with 715 additions and 658 deletions.
22 changes: 12 additions & 10 deletions app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,24 @@ export async function requestOpenai(req: NextRequest) {
try {
const res = await fetch(fetchUrl, fetchOptions);

// Extract the OpenAI-Organization header from the response
const openaiOrganizationHeader = res.headers.get("OpenAI-Organization");

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

// Check if serverConfig.openaiOrgId is defined and not an empty string
if (serverConfig.openaiOrgId && serverConfig.openaiOrgId.trim() !== "") {
// If openaiOrganizationHeader is present, log it; otherwise, log that the header is not present
console.log("[Org ID]", openaiOrganizationHeader);
} else {
console.log("[Org ID] is not set up.");
}

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


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


return new Response(res.body, {
status: res.status,
statusText: res.statusText,
Expand Down
6 changes: 2 additions & 4 deletions app/client/platforms/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ export class GeminiProApi implements LLMApi {

if (!baseUrl) {
baseUrl = isApp
? DEFAULT_API_HOST +
"/api/proxy/google/" +
Google.ChatPath(modelConfig.model)
? DEFAULT_API_HOST + "/api/proxy/google/" + Google.ChatPath(modelConfig.model)
: this.path(Google.ChatPath(modelConfig.model));
}

Expand All @@ -141,7 +139,7 @@ export class GeminiProApi implements LLMApi {
() => controller.abort(),
REQUEST_TIMEOUT_MS,
);

if (shouldStream) {
let responseText = "";
let remainText = "";
Expand Down
54 changes: 27 additions & 27 deletions app/components/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,33 @@ export function AuthPage() {
);
}}
/>
{/*{!accessStore.hideUserApiKey ? (*/}
{/* <>*/}
{/* <div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>*/}
{/* <input*/}
{/* className={styles["auth-input"]}*/}
{/* type="password"*/}
{/* placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}*/}
{/* value={accessStore.openaiApiKey}*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) => (access.openaiApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* <input*/}
{/* className={styles["auth-input"]}*/}
{/* type="password"*/}
{/* placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}*/}
{/* value={accessStore.googleApiKey}*/}
{/* onChange={(e) => {*/}
{/* accessStore.update(*/}
{/* (access) => (access.googleApiKey = e.currentTarget.value),*/}
{/* );*/}
{/* }}*/}
{/* />*/}
{/* </>*/}
{/*) : null}*/}
{!accessStore.hideUserApiKey ? (
<>
<div className={styles["auth-tips"]}>{Locale.Auth.SubTips}</div>
<input
className={styles["auth-input"]}
type="password"
placeholder={Locale.Settings.Access.OpenAI.ApiKey.Placeholder}
value={accessStore.openaiApiKey}
onChange={(e) => {
accessStore.update(
(access) => (access.openaiApiKey = e.currentTarget.value),
);
}}
/>
<input
className={styles["auth-input"]}
type="password"
placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}
value={accessStore.googleApiKey}
onChange={(e) => {
accessStore.update(
(access) => (access.googleApiKey = e.currentTarget.value),
);
}}
/>
</>
) : null}

<div className={styles["auth-actions"]}>
<IconButton
Expand Down
185 changes: 93 additions & 92 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,79 +491,79 @@ export function ChatActions(props: {

return (
<div className={styles["chat-input-actions"]}>
{/*{couldStop && (*/}
{/* <ChatAction*/}
{/* onClick={stopAll}*/}
{/* text={Locale.Chat.InputActions.Stop}*/}
{/* icon={<StopIcon />}*/}
{/* />*/}
{/*)}*/}
{/*{!props.hitBottom && (*/}
{/* <ChatAction*/}
{/* onClick={props.scrollToBottom}*/}
{/* text={Locale.Chat.InputActions.ToBottom}*/}
{/* icon={<BottomIcon />}*/}
{/* />*/}
{/*)}*/}
{/*{props.hitBottom && (*/}
{/* <ChatAction*/}
{/* onClick={props.showPromptModal}*/}
{/* text={Locale.Chat.InputActions.Settings}*/}
{/* icon={<SettingsIcon />}*/}
{/* />*/}
{/*)}*/}

{/*{showUploadImage && (*/}
{/* <ChatAction*/}
{/* onClick={props.uploadImage}*/}
{/* text={Locale.Chat.InputActions.UploadImage}*/}
{/* icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}*/}
{/* />*/}
{/*)}*/}
{/*<ChatAction*/}
{/* onClick={nextTheme}*/}
{/* text={Locale.Chat.InputActions.Theme[theme]}*/}
{/* icon={*/}
{/* <>*/}
{/* {theme === Theme.Auto ? (*/}
{/* <AutoIcon />*/}
{/* ) : theme === Theme.Light ? (*/}
{/* <LightIcon />*/}
{/* ) : theme === Theme.Dark ? (*/}
{/* <DarkIcon />*/}
{/* ) : null}*/}
{/* </>*/}
{/* }*/}
{/*/>*/}

{/*<ChatAction*/}
{/* onClick={props.showPromptHints}*/}
{/* text={Locale.Chat.InputActions.Prompt}*/}
{/* icon={<PromptIcon />}*/}
{/*/>*/}

{/*<ChatAction*/}
{/* onClick={() => {*/}
{/* navigate(Path.Masks);*/}
{/* }}*/}
{/* text={Locale.Chat.InputActions.Masks}*/}
{/* icon={<MaskIcon />}*/}
{/*/>*/}

{/*<ChatAction*/}
{/* text={Locale.Chat.InputActions.Clear}*/}
{/* icon={<BreakIcon />}*/}
{/* onClick={() => {*/}
{/* chatStore.updateCurrentSession((session) => {*/}
{/* if (session.clearContextIndex === session.messages.length) {*/}
{/* session.clearContextIndex = undefined;*/}
{/* } else {*/}
{/* session.clearContextIndex = session.messages.length;*/}
{/* session.memoryPrompt = ""; // will clear memory*/}
{/* }*/}
{/* });*/}
{/* }}*/}
{/*/>*/}
{couldStop && (
<ChatAction
onClick={stopAll}
text={Locale.Chat.InputActions.Stop}
icon={<StopIcon />}
/>
)}
{!props.hitBottom && (
<ChatAction
onClick={props.scrollToBottom}
text={Locale.Chat.InputActions.ToBottom}
icon={<BottomIcon />}
/>
)}
{props.hitBottom && (
<ChatAction
onClick={props.showPromptModal}
text={Locale.Chat.InputActions.Settings}
icon={<SettingsIcon />}
/>
)}

{showUploadImage && (
<ChatAction
onClick={props.uploadImage}
text={Locale.Chat.InputActions.UploadImage}
icon={props.uploading ? <LoadingButtonIcon /> : <ImageIcon />}
/>
)}
<ChatAction
onClick={nextTheme}
text={Locale.Chat.InputActions.Theme[theme]}
icon={
<>
{theme === Theme.Auto ? (
<AutoIcon />
) : theme === Theme.Light ? (
<LightIcon />
) : theme === Theme.Dark ? (
<DarkIcon />
) : null}
</>
}
/>

<ChatAction
onClick={props.showPromptHints}
text={Locale.Chat.InputActions.Prompt}
icon={<PromptIcon />}
/>

<ChatAction
onClick={() => {
navigate(Path.Masks);
}}
text={Locale.Chat.InputActions.Masks}
icon={<MaskIcon />}
/>

<ChatAction
text={Locale.Chat.InputActions.Clear}
icon={<BreakIcon />}
onClick={() => {
chatStore.updateCurrentSession((session) => {
if (session.clearContextIndex === session.messages.length) {
session.clearContextIndex = undefined;
} else {
session.clearContextIndex = session.messages.length;
session.memoryPrompt = ""; // will clear memory
}
});
}}
/>

<ChatAction
onClick={() => setShowModelSelector(true)}
Expand Down Expand Up @@ -1089,6 +1089,7 @@ function _Chat() {
if (payload.url) {
accessStore.update((access) => (access.openaiUrl = payload.url!));
}
accessStore.update((access) => (access.useCustomConfig = true));
});
}
} catch {
Expand Down Expand Up @@ -1233,25 +1234,25 @@ function _Chat() {
</div>
</div>
<div className="window-actions">
{/*{!isMobileScreen && (*/}
{/* <div className="window-action-button">*/}
{/* <IconButton*/}
{/* icon={<RenameIcon />}*/}
{/* bordered*/}
{/* onClick={() => setIsEditingMessage(true)}*/}
{/* />*/}
{/* </div>*/}
{/*)}*/}
{/*<div className="window-action-button">*/}
{/* <IconButton*/}
{/* icon={<ExportIcon />}*/}
{/* bordered*/}
{/* title={Locale.Chat.Actions.Export}*/}
{/* onClick={() => {*/}
{/* setShowExport(true);*/}
{/* }}*/}
{/* />*/}
{/*</div>*/}
{!isMobileScreen && (
<div className="window-action-button">
<IconButton
icon={<RenameIcon />}
bordered
onClick={() => setIsEditingMessage(true)}
/>
</div>
)}
<div className="window-action-button">
<IconButton
icon={<ExportIcon />}
bordered
title={Locale.Chat.Actions.Export}
onClick={() => {
setShowExport(true);
}}
/>
</div>
{showMaxIcon && (
<div className="window-action-button">
<IconButton
Expand Down
Loading

0 comments on commit de11112

Please sign in to comment.