Explorar o código

Merge branch 'master' of https://git.zyuas.com/LLM/chat

S0025136190 hai 1 ano
pai
achega
8fd8309ba1
Modificáronse 4 ficheiros con 106 adicións e 38 borrados
  1. 19 4
      app/components/chat.tsx
  2. 82 29
      app/components/home.tsx
  3. 4 4
      app/store/config.ts
  4. 1 1
      app/styles/globals.scss

+ 19 - 4
app/components/chat.tsx

@@ -175,8 +175,11 @@ export function SessionConfigModel(props: { onClose: () => void }) {
 }
 
 // 提示词
-const CallWord = (props: { setUserInput: (value: string) => void }) => {
-  const { setUserInput } = props
+const CallWord = (props: {
+  setUserInput: (value: string) => void,
+  doSubmit: (userInput: string) => void,
+}) => {
+  const { setUserInput, doSubmit } = props
   const list = [
     {
       title: '信息公布',
@@ -224,7 +227,14 @@ const CallWord = (props: { setUserInput: (value: string) => void }) => {
               fontSize: 12
             }}
             onClick={() => {
-              setUserInput(item.text)
+              const plan: string = '2';
+              if (plan === '1') {
+                // 方案1.点击后出现在输入框内,用户自己点击发送
+                setUserInput(item.text);
+              } else {
+                // 方案2.点击后直接发送
+                doSubmit(item.text)
+              }
             }}
           >
             {item.title}
@@ -488,6 +498,7 @@ function useScrollToBottom(
 
 export function ChatActions(props: {
   setUserInput: (value: string) => void;
+  doSubmit: (userInput: string) => void;
   uploadImage: () => void;
   setAttachImages: (images: string[]) => void;
   setUploading: (uploading: boolean) => void;
@@ -629,7 +640,10 @@ export function ChatActions(props: {
         }
       /> */}
 
-      <CallWord setUserInput={props.setUserInput} />
+      <CallWord
+        setUserInput={props.setUserInput}
+        doSubmit={props.doSubmit}
+      />
 
       {/* <ChatAction
         onClick={props.showPromptHints}
@@ -1670,6 +1684,7 @@ function _Chat() {
 
         <ChatActions
           setUserInput={setUserInput}
+          doSubmit={doSubmit}
           uploadImage={uploadImage}
           setAttachImages={setAttachImages}
           setUploading={setUploading}

+ 82 - 29
app/components/home.tsx

@@ -30,41 +30,94 @@ import { getClientConfig } from "../config/client";
 import { type ClientApi, getClientApi } from "../client/api";
 import { useAccessStore } from "../store";
 
-export function Loading(props: { noLogo?: boolean }) {
+export function Loading() {
   return (
     <div className={styles["loading-content"] + " no-dark"}>
-      {!props.noLogo && <img src={loadingIcon.src} />}
+      <img src={loadingIcon.src} />
     </div>
   );
 }
 
-const Artifacts = dynamic(async () => (await import("./artifacts")).Artifacts, {
-  loading: () => <Loading noLogo />,
-});
-
-const Settings = dynamic(async () => (await import("./settings")).Settings, {
-  loading: () => <Loading noLogo />,
-});
-
-const Chat = dynamic(async () => (await import("./chat")).Chat, {
-  loading: () => <Loading noLogo />,
-});
-
-const Record = dynamic(async () => (await import("./Record")), {
-  loading: () => <Loading noLogo />,
-});
-
-const NewChat = dynamic(async () => (await import("./new-chat")).NewChat, {
-  loading: () => <Loading noLogo />,
-});
-
-const MaskPage = dynamic(async () => (await import("./mask")).MaskPage, {
-  loading: () => <Loading noLogo />,
-});
+// 延时器
+export const delayer = (): Promise<any> => {
+  // 延时时间-秒
+  const time: number = 1;
+  return new Promise((resolve, reject) => {
+    setTimeout(() => {
+      resolve({});
+    }, time * 1000);
+  });
+}
 
-const Sd = dynamic(async () => (await import("./sd")).Sd, {
-  loading: () => <Loading noLogo />,
-});
+const Artifacts = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./artifacts")).Artifacts
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
+
+const Settings = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./settings")).Settings
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
+
+const Chat = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./chat")).Chat
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
+
+const Record = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./Record"))
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
+
+const NewChat = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./new-chat")).NewChat
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
+
+const MaskPage = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./mask")).MaskPage
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
+
+const Sd = dynamic(
+  async () => {
+    await delayer();
+    return (await import("./sd")).Sd
+  },
+  {
+    loading: () => <Loading />,
+  }
+);
 
 export function useSwitchTheme() {
   const config = useAppConfig();
@@ -216,7 +269,7 @@ export function Home() {
   useHtmlLang();
 
   useEffect(() => {
-    console.log("[Config] got config from build time", getClientConfig());
+    // console.log("[Config] got config from build time", getClientConfig());
     useAccessStore.getState().fetch();
   }, []);
 

+ 4 - 4
app/store/config.ts

@@ -35,7 +35,7 @@ export const DEFAULT_CONFIG = {
   avatar: "1f603",
   fontSize: 14,
   fontFamily: "",
-  theme: Theme.Auto as Theme,
+  theme: Theme.Light as Theme,
   tightBorder: true,
   sendPreviewBubble: true,
   enableAutoGenerateTitle: true,
@@ -52,8 +52,8 @@ export const DEFAULT_CONFIG = {
   modelConfig: {
     model: "gpt-3.5-turbo" as ModelType,
     providerName: "OpenAI" as ServiceProvider,
-    temperature: 0.5,
-    top_p: 1,
+    temperature: 0.95,
+    top_p: 0.7,
     max_tokens: 4000,
     presence_penalty: 0,
     frequency_penalty: 0,
@@ -134,7 +134,7 @@ export const useAppConfig = createPersistStore(
       }));
     },
 
-    allModels() {},
+    allModels() { },
   }),
   {
     name: StoreKey.Config,

+ 1 - 1
app/styles/globals.scss

@@ -109,7 +109,7 @@ body {
   overflow: hidden;
 
   @media only screen and (max-width: 600px) {
-    background-color: var(--second);
+    // background-color: var(--second);
   }
 
   *:focus-visible {