Skip to content

Commit

Permalink
Merge branch 'fix/logo' into deploy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zxhlyh committed Oct 13, 2023
2 parents 54a31fc + 181bb73 commit 84acff4
Show file tree
Hide file tree
Showing 36 changed files with 131 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from core.third_party.langchain.embeddings.xinference_embedding import XinferenceEmbedding as XinferenceEmbeddings

from core.model_providers.error import LLMBadRequestError
from core.model_providers.providers.base import BaseModelProvider
from core.model_providers.models.embedding.base import BaseEmbedding
from core.third_party.langchain.embeddings.xinference_embedding import XinferenceEmbeddings


class XinferenceEmbedding(BaseEmbedding):
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_providers/models/llm/openai_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'gpt-4': 8192,
'gpt-4-32k': 32768,
'gpt-3.5-turbo': 4096,
'gpt-3.5-turbo-instruct': 8192,
'gpt-3.5-turbo-instruct': 4097,
'gpt-3.5-turbo-16k': 16384,
'text-davinci-003': 4097,
}
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_providers/providers/openai_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_model_parameter_rules(self, model_name: str, model_type: ModelType) -> M
'gpt-4': 8192,
'gpt-4-32k': 32768,
'gpt-3.5-turbo': 4096,
'gpt-3.5-turbo-instruct': 8192,
'gpt-3.5-turbo-instruct': 4097,
'gpt-3.5-turbo-16k': 16384,
'text-davinci-003': 4097,
}
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_providers/providers/xinference_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Type

import requests
from langchain.embeddings import XinferenceEmbeddings

from core.helper import encrypter
from core.model_providers.models.embedding.xinference_embedding import XinferenceEmbedding
Expand All @@ -11,6 +10,7 @@
from core.model_providers.providers.base import BaseModelProvider, CredentialsValidateFailedError

from core.model_providers.models.base import BaseProviderModel
from core.third_party.langchain.embeddings.xinference_embedding import XinferenceEmbeddings
from core.third_party.langchain.llms.xinference_llm import XinferenceLLM
from models.provider import ProviderType

Expand Down
43 changes: 38 additions & 5 deletions api/core/third_party/langchain/embeddings/xinference_embedding.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
from typing import List
from typing import List, Optional, Any

import numpy as np
from langchain.embeddings import XinferenceEmbeddings
from langchain.embeddings.base import Embeddings
from xinference_client.client.restful.restful_client import Client


class XinferenceEmbedding(XinferenceEmbeddings):
class XinferenceEmbeddings(Embeddings):
client: Any
server_url: Optional[str]
"""URL of the xinference server"""
model_uid: Optional[str]
"""UID of the launched model"""

def __init__(
self, server_url: Optional[str] = None, model_uid: Optional[str] = None
):

super().__init__()

if server_url is None:
raise ValueError("Please provide server URL")

if model_uid is None:
raise ValueError("Please provide the model UID")

self.server_url = server_url

self.model_uid = model_uid

self.client = Client(server_url)

def embed_documents(self, texts: List[str]) -> List[List[float]]:
vectors = super().embed_documents(texts)
model = self.client.get_model(self.model_uid)

embeddings = [
model.create_embedding(text)["data"][0]["embedding"] for text in texts
]
vectors = [list(map(float, e)) for e in embeddings]
normalized_vectors = [(vector / np.linalg.norm(vector)).tolist() for vector in vectors]

return normalized_vectors

def embed_query(self, text: str) -> List[float]:
vector = super().embed_query(text)
model = self.client.get_model(self.model_uid)

embedding_res = model.create_embedding(text)

embedding = embedding_res["data"][0]["embedding"]

vector = list(map(float, embedding))
normalized_vector = (vector / np.linalg.norm(vector)).tolist()

return normalized_vector
47 changes: 42 additions & 5 deletions api/core/third_party/langchain/llms/xinference_llm.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,53 @@
from typing import Optional, List, Any, Union, Generator
from typing import Optional, List, Any, Union, Generator, Mapping

