diff --git a/api/core/entities/provider_configuration.py b/api/core/entities/provider_configuration.py index 86887c9b4a..81d582fb9a 100644 --- a/api/core/entities/provider_configuration.py +++ b/api/core/entities/provider_configuration.py @@ -897,37 +897,36 @@ class ProviderConfiguration(BaseModel): ) except Exception as ex: logger.warning(f"get custom model schema failed, {ex}") + continue - if not custom_model_schema: - continue + if not custom_model_schema: + continue - if custom_model_schema.model_type not in model_types: - continue + if custom_model_schema.model_type not in model_types: + continue - status = ModelStatus.ACTIVE - if ( - custom_model_schema.model_type in model_setting_map - and custom_model_schema.model in model_setting_map[custom_model_schema.model_type] - ): - model_setting = model_setting_map[custom_model_schema.model_type][ - custom_model_schema.model - ] - if model_setting.enabled is False: - status = ModelStatus.DISABLED + status = ModelStatus.ACTIVE + if ( + custom_model_schema.model_type in model_setting_map + and custom_model_schema.model in model_setting_map[custom_model_schema.model_type] + ): + model_setting = model_setting_map[custom_model_schema.model_type][custom_model_schema.model] + if model_setting.enabled is False: + status = ModelStatus.DISABLED - provider_models.append( - ModelWithProviderEntity( - model=custom_model_schema.model, - label=custom_model_schema.label, - model_type=custom_model_schema.model_type, - features=custom_model_schema.features, - fetch_from=FetchFrom.PREDEFINED_MODEL, - model_properties=custom_model_schema.model_properties, - deprecated=custom_model_schema.deprecated, - provider=SimpleModelProviderEntity(self.provider), - status=status, - ) + provider_models.append( + ModelWithProviderEntity( + model=custom_model_schema.model, + label=custom_model_schema.label, + model_type=custom_model_schema.model_type, + features=custom_model_schema.features, + fetch_from=FetchFrom.PREDEFINED_MODEL, + model_properties=custom_model_schema.model_properties, + deprecated=custom_model_schema.deprecated, + provider=SimpleModelProviderEntity(self.provider), + status=status, ) + ) # if llm name not in restricted llm list, remove it restrict_model_names = [rm.model for rm in restrict_models] diff --git a/api/core/rag/datasource/vdb/pgvector/pgvector.py b/api/core/rag/datasource/vdb/pgvector/pgvector.py index 366a21c381..04e9cf801e 100644 --- a/api/core/rag/datasource/vdb/pgvector/pgvector.py +++ b/api/core/rag/datasource/vdb/pgvector/pgvector.py @@ -1,3 +1,4 @@ +import hashlib import json import logging import uuid @@ -61,12 +62,12 @@ CREATE TABLE IF NOT EXISTS {table_name} ( """ SQL_CREATE_INDEX = """ -CREATE INDEX IF NOT EXISTS embedding_cosine_v1_idx ON {table_name} +CREATE INDEX IF NOT EXISTS embedding_cosine_v1_idx_{index_hash} ON {table_name} USING hnsw (embedding vector_cosine_ops) WITH (m = 16, ef_construction = 64); """ SQL_CREATE_INDEX_PG_BIGM = """ -CREATE INDEX IF NOT EXISTS bigm_idx ON {table_name} +CREATE INDEX IF NOT EXISTS bigm_idx_{index_hash} ON {table_name} USING gin (text gin_bigm_ops); """ @@ -76,6 +77,7 @@ class PGVector(BaseVector): super().__init__(collection_name) self.pool = self._create_connection_pool(config) self.table_name = f"embedding_{collection_name}" + self.index_hash = hashlib.md5(self.table_name.encode()).hexdigest()[:8] self.pg_bigm = config.pg_bigm def get_type(self) -> str: @@ -256,10 +258,9 @@ class PGVector(BaseVector): # PG hnsw index only support 2000 dimension or less # ref: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing if dimension <= 2000: - cur.execute(SQL_CREATE_INDEX.format(table_name=self.table_name)) + cur.execute(SQL_CREATE_INDEX.format(table_name=self.table_name, index_hash=self.index_hash)) if self.pg_bigm: - cur.execute("CREATE EXTENSION IF NOT EXISTS pg_bigm") - cur.execute(SQL_CREATE_INDEX_PG_BIGM.format(table_name=self.table_name)) + cur.execute(SQL_CREATE_INDEX_PG_BIGM.format(table_name=self.table_name, index_hash=self.index_hash)) redis_client.set(collection_exist_cache_key, 1, ex=3600) diff --git a/web/app/account/header.tsx b/web/app/account/header.tsx index 2bb89552c8..11b6beec08 100644 --- a/web/app/account/header.tsx +++ b/web/app/account/header.tsx @@ -4,23 +4,25 @@ import { RiArrowRightUpLine, RiRobot2Line } from '@remixicon/react' import { useRouter } from 'next/navigation' import Button from '../components/base/button' import Avatar from './avatar' -import LogoSite from '@/app/components/base/logo/logo-site' +import DifyLogo from '@/app/components/base/logo/dify-logo' +import { useCallback } from 'react' const Header = () => { const { t } = useTranslation() const router = useRouter() - const back = () => { + const back = useCallback(() => { router.back() - } + }, [router]) + return (
- +
-
-

{t('common.account.account')}

+
+

{t('common.account.account')}

)} @@ -132,7 +132,7 @@ const Header: FC = ({ return (
{customerIcon} diff --git a/web/app/components/base/chat/embedded-chatbot/index.tsx b/web/app/components/base/chat/embedded-chatbot/index.tsx index 44a8edbc0f..49189c419e 100644 --- a/web/app/components/base/chat/embedded-chatbot/index.tsx +++ b/web/app/components/base/chat/embedded-chatbot/index.tsx @@ -19,7 +19,7 @@ import Loading from '@/app/components/base/loading' import LogoHeader from '@/app/components/base/logo/logo-embedded-chat-header' import Header from '@/app/components/base/chat/embedded-chatbot/header' import ChatWrapper from '@/app/components/base/chat/embedded-chatbot/chat-wrapper' -import LogoSite from '@/app/components/base/logo/logo-site' +import DifyLogo from '@/app/components/base/logo/dify-logo' import cn from '@/utils/classnames' import useDocumentTitle from '@/hooks/use-document-title' @@ -119,7 +119,7 @@ const Chatbot = () => { logo )} {!appData?.custom_config?.replace_webapp_logo && ( - + )}
)} diff --git a/web/app/components/base/logo/dify-logo.tsx b/web/app/components/base/logo/dify-logo.tsx new file mode 100644 index 0000000000..4f2d833b88 --- /dev/null +++ b/web/app/components/base/logo/dify-logo.tsx @@ -0,0 +1,51 @@ +'use client' +import type { FC } from 'react' +import { WEB_PREFIX } from '@/config' +import classNames from '@/utils/classnames' +import useTheme from '@/hooks/use-theme' +import { useGlobalPublicStore } from '@/context/global-public-context' + +export type LogoStyle = 'default' | 'monochromeWhite' + +export const logoPathMap: Record = { + default: '/logo/logo.svg', + monochromeWhite: '/logo/logo-monochrome-white.svg', +} + +export type LogoSize = 'large' | 'medium' | 'small' + +export const logoSizeMap: Record = { + large: 'w-16 h-7', + medium: 'w-12 h-[22px]', + small: 'w-9 h-4', +} + +type DifyLogoProps = { + style?: LogoStyle + size?: LogoSize + className?: string +} + +const DifyLogo: FC = ({ + style = 'default', + size = 'medium', + className, +}) => { + const { theme } = useTheme() + const themedStyle = (theme === 'dark' && style === 'default') ? 'monochromeWhite' : style + const { systemFeatures } = useGlobalPublicStore() + + let src = `${WEB_PREFIX}${logoPathMap[themedStyle]}` + if (systemFeatures.branding.enabled) + src = systemFeatures.branding.workspace_logo + + return ( + Dify logo + ) +} + +export default DifyLogo diff --git a/web/app/components/base/logo/logo-site.tsx b/web/app/components/base/logo/logo-site.tsx deleted file mode 100644 index bccae128cc..0000000000 --- a/web/app/components/base/logo/logo-site.tsx +++ /dev/null @@ -1,29 +0,0 @@ -'use client' -import type { FC } from 'react' -import { WEB_PREFIX } from '@/config' -import classNames from '@/utils/classnames' -import { useGlobalPublicStore } from '@/context/global-public-context' - -type LogoSiteProps = { - className?: string -} - -const LogoSite: FC = ({ - className, -}) => { - const { systemFeatures } = useGlobalPublicStore() - - let src = `${WEB_PREFIX}/logo/logo.png` - if (systemFeatures.branding.enabled) - src = systemFeatures.branding.workspace_logo - - return ( - logo - ) -} - -export default LogoSite diff --git a/web/app/components/base/premium-badge/index.css b/web/app/components/base/premium-badge/index.css index b160ba7e2c..61031cd4d2 100644 --- a/web/app/components/base/premium-badge/index.css +++ b/web/app/components/base/premium-badge/index.css @@ -2,7 +2,7 @@ @layer components { .premium-badge { - @apply shrink-0 relative inline-flex justify-center items-center rounded-md box-border border border-transparent text-white shadow-xs hover:shadow-lg bg-origin-border overflow-hidden; + @apply shrink-0 relative inline-flex justify-center items-center rounded-md box-border border border-transparent text-white shadow-xs hover:shadow-lg bg-origin-border overflow-hidden transition-all duration-100 ease-out; background-clip: padding-box, border-box; } .allowHover { diff --git a/web/app/components/custom/custom-web-app-brand/index.tsx b/web/app/components/custom/custom-web-app-brand/index.tsx index b95016fec5..444df98f24 100644 --- a/web/app/components/custom/custom-web-app-brand/index.tsx +++ b/web/app/components/custom/custom-web-app-brand/index.tsx @@ -10,7 +10,7 @@ import { RiLoader2Line, RiPlayLargeLine, } from '@remixicon/react' -import LogoSite from '@/app/components/base/logo/logo-site' +import DifyLogo from '@/app/components/base/logo/dify-logo' import Switch from '@/app/components/base/switch' import Button from '@/app/components/base/button' import Divider from '@/app/components/base/divider' @@ -246,7 +246,7 @@ const CustomWebAppBrand = () => {
POWERED BY
{webappLogo ? logo - : + : } )} @@ -305,7 +305,7 @@ const CustomWebAppBrand = () => {
POWERED BY
{webappLogo ? logo - : + : } )} diff --git a/web/app/components/header/account-about/index.tsx b/web/app/components/header/account-about/index.tsx index 16dd63ea7a..6129b48dce 100644 --- a/web/app/components/header/account-about/index.tsx +++ b/web/app/components/header/account-about/index.tsx @@ -7,7 +7,7 @@ import Modal from '@/app/components/base/modal' import Button from '@/app/components/base/button' import type { LangGeniusVersionResponse } from '@/models/common' import { IS_CE_EDITION } from '@/config' -import LogoSite from '@/app/components/base/logo/logo-site' +import DifyLogo from '@/app/components/base/logo/dify-logo' import { noop } from 'lodash-es' type IAccountSettingProps = { @@ -28,21 +28,21 @@ export default function AccountAbout({ onClose={noop} className='!w-[480px] !max-w-[480px] !px-6 !py-4' > -
-
+
+
-
- -
Version {langeniusVersionInfo?.current_version}
-
+
+ +
Version {langeniusVersionInfo?.current_version}
+
© {dayjs().year()} LangGenius, Inc., Contributors.
{ IS_CE_EDITION ? Open Source License : <> - Privacy Policy, + Privacy Policy,  Terms of Service } @@ -51,7 +51,7 @@ export default function AccountAbout({
-
+
{ isLatest ? t('common.about.latestAvailable', { version: langeniusVersionInfo.latest_version }) @@ -59,7 +59,7 @@ export default function AccountAbout({ }
-