feat: Added GitHub provider support and models.

- Added a new SVG logo for the GitHub provider.
- Added a new social media platform provider to the SYSTEM_MODELS configuration.
- Added support for Github provider in the application configuration.
- Added two new translation keys: 'github' with 'GitHub Models' and updated the existing key 'graphrag-kylin-mountain'.
- Added width parameter to EditModelsPopup configuration.
- Added GitHub-specific model handling to OpenAIProvider class.
- Incremented the application version to 25.
- Added support for a new LLM model type.
- Added a new migration step to configure and enable a GitHub LLM provider.
This commit is contained in:
kangfenmao 2024-09-11 19:08:40 +08:00
parent 4c96324ef7
commit 7e8687decd
9 changed files with 77 additions and 4 deletions

View File

@ -0,0 +1,3 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M16 0C7.16 0 0 7.16 0 16C0 23.08 4.58 29.06 10.94 31.18C11.74 31.32 12.04 30.84 12.04 30.42C12.04 30.04 12.02 28.78 12.02 27.44C8 28.18 6.96 26.46 6.64 25.56C6.46 25.1 5.68 23.68 5 23.3C4.44 23 3.64 22.26 4.98 22.24C6.24 22.22 7.14 23.4 7.44 23.88C8.88 26.3 11.18 25.62 12.1 25.2C12.24 24.16 12.66 23.46 13.12 23.06C9.56 22.66 5.84 21.28 5.84 15.16C5.84 13.42 6.46 11.98 7.48 10.86C7.32 10.46 6.76 8.82 7.64 6.62C7.64 6.62 8.98 6.2 12.04 8.26C13.32 7.9 14.68 7.72 16.04 7.72C17.4 7.72 18.76 7.9 20.04 8.26C23.1 6.18 24.44 6.62 24.44 6.62C25.32 8.82 24.76 10.46 24.6 10.86C25.62 11.98 26.24 13.4 26.24 15.16C26.24 21.3 22.5 22.66 18.94 23.06C19.52 23.56 20.02 24.52 20.02 26.02C20.02 28.16 20 29.88 20 30.42C20 30.84 20.3 31.34 21.1 31.18C27.42 29.06 32 23.06 32 16C32 7.16 24.84 0 16 0V0Z" fill="#24292E"/>
</svg>

After

Width:  |  Height:  |  Size: 959 B

View File

@ -117,6 +117,14 @@ export const SYSTEM_MODELS: Record<string, Model[]> = {
group: 'DeepSeek Coder'
}
],
github: [
{
id: 'gpt-4o',
provider: 'github',
name: 'OpenAI GPT-4o',
group: 'OpenAI'
}
],
yi: [
{
id: 'yi-large',

View File

@ -25,6 +25,7 @@ import DashScopeProviderLogo from '@renderer/assets/images/providers/dashscope.p
import DeepSeekProviderLogo from '@renderer/assets/images/providers/deepseek.png'
import DoubaoProviderLogo from '@renderer/assets/images/providers/doubao.png'
import GeminiProviderLogo from '@renderer/assets/images/providers/gemini.png'
import GithubProviderLogo from '@renderer/assets/images/providers/github.svg'
import GraphRagProviderLogo from '@renderer/assets/images/providers/graph-rag.png'
import GroqProviderLogo from '@renderer/assets/images/providers/groq.png'
import MinimaxProviderLogo from '@renderer/assets/images/providers/minimax.png'
@ -76,6 +77,8 @@ export function getProviderLogo(providerId: string) {
return GraphRagProviderLogo
case 'minimax':
return MinimaxProviderLogo
case 'github':
return GithubProviderLogo
default:
return undefined
}
@ -183,6 +186,22 @@ export const PROVIDER_CONFIG = {
logo: DeepSeekProviderLogo
}
},
github: {
api: {
url: 'https://models.inference.ai.azure.com/'
},
websites: {
official: 'https://github.com/marketplace/models',
apiKey: 'https://github.com/settings/tokens',
docs: 'https://docs.github.com/en/github-models',
models: 'https://github.com/marketplace/models'
},
app: {
name: 'Github Models',
url: 'https://github.com/marketplace/models/azure-openai/gpt-4o/playground',
logo: GithubProviderLogo
}
},
yi: {
api: {
url: 'https://api.lingyiwanwu.com'

View File

@ -136,7 +136,8 @@ const resources = {
stepfun: 'StepFun',
doubao: 'Doubao',
minimax: 'MiniMax',
'graphrag-kylin-mountain': 'GraphRAG'
'graphrag-kylin-mountain': 'GraphRAG',
github: 'GitHub Models'
},
settings: {
title: 'Settings',
@ -391,7 +392,8 @@ const resources = {
stepfun: '阶跃星辰',
doubao: '豆包',
minimax: 'MiniMax',
'graphrag-kylin-mountain': 'GraphRAG'
'graphrag-kylin-mountain': 'GraphRAG',
github: 'GitHub Models'
},
settings: {
title: '设置',

View File

@ -155,7 +155,8 @@ const onShowModelInfo = (model: Model) => {
title: model.name,
content: model?.description,
icon: null,
maskClosable: true
maskClosable: true,
width: 600
})
}

View File

@ -178,6 +178,17 @@ export default class OpenAIProvider extends BaseProvider {
public async models(): Promise<OpenAI.Models.Model[]> {
try {
const response = await this.sdk.models.list()
if (this.provider.id === 'github') {
// @ts-ignore key is not typed
return response.body.map((model) => ({
id: model.name,
description: model.summary,
object: 'model',
owned_by: model.publisher
}))
}
return response.data
} catch (error) {
return []

View File

@ -22,7 +22,7 @@ const persistedReducer = persistReducer(
{
key: 'cherry-studio',
storage,
version: 24,
version: 25,
blacklist: ['runtime'],
migrate
},

View File

@ -77,6 +77,15 @@ const initialState: LlmState = {
isSystem: true,
enabled: false
},
{
id: 'github',
name: 'Github Models',
apiKey: '',
apiHost: 'https://models.inference.ai.azure.com/',
models: SYSTEM_MODELS.github,
isSystem: true,
enabled: false
},
{
id: 'yi',
name: 'Yi',

View File

@ -399,6 +399,26 @@ const migrateConfig = {
topicPosition: 'right'
}
}
},
'25': (state: RootState) => {
return {
...state,
llm: {
...state.llm,
providers: [
...state.llm.providers,
{
id: 'github',
name: 'Github Models',
apiKey: '',
apiHost: 'https://models.inference.ai.azure.com/',
models: SYSTEM_MODELS.github,
isSystem: true,
enabled: false
}
]
}
}
}
}