allow overriding Core API URL

This commit is contained in:
josc146
2023-12-12 22:37:36 +08:00
parent 0c796c8cfc
commit b8f8837a8f
9 changed files with 27 additions and 7 deletions

View File

@@ -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: {

View File

@@ -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: {

View File

@@ -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: {

View File

@@ -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>;
});