From 15e595837be45d0fa2f5a429840950345801b7f9 Mon Sep 17 00:00:00 2001 From: butterfly Date: Tue, 2 Apr 2024 14:21:49 +0800 Subject: [PATCH] feat: settings command dev done --- app/components/chat.tsx | 9 +++++++++ app/components/emoji.tsx | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 7b7b66bec..0d0ae93eb 100644 --- a/app/components/chat.tsx +++ b/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!), + ); } }); } diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index 6f4dc62a9..495e48785 100644 --- a/app/components/emoji.tsx +++ b/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";