from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain.llms import Xinference
from langchain.llms.base import LLM
from langchain.llms.utils import enforce_stop_tokens
from xinference.client import (
from xinference_client.client.restful.restful_client import (
RESTfulChatglmCppChatModelHandle,
RESTfulChatModelHandle,
RESTfulGenerateModelHandle,
RESTfulGenerateModelHandle, Client,
)


class XinferenceLLM(Xinference):
class XinferenceLLM(LLM):
client: Any
server_url: Optional[str]
"""URL of the xinference server"""
model_uid: Optional[str]
"""UID of the launched model"""

def __init__(
self, server_url: Optional[str] = None, model_uid: Optional[str] = None
):
super().__init__(
**{
"server_url": server_url,
"model_uid": model_uid,
}
)

if self.server_url is None:
raise ValueError("Please provide server URL")

if self.model_uid is None:
raise ValueError("Please provide the model UID")

self.client = Client(server_url)

@property
def _llm_type(self) -> str:
"""Return type of llm."""
return "xinference"

@property
def _identifying_params(self) -> Mapping[str, Any]:
"""Get the identifying parameters."""
return {
**{"server_url": self.server_url},
**{"model_uid": self.model_uid},
}

def _call(
self,
prompt: str,
Expand Down
2 changes: 1 addition & 1 deletion api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ huggingface_hub~=0.16.4
transformers~=4.31.0
stripe~=5.5.0
pandas==1.5.3
xinference==0.5.2
xinference-client~=0.1.2
safetensors==0.3.2
zhipuai==1.0.7
werkzeug==2.3.7
Expand Down
13 changes: 0 additions & 13 deletions web/app/components/header/account-about/index.module.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
.logo-icon {
background: url(../assets/logo-icon.png) center center no-repeat;
background-size: 32px;
box-shadow: 0px 2px 4px -2px rgba(0, 0, 0, 0.05), 0px 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.logo-text {
width: 74.09px;
height: 15.32px;
background: url(../assets/logo-text.svg) center center no-repeat;
background-size: contain;
}

.modal {
max-width: 480px !important;
width: 480px !important;
Expand Down
15 changes: 8 additions & 7 deletions web/app/components/header/account-about/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import { useTranslation } from 'react-i18next'
import classNames from 'classnames'
import Link from 'next/link'
import Image from 'next/image'
import { useContext } from 'use-context-selector'
import logoUrl from '../../../../public/logo/logo-site.png'
import s from './index.module.css'
import Modal from '@/app/components/base/modal'
import { XClose } from '@/app/components/base/icons/src/vender/line/general'
import { Dify } from '@/app/components/base/icons/src/public/common'
import type { LangGeniusVersionResponse } from '@/models/common'
import { IS_CE_EDITION } from '@/config'
import I18n from '@/context/i18n'
Expand All @@ -33,16 +34,16 @@ export default function AccountAbout({
onClose={() => { }}
className={s.modal}
>
<div className='relative'>
<div className='relative pt-4'>
<div className='absolute -top-2 -right-4 flex justify-center items-center w-8 h-8 cursor-pointer' onClick={onCancel}>
<XClose className='w-4 h-4 text-gray-500' />
</div>
<div>
<div className={classNames(
s['logo-icon'],
'mx-auto mb-3 w-12 h-12 bg-white rounded-xl border-[0.5px] border-gray-200',
)} />
<Dify className='mx-auto mb-2' />
<Image
alt='logo'
src={logoUrl}
className='mx-auto mb-2 w-auto h-10'
/>
<div className='mb-3 text-center text-xs font-normal text-gray-500'>Version {langeniusVersionInfo?.current_version}</div>
<div className='mb-4 text-center text-xs font-normal text-gray-700'>
<div>© 2023 LangGenius, Inc., Contributors.</div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use client'
import { useState } from 'react'
import cn from 'classnames'
import useSWR from 'swr'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import relativeTime from 'dayjs/plugin/relativeTime'
import { useContext } from 'use-context-selector'
import { UserPlusIcon } from '@heroicons/react/24/outline'
import { useTranslation } from 'react-i18next'
import s from './index.module.css'
import InviteModal from './invite-modal'
import InvitedModal from './invited-modal'
import Operation from './operation'
Expand Down Expand Up @@ -40,7 +38,6 @@ const MembersPage = () => {
<>
<div>
<div className='flex items-center mb-4 p-3 bg-gray-50 rounded-2xl'>
<div className={cn(s['logo-icon'], 'shrink-0')}></div>
<div className='grow mx-2'>
<div className='text-sm font-medium text-gray-900'>{currentWorkspace?.name}</div>
<div className='text-xs text-gray-500'>{t('common.userProfile.workspace')}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

.emailBackground {
background-color: white !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const InviteModal = ({
}, [role, emails, notify, onCancel, onSend, t])

return (
<div className={s.wrap}>
<Modal overflowVisible isShow onClose={() => {}} className={s.modal}>
<div className={cn(s.wrap)}>
<Modal overflowVisible isShow onClose={() => {}} className={cn(s.modal)} wrapperClassName='z-20'>
<div className='flex justify-between mb-2'>
<div className='text-xl font-semibold text-gray-900'>{t('common.members.inviteTeamMember')}</div>
<XMarkIcon className='w-4 h-4 cursor-pointer' onClick={onCancel} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const InvitedModal = ({

return (
<div className={s.wrap}>
<Modal isShow onClose={() => {}} className={s.modal}>
<Modal isShow onClose={() => {}} className={s.modal} wrapperClassName='z-20'>
<div className='flex justify-between mb-3'>
<div className='
w-12 h-12 flex items-center justify-center rounded-xl
Expand Down
Binary file removed web/app/components/header/assets/logo-icon.png
Binary file not shown.
6 changes: 0 additions & 6 deletions web/app/components/header/assets/logo-text.svg

This file was deleted.

Binary file removed web/app/components/header/assets/logo.png
Binary file not shown.
7 changes: 0 additions & 7 deletions web/app/components/header/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
border-top: 4px solid #06AED4;
}

.logo {
width: 96px;
height: 40px;
background: url(~@/app/components/share/chat/welcome/icons/logo.png) center center no-repeat;
background-size: contain;
}

.alpha {
width: 12px;
height: 12px;
Expand Down
10 changes: 7 additions & 3 deletions web/app/components/header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use client'

import Link from 'next/link'
import Image from 'next/image'
import logoUrl from '../../../public/logo/logo-site.png'
import AccountDropdown from './account-dropdown'
import AppNav from './app-nav'
import DatasetNav from './dataset-nav'
import EnvNav from './env-nav'
import ExploreNav from './explore-nav'
import GithubStar from './github-star'
import PluginNav from './plugin-nav'
import s from './index.module.css'
import { WorkspaceProvider } from '@/context/workspace-context'
import { useAppContext } from '@/context/app-context'

Expand All @@ -24,9 +25,12 @@ const Header = () => {
<>
<div className='flex items-center'>
<Link href="/apps" className='flex items-center mr-4'>
<div className={s.logo} />
<Image
src={logoUrl}
className='w-auto h-10'
alt='logo'
/>
</Link>
{/* @ts-expect-error Async Server Component */}
<GithubStar />
</div>
<div className='flex items-center'>
Expand Down
Binary file removed web/app/components/share/chat/welcome/icons/logo.png
Binary file not shown.
8 changes: 7 additions & 1 deletion web/app/components/share/chat/welcome/massive-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import type { FC } from 'react'
import React from 'react'
import cn from 'classnames'
import { useTranslation } from 'react-i18next'
import Image from 'next/image'
import {
PencilIcon,
} from '@heroicons/react/24/solid'
import logoUrl from '../../../../../public/logo/logo-site.png'
import s from './style.module.css'
import type { SiteInfo } from '@/models/share'
import Button from '@/app/components/base/button'
Expand Down Expand Up @@ -69,5 +71,9 @@ export const EditBtn = ({ className, onClick }: { className?: string; onClick: (
}

export const FootLogo = () => (
<div className={s.logo} />
<Image
src={logoUrl}
className='w-auto h-5'
alt='logo'
/>
)
7 changes: 0 additions & 7 deletions web/app/components/share/chat/welcome/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@

.customBtn {
width: 136px;
}

.logo {
width: 48px;
height: 20px;
background: url(./icons/logo.png) center center no-repeat;
background-size: contain;
}
22 changes: 0 additions & 22 deletions web/app/components/share/chatbot/icons/dify-header.svg

This file was deleted.

11 changes: 0 additions & 11 deletions web/app/components/share/chatbot/icons/dify.svg

This file was deleted.

Loading

0 comments on commit 84acff4

Please sign in to comment.