Merge branch 'dev' into litellm-as-subprocess

This commit is contained in:
Timothy Jaeryang Baek 2024-04-21 12:58:19 -07:00 committed by GitHub
commit 56c93bc2ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 31 deletions

View file

@ -195,7 +195,7 @@ class ImageGenerationPayload(BaseModel):
def comfyui_generate_image( def comfyui_generate_image(
model: str, payload: ImageGenerationPayload, client_id, base_url model: str, payload: ImageGenerationPayload, client_id, base_url
): ):
host = base_url.replace("http://", "").replace("https://", "") ws_url = base_url.replace("http://", "ws://").replace("https://", "wss://")
comfyui_prompt = json.loads(COMFYUI_DEFAULT_PROMPT) comfyui_prompt = json.loads(COMFYUI_DEFAULT_PROMPT)
@ -217,7 +217,7 @@ def comfyui_generate_image(
try: try:
ws = websocket.WebSocket() ws = websocket.WebSocket()
ws.connect(f"ws://{host}/ws?clientId={client_id}") ws.connect(f"{ws_url}/ws?clientId={client_id}")
log.info("WebSocket connection established.") log.info("WebSocket connection established.")
except Exception as e: except Exception as e:
log.exception(f"Failed to connect to WebSocket server: {e}") log.exception(f"Failed to connect to WebSocket server: {e}")

View file

@ -316,24 +316,22 @@
console.log(e); console.log(e);
if (e.dataTransfer?.files) { if (e.dataTransfer?.files) {
let reader = new FileReader();
reader.onload = (event) => {
files = [
...files,
{
type: 'image',
url: `${event.target.result}`
}
];
};
const inputFiles = Array.from(e.dataTransfer?.files); const inputFiles = Array.from(e.dataTransfer?.files);
if (inputFiles && inputFiles.length > 0) { if (inputFiles && inputFiles.length > 0) {
inputFiles.forEach((file) => { inputFiles.forEach((file) => {
console.log(file, file.name.split('.').at(-1)); console.log(file, file.name.split('.').at(-1));
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) { if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
let reader = new FileReader();
reader.onload = (event) => {
files = [
...files,
{
type: 'image',
url: `${event.target.result}`
}
];
};
reader.readAsDataURL(file); reader.readAsDataURL(file);
} else if ( } else if (
SUPPORTED_FILE_TYPE.includes(file['type']) || SUPPORTED_FILE_TYPE.includes(file['type']) ||
@ -470,23 +468,22 @@
hidden hidden
multiple multiple
on:change={async () => { on:change={async () => {
let reader = new FileReader();
reader.onload = (event) => {
files = [
...files,
{
type: 'image',
url: `${event.target.result}`
}
];
inputFiles = null;
filesInputElement.value = '';
};
if (inputFiles && inputFiles.length > 0) { if (inputFiles && inputFiles.length > 0) {
const _inputFiles = Array.from(inputFiles); const _inputFiles = Array.from(inputFiles);
_inputFiles.forEach((file) => { _inputFiles.forEach((file) => {
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) { if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
let reader = new FileReader();
reader.onload = (event) => {
files = [
...files,
{
type: 'image',
url: `${event.target.result}`
}
];
inputFiles = null;
filesInputElement.value = '';
};
reader.readAsDataURL(file); reader.readAsDataURL(file);
} else if ( } else if (
SUPPORTED_FILE_TYPE.includes(file['type']) || SUPPORTED_FILE_TYPE.includes(file['type']) ||

View file

@ -67,7 +67,7 @@
<div class="flex flex-col md:flex-row w-full px-5 py-4 md:space-x-4 dark:text-gray-200"> <div class="flex flex-col md:flex-row w-full px-5 py-4 md:space-x-4 dark:text-gray-200">
<div class=" flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6"> <div class=" flex flex-col w-full sm:flex-row sm:justify-center sm:space-x-6">
{#if chats.length > 0} {#if chats.length > 0}
<div class="text-left text-sm w-full mb-4"> <div class="text-left text-sm w-full mb-4 max-h-[22rem] overflow-y-scroll">
<div class="relative overflow-x-auto"> <div class="relative overflow-x-auto">
<table class="w-full text-sm text-left text-gray-500 dark:text-gray-400 table-auto"> <table class="w-full text-sm text-left text-gray-500 dark:text-gray-400 table-auto">
<thead <thead
@ -75,7 +75,7 @@
> >
<tr> <tr>
<th scope="col" class="px-3 py-2"> {$i18n.t('Name')} </th> <th scope="col" class="px-3 py-2"> {$i18n.t('Name')} </th>
<th scope="col" class="px-3 py-2"> {$i18n.t('Created At')} </th> <th scope="col" class="px-3 py-2 hidden md:flex"> {$i18n.t('Created At')} </th>
<th scope="col" class="px-3 py-2 text-right" /> <th scope="col" class="px-3 py-2 text-right" />
</tr> </tr>
</thead> </thead>
@ -93,8 +93,10 @@
</a> </a>
</td> </td>
<td class=" px-3 py-1"> <td class=" px-3 py-1 hidden md:flex h-[2.5rem]">
{dayjs(chat.created_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))} <div class="my-auto">
{dayjs(chat.created_at * 1000).format($i18n.t('MMMM DD, YYYY HH:mm'))}
</div>
</td> </td>
<td class="px-3 py-1 text-right"> <td class="px-3 py-1 text-right">