allow overriding Core API URL
This commit is contained in:
parent
0c796c8cfc
commit
b8f8837a8f
@ -317,5 +317,7 @@
|
||||
"Please convert model to GGML format first": "モデルをGGML形式に変換してください",
|
||||
"Convert To GGML Format": "GGML形式に変換",
|
||||
"CPU (rwkv.cpp, Faster)": "CPU (rwkv.cpp, 高速)",
|
||||
"Play With External Player": "外部プレーヤーで再生"
|
||||
"Play With External Player": "外部プレーヤーで再生",
|
||||
"Core API URL": "コアAPI URL",
|
||||
"Override core API URL(/chat/completions and /completions). If you don't know what this is, leave it blank.": "コアAPI URLを上書きします(/chat/completions と /completions)。何であるかわからない場合は空白のままにしてください。"
|
||||
}
|
@ -317,5 +317,7 @@
|
||||
"Please convert model to GGML format first": "请先将模型转换为GGML格式",
|
||||
"Convert To GGML Format": "转换为GGML格式",
|
||||
"CPU (rwkv.cpp, Faster)": "CPU (rwkv.cpp, 更快)",
|
||||
"Play With External Player": "使用外部播放器播放"
|
||||
"Play With External Player": "使用外部播放器播放",
|
||||
"Core API URL": "核心 API URL",
|
||||
"Override core API URL(/chat/completions and /completions). If you don't know what this is, leave it blank.": "覆盖核心的 API URL (/chat/completions 和 /completions)。如果你不知道这是什么,请留空"
|
||||
}
|
@ -436,7 +436,7 @@ const ChatPanel: FC = observer(() => {
|
||||
const chatSseController = new AbortController();
|
||||
chatSseControllers[answerId] = chatSseController;
|
||||
fetchEventSource( // https://api.openai.com/v1/chat/completions || http://127.0.0.1:${port}/v1/chat/completions
|
||||
getServerRoot(port) + '/v1/chat/completions',
|
||||
getServerRoot(port, true) + '/v1/chat/completions',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -82,7 +82,7 @@ const CompletionPanel: FC = observer(() => {
|
||||
let answer = '';
|
||||
completionSseController = new AbortController();
|
||||
fetchEventSource( // https://api.openai.com/v1/completions || http://127.0.0.1:${port}/v1/completions
|
||||
getServerRoot(port) + '/v1/completions',
|
||||
getServerRoot(port, true) + '/v1/completions',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -173,7 +173,7 @@ const CompositionPanel: FC = observer(() => {
|
||||
let answer = '';
|
||||
compositionSseController = new AbortController();
|
||||
fetchEventSource( // https://api.openai.com/v1/completions || http://127.0.0.1:${port}/v1/completions
|
||||
getServerRoot(port) + '/v1/completions',
|
||||
getServerRoot(port, true) + '/v1/completions',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -186,6 +186,16 @@ export const AdvancedGeneralSettings: FC = observer(() => {
|
||||
</Dropdown>
|
||||
</div>
|
||||
} />
|
||||
<Labeled label={t('Core API URL')}
|
||||
desc={t('Override core API URL(/chat/completions and /completions). If you don\'t know what this is, leave it blank.')}
|
||||
content={
|
||||
<Input style={{ minWidth: 0 }} className="grow" value={commonStore.settings.coreApiUrl}
|
||||
onChange={(e, data) => {
|
||||
commonStore.setSettings({
|
||||
coreApiUrl: data.value
|
||||
});
|
||||
}} />
|
||||
} />
|
||||
</div>;
|
||||
});
|
||||
|
||||
|
@ -175,7 +175,8 @@ class CommonStore {
|
||||
apiUrl: '',
|
||||
apiKey: '',
|
||||
apiChatModelName: 'rwkv',
|
||||
apiCompletionModelName: 'rwkv'
|
||||
apiCompletionModelName: 'rwkv',
|
||||
coreApiUrl: ''
|
||||
};
|
||||
// about
|
||||
about: AboutContent = manifest.about;
|
||||
|
@ -19,4 +19,5 @@ export type SettingsType = {
|
||||
apiKey: string
|
||||
apiChatModelName: string
|
||||
apiCompletionModelName: string
|
||||
coreApiUrl: string
|
||||
}
|
@ -303,7 +303,11 @@ export function bytesToReadable(size: number) {
|
||||
else return bytesToGb(size) + ' GB';
|
||||
}
|
||||
|
||||
export function getServerRoot(defaultLocalPort: number) {
|
||||
export function getServerRoot(defaultLocalPort: number, isCore: boolean = false) {
|
||||
const coreCustomApiUrl = commonStore.settings.coreApiUrl.trim().replace(/\/$/, '');
|
||||
if (isCore && coreCustomApiUrl)
|
||||
return coreCustomApiUrl;
|
||||
|
||||
const defaultRoot = `http://127.0.0.1:${defaultLocalPort}`;
|
||||
if (commonStore.status.status !== ModelStatus.Offline)
|
||||
return defaultRoot;
|
||||
|
Loading…
Reference in New Issue
Block a user