mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-11 22:52:54 +00:00
refac
This commit is contained in:
parent
b141fdc49e
commit
f9f815c862
2 changed files with 26 additions and 6 deletions
|
|
@ -159,7 +159,7 @@ async def get_headers_and_cookies(
|
|||
metadata: dict | None = None,
|
||||
user: UserModel = None,
|
||||
):
|
||||
cookies = {}
|
||||
cookies = getattr(request, 'cookies', {}) if config.get('forward_cookies', False) else {}
|
||||
headers = {
|
||||
'Content-Type': 'application/json',
|
||||
**(
|
||||
|
|
@ -189,11 +189,8 @@ async def get_headers_and_cookies(
|
|||
elif auth_type == 'none':
|
||||
token = None
|
||||
elif auth_type == 'session':
|
||||
cookies = request.cookies
|
||||
token = request.state.token.credentials
|
||||
elif auth_type == 'system_oauth':
|
||||
cookies = request.cookies
|
||||
|
||||
oauth_token = None
|
||||
try:
|
||||
if request.cookies.get('oauth_session_id', None):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { getContext, onMount } from 'svelte';
|
||||
const i18n = getContext('i18n');
|
||||
const i18n = getContext<any>('i18n');
|
||||
|
||||
import { verifyOpenAIConnection } from '$lib/apis/openai';
|
||||
import { verifyOllamaConnection } from '$lib/apis/ollama';
|
||||
|
|
@ -29,11 +29,12 @@
|
|||
export let ollama = false;
|
||||
export let direct = false;
|
||||
|
||||
export let connection = null;
|
||||
export let connection: any = null;
|
||||
|
||||
let url = '';
|
||||
let key = '';
|
||||
let auth_type = 'bearer';
|
||||
let forwardCookies = false;
|
||||
|
||||
let connectionType = 'external';
|
||||
let provider = '';
|
||||
|
|
@ -115,6 +116,7 @@
|
|||
key,
|
||||
config: {
|
||||
auth_type,
|
||||
...(!direct && !ollama ? { forward_cookies: forwardCookies } : {}),
|
||||
...(provider ? { provider } : {}),
|
||||
...(azure ? { azure: true } : {}),
|
||||
api_version: apiVersion,
|
||||
|
|
@ -215,6 +217,7 @@
|
|||
model_ids: modelIds,
|
||||
connection_type: connectionType,
|
||||
auth_type,
|
||||
...(!direct && !ollama ? { forward_cookies: forwardCookies } : {}),
|
||||
headers: headers ? JSON.parse(headers) : undefined,
|
||||
passthrough_params: parsePassthroughParams(passthroughParams),
|
||||
...(provider ? { provider } : {}),
|
||||
|
|
@ -232,6 +235,7 @@
|
|||
url = '';
|
||||
key = '';
|
||||
auth_type = 'bearer';
|
||||
forwardCookies = false;
|
||||
prefixId = '';
|
||||
passthroughParams = '';
|
||||
showAdvanced = false;
|
||||
|
|
@ -240,6 +244,7 @@
|
|||
};
|
||||
|
||||
const init = () => {
|
||||
forwardCookies = connection?.config?.forward_cookies ?? false;
|
||||
if (connection) {
|
||||
url = connection.url;
|
||||
key = connection.key;
|
||||
|
|
@ -506,6 +511,24 @@
|
|||
</div>
|
||||
|
||||
{#if showAdvanced}
|
||||
{#if !direct && !ollama}
|
||||
<div class="flex items-center justify-between gap-3 mt-2">
|
||||
<div>
|
||||
<label for="forward-cookies" class="text-xs text-gray-500">
|
||||
{$i18n.t('Forward cookies')}
|
||||
</label>
|
||||
<p class="text-xs text-gray-500">
|
||||
{$i18n.t('Forward cookies from your Open WebUI request to this server.')}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="forward-cookies"
|
||||
ariaLabel={$i18n.t('Forward cookies')}
|
||||
bind:state={forwardCookies}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !direct}
|
||||
<div class="flex gap-2 mt-2">
|
||||
<div class="flex flex-col w-full">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue