Selaa lähdekoodia

feat: settings command dev done

butterfly 1 vuosi sitten
vanhempi
commit
15e595837b
2 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 9 0
      app/components/chat.tsx
  2. 0 2
      app/components/emoji.tsx

+ 9 - 0
app/components/chat.tsx

@@ -979,6 +979,7 @@ function _Chat() {
         }
       });
     },
+    // set openai key & endpoint url
     settings: (text) => {
       try {
         const payload = JSON.parse(text) as {
@@ -996,9 +997,17 @@ function _Chat() {
             if (!res) return;
             if (payload.key) {
               // TODO: auto-fill openai api key here, must specific provider type
+              config.update(
+                (config) =>
+                  (config.providerConfig.openai.apiKey = payload.key!),
+              );
             }
             if (payload.url) {
               // TODO: auto-fill openai url here, must specific provider type
+              config.update(
+                (config) =>
+                  (config.providerConfig.openai.endpoint = payload.url!),
+              );
             }
           });
         }

+ 0 - 2
app/components/emoji.tsx

@@ -4,8 +4,6 @@ import EmojiPicker, {
   Theme as EmojiTheme,
 } from "emoji-picker-react";
 
-import { ModelType } from "../store";
-
 import BotIcon from "../icons/bot.svg";
 import BlackBotIcon from "../icons/black-bot.svg";