mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
refac/fix: direct connection floating action buttons
This commit is contained in:
parent
b6538b2cdd
commit
6c4deed37a
2 changed files with 16 additions and 6 deletions
|
|
@ -80,6 +80,7 @@ async def generate_direct_chat_completion(
|
||||||
event_caller = get_event_call(metadata)
|
event_caller = get_event_call(metadata)
|
||||||
|
|
||||||
channel = f"{user_id}:{session_id}:{request_id}"
|
channel = f"{user_id}:{session_id}:{request_id}"
|
||||||
|
logging.info(f"WebSocket channel: {channel}")
|
||||||
|
|
||||||
if form_data.get("stream"):
|
if form_data.get("stream"):
|
||||||
q = asyncio.Queue()
|
q = asyncio.Queue()
|
||||||
|
|
@ -121,7 +122,10 @@ async def generate_direct_chat_completion(
|
||||||
|
|
||||||
yield f"data: {json.dumps(data)}\n\n"
|
yield f"data: {json.dumps(data)}\n\n"
|
||||||
elif isinstance(data, str):
|
elif isinstance(data, str):
|
||||||
yield data
|
if "data:" in data:
|
||||||
|
yield f"{data}\n\n"
|
||||||
|
else:
|
||||||
|
yield f"data: {data}\n\n"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.debug(f"Error in event generator: {e}")
|
log.debug(f"Error in event generator: {e}")
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
import LightBulb from '$lib/components/icons/LightBulb.svelte';
|
import LightBulb from '$lib/components/icons/LightBulb.svelte';
|
||||||
import Markdown from '../Messages/Markdown.svelte';
|
import Markdown from '../Messages/Markdown.svelte';
|
||||||
import Skeleton from '../Messages/Skeleton.svelte';
|
import Skeleton from '../Messages/Skeleton.svelte';
|
||||||
|
import { chatId, models, socket } from '$lib/stores';
|
||||||
|
|
||||||
export let id = '';
|
export let id = '';
|
||||||
export let messageId = '';
|
export let messageId = '';
|
||||||
|
|
@ -118,6 +119,9 @@
|
||||||
let res;
|
let res;
|
||||||
[res, controller] = await chatCompletion(localStorage.token, {
|
[res, controller] = await chatCompletion(localStorage.token, {
|
||||||
model: model,
|
model: model,
|
||||||
|
model_item: $models.find((m) => m.id === model),
|
||||||
|
session_id: $socket?.id,
|
||||||
|
chat_id: $chatId,
|
||||||
messages: [
|
messages: [
|
||||||
...messages,
|
...messages,
|
||||||
{
|
{
|
||||||
|
|
@ -246,11 +250,11 @@
|
||||||
{#if responseContent === null}
|
{#if responseContent === null}
|
||||||
{#if !floatingInput}
|
{#if !floatingInput}
|
||||||
<div
|
<div
|
||||||
class="flex flex-row gap-0.5 shrink-0 p-1 bg-white dark:bg-gray-850 dark:text-gray-100 text-medium rounded-lg shadow-xl"
|
class="flex flex-row shrink-0 p-0.5 bg-white dark:bg-gray-850 dark:text-gray-100 text-medium rounded-xl shadow-xl border border-gray-100 dark:border-gray-800"
|
||||||
>
|
>
|
||||||
{#each actions as action}
|
{#each actions as action}
|
||||||
<button
|
<button
|
||||||
class="px-1 hover:bg-gray-50 dark:hover:bg-gray-800 rounded-sm flex items-center gap-1 min-w-fit"
|
class="px-1.5 py-[1px] hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl flex items-center gap-1 min-w-fit transition"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
selectedText = window.getSelection().toString();
|
selectedText = window.getSelection().toString();
|
||||||
selectedAction = action;
|
selectedAction = action;
|
||||||
|
|
@ -321,9 +325,11 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
<div class="bg-white dark:bg-gray-850 dark:text-gray-100 rounded-xl shadow-xl w-80 max-w-full">
|
<div
|
||||||
|
class="bg-white dark:bg-gray-850 dark:text-gray-100 rounded-3xl shadow-xl w-80 max-w-full border border-gray-100 dark:border-gray-800"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="bg-gray-50/50 dark:bg-gray-800 dark:text-gray-100 text-medium rounded-xl px-3.5 py-3 w-full"
|
class="bg-white dark:bg-gray-850 dark:text-gray-100 text-medium rounded-3xl px-3.5 pt-3 w-full"
|
||||||
>
|
>
|
||||||
<div class="font-medium">
|
<div class="font-medium">
|
||||||
<Markdown id={`${id}-float-prompt`} {content} />
|
<Markdown id={`${id}-float-prompt`} {content} />
|
||||||
|
|
@ -331,7 +337,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="bg-white dark:bg-gray-850 dark:text-gray-100 text-medium rounded-xl px-3.5 py-3 w-full"
|
class="bg-white dark:bg-gray-850 dark:text-gray-100 text-medium rounded-3xl px-3.5 py-3 w-full"
|
||||||
>
|
>
|
||||||
<div class=" max-h-80 overflow-y-auto w-full markdown-prose-xs" id="response-container">
|
<div class=" max-h-80 overflow-y-auto w-full markdown-prose-xs" id="response-container">
|
||||||
{#if !responseContent || responseContent?.trim() === ''}
|
{#if !responseContent || responseContent?.trim() === ''}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue