From 7d08bbd2624e3479c4154a2a7f6154fff2441a78 Mon Sep 17 00:00:00 2001 From: Yurun Date: Fri, 15 Sep 2023 11:19:05 +0800 Subject: [PATCH] =?UTF-8?q?OpenAI=20=E6=A8=A1=E5=9E=8B=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/config/components/config-openai.vue | 9 +- .../config/components/models-manager.vue | 97 +++++++++++++++++++ server/Module/Chat/Model/Redis/ChatConfig.php | 4 +- .../Embedding/Model/Redis/EmbeddingConfig.php | 4 +- .../OpenAI/Model/Redis/OpenAIConfig.php | 4 +- 5 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 admin/src/views/config/components/models-manager.vue diff --git a/admin/src/views/config/components/config-openai.vue b/admin/src/views/config/components/config-openai.vue index bfbeed6..742c3ab 100644 --- a/admin/src/views/config/components/config-openai.vue +++ b/admin/src/views/config/components/config-openai.vue @@ -9,7 +9,10 @@ > - + + + + @@ -24,12 +27,14 @@ import type { FormInst, FormRules } from 'naive-ui'; import { defineConfigComponent } from '@/store'; import type { ConfigComponentProps, ConfigComponentEmit } from '@/store'; import ApiManager from './api-manager.vue'; +import ModelsManager from './models-manager.vue'; const props = defineProps(); const emit = defineEmits(); const rules: FormRules = {}; const formData = ref({ - apis: [] + apis: [], + models: [] }); const form = ref(); diff --git a/admin/src/views/config/components/models-manager.vue b/admin/src/views/config/components/models-manager.vue new file mode 100644 index 0000000..95c056d --- /dev/null +++ b/admin/src/views/config/components/models-manager.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/server/Module/Chat/Model/Redis/ChatConfig.php b/server/Module/Chat/Model/Redis/ChatConfig.php index 71a4b81..ef4f742 100644 --- a/server/Module/Chat/Model/Redis/ChatConfig.php +++ b/server/Module/Chat/Model/Redis/ChatConfig.php @@ -43,8 +43,8 @@ public function getModelConfigs(): array return $this->modelConfigs = [ new ModelConfig(['model' => 'gpt-3.5-turbo', 'inputTokenMultiple' => '0.75', 'outputTokenMultiple' => '1.0', 'maxTokens' => 4096]), new ModelConfig(['model' => 'gpt-3.5-turbo-16k', 'inputTokenMultiple' => '1.5', 'outputTokenMultiple' => '2.0', 'maxTokens' => 16384]), - new ModelConfig(['model' => 'gpt-4', 'enable' => false, 'inputTokenMultiple' => '150', 'outputTokenMultiple' => '3.0', 'maxTokens' => 8192]), - new ModelConfig(['model' => 'gpt-4-32k', 'enable' => false, 'inputTokenMultiple' => '300', 'outputTokenMultiple' => '6.0', 'maxTokens' => 32768]), + new ModelConfig(['model' => 'gpt-4', 'enable' => false, 'inputTokenMultiple' => '15', 'outputTokenMultiple' => '30', 'maxTokens' => 8192]), + new ModelConfig(['model' => 'gpt-4-32k', 'enable' => false, 'inputTokenMultiple' => '30', 'outputTokenMultiple' => '60', 'maxTokens' => 32768]), ]; } diff --git a/server/Module/Embedding/Model/Redis/EmbeddingConfig.php b/server/Module/Embedding/Model/Redis/EmbeddingConfig.php index 4289995..fc4f03c 100644 --- a/server/Module/Embedding/Model/Redis/EmbeddingConfig.php +++ b/server/Module/Embedding/Model/Redis/EmbeddingConfig.php @@ -225,8 +225,8 @@ public function getChatModelConfigs(): ?array return $this->chatModelConfigs = [ new ModelConfig(['model' => 'gpt-3.5-turbo', 'inputTokenMultiple' => '0.75', 'outputTokenMultiple' => '1.0', 'maxTokens' => 4096]), new ModelConfig(['model' => 'gpt-3.5-turbo-16k', 'inputTokenMultiple' => '1.5', 'outputTokenMultiple' => '2.0', 'maxTokens' => 16384]), - new ModelConfig(['model' => 'gpt-4', 'enable' => false, 'inputTokenMultiple' => '150', 'outputTokenMultiple' => '3.0', 'maxTokens' => 8192]), - new ModelConfig(['model' => 'gpt-4-32k', 'enable' => false, 'inputTokenMultiple' => '300', 'outputTokenMultiple' => '6.0', 'maxTokens' => 32768]), + new ModelConfig(['model' => 'gpt-4', 'enable' => false, 'inputTokenMultiple' => '15', 'outputTokenMultiple' => '30', 'maxTokens' => 8192]), + new ModelConfig(['model' => 'gpt-4-32k', 'enable' => false, 'inputTokenMultiple' => '30', 'outputTokenMultiple' => '60', 'maxTokens' => 32768]), ]; } diff --git a/server/Module/OpenAI/Model/Redis/OpenAIConfig.php b/server/Module/OpenAI/Model/Redis/OpenAIConfig.php index 328d7ba..de352d6 100644 --- a/server/Module/OpenAI/Model/Redis/OpenAIConfig.php +++ b/server/Module/OpenAI/Model/Redis/OpenAIConfig.php @@ -95,8 +95,8 @@ public function getModels(): ?array return $this->models = [ new ModelConfig(['model' => 'gpt-3.5-turbo', 'inputTokenMultiple' => '0.75', 'outputTokenMultiple' => '1.0', 'maxTokens' => 4096]), new ModelConfig(['model' => 'gpt-3.5-turbo-16k', 'inputTokenMultiple' => '1.5', 'outputTokenMultiple' => '2.0', 'maxTokens' => 16384]), - new ModelConfig(['model' => 'gpt-4', 'enable' => false, 'inputTokenMultiple' => '150', 'outputTokenMultiple' => '3.0', 'maxTokens' => 8192]), - new ModelConfig(['model' => 'gpt-4-32k', 'enable' => false, 'inputTokenMultiple' => '300', 'outputTokenMultiple' => '6.0', 'maxTokens' => 32768]), + new ModelConfig(['model' => 'gpt-4', 'enable' => false, 'inputTokenMultiple' => '15', 'outputTokenMultiple' => '30', 'maxTokens' => 8192]), + new ModelConfig(['model' => 'gpt-4-32k', 'enable' => false, 'inputTokenMultiple' => '30', 'outputTokenMultiple' => '60', 'maxTokens' => 32768]), new ModelConfig(['model' => 'text-embedding-ada-002', 'inputTokenMultiple' => '0.05', 'outputTokenMultiple' => '0.05', 'maxTokens' => 8191]), ]; }