feat: Add support for SiliconFlow provider charge and knowledge base improvements
This commit is contained in:
parent
e1a04030b5
commit
cb3db57d2f
@ -165,6 +165,7 @@ export class WindowService {
|
||||
|
||||
const oauthProviderUrls = [
|
||||
'https://account.siliconflow.cn/oauth',
|
||||
'https://cloud.siliconflow.cn/expensebill',
|
||||
'https://aihubmix.com/oauth',
|
||||
'https://aihubmix.com/topup'
|
||||
]
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
export const DEFAULT_TEMPERATURE = 1.0
|
||||
export const DEFAULT_CONTEXTCOUNT = 5
|
||||
export const DEFAULT_MAX_TOKENS = 4096
|
||||
export const DEFAULT_KNOWLEDGE_DOCUMENT_COUNT = 6
|
||||
export const FONT_FAMILY =
|
||||
"Ubuntu, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif"
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { WarningOutlined } from '@ant-design/icons'
|
||||
import { TopView } from '@renderer/components/TopView'
|
||||
import { DEFAULT_KNOWLEDGE_DOCUMENT_COUNT } from '@renderer/config/constant'
|
||||
import { getEmbeddingMaxContext } from '@renderer/config/embedings'
|
||||
import { isEmbeddingModel } from '@renderer/config/models'
|
||||
import { useKnowledge } from '@renderer/hooks/useKnowledge'
|
||||
@ -59,7 +60,7 @@ const PopupContainer: React.FC<Props> = ({ base: _base, resolve }) => {
|
||||
const newBase = {
|
||||
...base,
|
||||
name: values.name,
|
||||
documentCount: values.documentCount,
|
||||
documentCount: values.documentCount || DEFAULT_KNOWLEDGE_DOCUMENT_COUNT,
|
||||
chunkSize: values.chunkSize,
|
||||
chunkOverlap: values.chunkOverlap
|
||||
}
|
||||
@ -89,6 +90,7 @@ const PopupContainer: React.FC<Props> = ({ base: _base, resolve }) => {
|
||||
onCancel={onCancel}
|
||||
afterClose={onClose}
|
||||
destroyOnClose
|
||||
maskClosable={false}
|
||||
centered>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item
|
||||
|
||||
@ -22,7 +22,7 @@ import { isProviderSupportAuth, isProviderSupportCharge } from '@renderer/servic
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setModel } from '@renderer/store/assistants'
|
||||
import { Model, ModelType, Provider } from '@renderer/types'
|
||||
import { aihubmixCharge } from '@renderer/utils/oauth'
|
||||
import { providerCharge } from '@renderer/utils/oauth'
|
||||
import { Avatar, Button, Card, Checkbox, Divider, Flex, Input, Popover, Space, Switch } from 'antd'
|
||||
import Link from 'antd/es/typography/Link'
|
||||
import { groupBy, isEmpty } from 'lodash'
|
||||
@ -272,12 +272,14 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
||||
</Space.Compact>
|
||||
{apiKeyWebsite && (
|
||||
<SettingHelpTextRow style={{ justifyContent: 'space-between' }}>
|
||||
<HStack gap={10}>
|
||||
<HStack gap={5}>
|
||||
<SettingHelpLink target="_blank" href={apiKeyWebsite}>
|
||||
{t('settings.provider.get_api_key')}
|
||||
</SettingHelpLink>
|
||||
{isProviderSupportCharge(provider) && (
|
||||
<SettingHelpLink onClick={aihubmixCharge}>{t('settings.provider.charge')}</SettingHelpLink>
|
||||
<SettingHelpLink onClick={() => providerCharge(provider.id)}>
|
||||
{t('settings.provider.charge')}
|
||||
</SettingHelpLink>
|
||||
)}
|
||||
</HStack>
|
||||
<SettingHelpText>{t('settings.provider.api_key.tip')}</SettingHelpText>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import type { ExtractChunkData } from '@llm-tools/embedjs-interfaces'
|
||||
import { DEFAULT_KNOWLEDGE_DOCUMENT_COUNT } from '@renderer/config/constant'
|
||||
import { getEmbeddingMaxContext } from '@renderer/config/embedings'
|
||||
import AiProvider from '@renderer/providers/AiProvider'
|
||||
import { FileType, KnowledgeBase, KnowledgeBaseParams, Message } from '@renderer/types'
|
||||
@ -90,13 +91,13 @@ export const getKnowledgeReferences = async (base: KnowledgeBase, message: Messa
|
||||
})
|
||||
)
|
||||
|
||||
const documentCount = base.documentCount || 6
|
||||
const documentCount = base.documentCount || DEFAULT_KNOWLEDGE_DOCUMENT_COUNT
|
||||
|
||||
const references = await Promise.all(
|
||||
take(_searchResults, documentCount).map(async (item, index) => {
|
||||
const baseItem = base.items.find((i) => i.uniqueId === item.metadata.uniqueLoaderId)
|
||||
return {
|
||||
id: index,
|
||||
id: index + 1,
|
||||
content: item.pageContent,
|
||||
sourceUrl: await getKnowledgeSourceUrl(item),
|
||||
type: baseItem?.type
|
||||
|
||||
@ -21,6 +21,6 @@ export function isProviderSupportAuth(provider: Provider) {
|
||||
}
|
||||
|
||||
export function isProviderSupportCharge(provider: Provider) {
|
||||
const supportProviders = ['aihubmix']
|
||||
const supportProviders = ['silicon', 'aihubmix']
|
||||
return supportProviders.includes(provider.id)
|
||||
}
|
||||
|
||||
@ -58,11 +58,25 @@ export const oauthWithAihubmix = async (setKey) => {
|
||||
window.addEventListener('message', messageHandler)
|
||||
}
|
||||
|
||||
export const aihubmixCharge = async () => {
|
||||
const chargeUrl = `https://aihubmix.com/topup?client_id=cherry_studio_oauth&lang=${getLanguageCode()}&aff=SJyh`
|
||||
export const providerCharge = async (provider: string) => {
|
||||
const chargeUrlMap = {
|
||||
silicon: {
|
||||
url: 'https://cloud.siliconflow.cn/expensebill',
|
||||
width: 900,
|
||||
height: 700
|
||||
},
|
||||
aihubmix: {
|
||||
url: `https://aihubmix.com/topup?client_id=cherry_studio_oauth&lang=${getLanguageCode()}&aff=SJyh`,
|
||||
width: 720,
|
||||
height: 900
|
||||
}
|
||||
}
|
||||
|
||||
const { url, width, height } = chargeUrlMap[provider]
|
||||
|
||||
window.open(
|
||||
chargeUrl,
|
||||
url,
|
||||
'oauth',
|
||||
'width=720,height=900,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,alwaysOnTop=yes,alwaysRaised=yes'
|
||||
`width=${width},height=${height},toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,alwaysOnTop=yes,alwaysRaised=yes`
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user