Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: add Github Models provider #3869

Merged
merged 13 commits into from
Sep 18, 2024

Conversation

CloudPassenger
Copy link
Contributor

@CloudPassenger CloudPassenger commented Sep 9, 2024

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

Support Github Models as LLM model provider

📝 补充信息 | Additional Information

  • Add GithubModel to ProviderCombine in @lobehub/icons

Copy link

vercel bot commented Sep 9, 2024

@CloudPassenger is attempting to deploy a commit to the LobeHub Pro Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Sep 9, 2024
@lobehubbot
Copy link
Member

👍 @CloudPassenger

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@dosubot dosubot bot added the Model Provider 模型服务商 label Sep 9, 2024
Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 96.66667% with 9 lines in your changes missing coverage. Please review.

Project coverage is 92.21%. Comparing base (5ccc41d) to head (06cc702).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/app/api/chat/agentRuntime.ts 14.28% 6 Missing ⚠️
src/libs/agent-runtime/AgentRuntime.ts 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3869      +/-   ##
==========================================
+ Coverage   92.18%   92.21%   +0.03%     
==========================================
  Files         464      466       +2     
  Lines       31862    32132     +270     
  Branches     3022     3175     +153     
==========================================
+ Hits        29371    29631     +260     
- Misses       2491     2501      +10     
Flag Coverage Δ
app 92.21% <96.66%> (+0.03%) ⬆️
server 97.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-database ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 18, 2024 5:20pm
lobe-chat-preview 🛑 Canceled (Inspect) Sep 18, 2024 5:20pm

@canisminor1990
Copy link
Member

  • Add GithubModel to ProviderCombine in @lobehub/icons

@arvinxx
Copy link
Contributor

arvinxx commented Sep 10, 2024

@CloudPassenger rebase 下main, ProviderAvatar 这个收到组件里去了

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@CloudPassenger rebase under main, ProviderAvatar is received in the component

@CloudPassenger
Copy link
Contributor Author

@CloudPassenger rebase 下main, ProviderAvatar 这个收到组件里去了

已经 rebase,麻烦查阅了,谢谢

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@CloudPassenger rebase under main, ProviderAvatar is received in the component

Already rebase, please check it, thank you

@arvinxx
Copy link
Contributor

arvinxx commented Sep 11, 2024

image

确定一下是用 Token 还是 API Key

@CloudPassenger
Copy link
Contributor Author

image 确定一下是用 Token 还是 API Key

const apiKeyItem: FormItemProps[] = !showApiKey
? []
: (apiKeyItems ?? [
{
children: (
<Input.Password
autoComplete={'new-password'}
placeholder={t(`llm.apiKey.placeholder`, { name })}
/>
),
desc: t(`llm.apiKey.desc`, { name }),
label: t(`llm.apiKey.title`),
name: [KeyVaultsConfigKey, id, LLMProviderApiTokenKey],
},
]);

是 Github Token,但我查看了一下并没有给不同 Provider 配置显示的选项,如果我在这里添加根据 id 显示不同文字的逻辑,并且更新 i18n 的话,会是一个好的实践吗?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


image 确定一下是用 Token 还是 API Key

const apiKeyItem: FormItemProps[] = !showApiKey
? []
: (apiKeyItems ?? [
{
children: (
<Input.Password
autoComplete={'new-password'}
placeholder={t(`llm.apiKey.placeholder`, { name })}
/>
),
desc: t(`llm.apiKey.desc`, { name }),
label: t(`llm.apiKey.title`),
name: [KeyVaultsConfigKey, id, LLMProviderApiTokenKey],
},
]);

是 Github Token,但我查看了一下并没有给不同 Provider 配置显示的选项,如果我在这里添加根据 id i18n 的话,会是一个好的实践吗?

@arvinxx
Copy link
Contributor

arvinxx commented Sep 11, 2024

如果我在这里添加根据 id 显示不同文字的逻辑,并且更新 i18n 的话,会是一个好的实践吗?

这个方案不太好,建议是参考 Azure 或者 Bedrock 的方案,外部覆写下 apiKeyItems

apiKeyItems: [
{
children: (
<Input.Password
autoComplete={'new-password'}
placeholder={t(`${providerKey}.accessKeyId.placeholder`)}
/>
),
desc: t(`${providerKey}.accessKeyId.desc`),
label: t(`${providerKey}.accessKeyId.title`),
name: [KeyVaultsConfigKey, providerKey, 'accessKeyId'],
},

针对 Github 这个再单独加 i18n 比较好

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Is it a good practice if I add logic here to display different text based on id and update i18n?

This solution is not very good. It is recommended to refer to Azure or Bedrock’s solution and externally overwrite apiKeyItems:

apiKeyItems: [
{
children: (
<Input.Password
autoComplete={'new-password'}
placeholder={t(`${providerKey}.accessKeyId.placeholder`)}
/>
),
desc: t(`${providerKey}.accessKeyId.desc`),
label: t(`${providerKey}.accessKeyId.title`),
name: [KeyVaultsConfigKey, providerKey, 'accessKeyId'],
},

For Github, it is better to add i18n separately.

@LovelyGuYiMeng
Copy link
Contributor

QQ20240912-110258
QQ20240912-110327
请注意排序务必相同,不要一个在Deepseek后面一个在Openrouter后面

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


QQ20240912-110258
QQ20240912-110327
Please note that the ordering must be the same, not one after Deepseek and one after Openrouter.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Sep 12, 2024
@CloudPassenger
Copy link
Contributor Author

I have made some changes for this feature. Please review.
If you have any other suggestions, please don't hesitate to let me know. I will get back to you as soon as possible. Thanks!

Copy link
Contributor

@LovelyGuYiMeng LovelyGuYiMeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把GoogleProviderCard放到BedrockProviderCard后面,不要乱改顺序

src/app/(main)/settings/llm/ProviderList/providers.tsx Outdated Show resolved Hide resolved
@arvinxx
Copy link
Contributor

arvinxx commented Sep 13, 2024

@CloudPassenger

  1. Rebase 下
  2. 改成缩写吧? GitHub PAT ,不然看着太长了,被裁剪了。 然后 desc 那边最好加个超链接直接跳创建 Github PAT 的地方?
Google Chrome 2024-09-13 23 31 59

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


  1. Under Rebase
  2. Change it to an abbreviation? GitHub PAT, otherwise it will look too long and will be cropped. Then desc is it best to add a hyperlink to jump directly to the place where Github PAT is created?
Google Chrome 2024-09-13 23 31 59

Adds support for configuring the GitHub provider in the LLM settings. It includes:

- A new `useGithubProvider` hook to define the GitHub provider configuration
- Integration of the GitHub provider in the provider list
- Localization strings for the GitHub personal access token input

The changes allow users to enter their GitHub personal access token to use GitHub-related LLM features.
Adds support for handling invalid Github Personal Access Tokens:

- Adds a new `InvalidGithubToken` error type in the `AgentRuntimeErrorType` enum
- Adds an error message for `InvalidGithubToken` in the localization files
- Configures the Github AI provider to use the new error type

This allows properly handling and displaying errors when an invalid Github token is provided.
@CloudPassenger
Copy link
Contributor Author

@CloudPassenger

  1. Rebase 下
  2. 改成缩写吧? GitHub PAT ,不然看着太长了,被裁剪了。 然后 desc 那边最好加个超链接直接跳创建 Github PAT 的地方?
Google Chrome 2024-09-13 23 31 59

感谢提醒,已经修复并添加,中秋快乐🥮

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@CloudPassenger

  1. Rebase Next
  2. Change it to an abbreviation? GitHub PAT, otherwise it will look too long and will be cropped. Then desc is it best to add a hyperlink to jump directly to the place where Github PAT is created?
Google Chrome 2024-09-13 23 31 59

Thanks for the reminder, it has been fixed and added. Happy Mid-Autumn Festival🥮

@vercel vercel bot temporarily deployed to Preview – lobe-chat-preview September 18, 2024 16:55 Inactive
@arvinxx arvinxx merged commit 8eac1bd into lobehub:main Sep 18, 2024
6 of 8 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @CloudPassenger ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

github-actions bot pushed a commit that referenced this pull request Sep 18, 2024
## [Version&nbsp;1.19.0](v1.18.2...v1.19.0)
<sup>Released on **2024-09-18**</sup>

#### ✨ Features

- **misc**: Add Ai21Labs model provider, add Github Models provider, support native Artifacts just like Claude.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add Ai21Labs model provider, closes [#3727](#3727) ([d2fe0f0](d2fe0f0))
* **misc**: Add Github Models provider, closes [#3869](#3869) ([8eac1bd](8eac1bd))
* **misc**: Support native Artifacts just like Claude, closes [#3985](#3985) ([0c42c46](0c42c46))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.19.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Sep 19, 2024
## [Version&nbsp;1.62.0](v1.61.0...v1.62.0)
<sup>Released on **2024-09-19**</sup>

#### ✨ Features

- **misc**: Add Ai21Labs model provider, add Github Models provider, support native Artifacts just like Claude.

#### 🐛 Bug Fixes

- **misc**: Fix InterceptingRoutes in discover.

#### 💄 Styles

- **misc**: Add mistral provider new models.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add Ai21Labs model provider, closes [lobehub#3727](https://github.com/bentwnghk/lobe-chat/issues/3727) ([d2fe0f0](d2fe0f0))
* **misc**: Add Github Models provider, closes [lobehub#3869](https://github.com/bentwnghk/lobe-chat/issues/3869) ([8eac1bd](8eac1bd))
* **misc**: Support native Artifacts just like Claude, closes [lobehub#3985](https://github.com/bentwnghk/lobe-chat/issues/3985) ([0c42c46](0c42c46))

#### What's fixed

* **misc**: Fix InterceptingRoutes in discover, closes [lobehub#4011](https://github.com/bentwnghk/lobe-chat/issues/4011) ([2b75040](2b75040))

#### Styles

* **misc**: Add mistral provider new models, closes [lobehub#4014](https://github.com/bentwnghk/lobe-chat/issues/4014) ([0b70d57](0b70d57))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
cy948 pushed a commit to cy948/lobe-chat that referenced this pull request Sep 21, 2024
* ✨ feat: add Github Models as provider

* :bug fix: sort order of ProviderList

* 💄 style: add more info for Github Models provider

* ✨ feat: Add GitHub provider configuration

Adds support for configuring the GitHub provider in the LLM settings. It includes:

- A new `useGithubProvider` hook to define the GitHub provider configuration
- Integration of the GitHub provider in the provider list
- Localization strings for the GitHub personal access token input

The changes allow users to enter their GitHub personal access token to use GitHub-related LLM features.

* 🐛 fix: use Github Personal access tokens (classic) instead

* 💄 style: Add Invalid Github Token error type and message

Adds support for handling invalid Github Personal Access Tokens:

- Adds a new `InvalidGithubToken` error type in the `AgentRuntimeErrorType` enum
- Adds an error message for `InvalidGithubToken` in the localization files
- Configures the Github AI provider to use the new error type

This allows properly handling and displaying errors when an invalid Github token is provided.

* ✅ test: fix test for new error type

* 🐛 fix: sort order of ProviderCards

* 💄 style: use abbreviation for Github PAT

* 💄 style: add the hyperlink for creating Github PAT

* 🌐 chore: improve desc

* ✅ test: update test

---------

Co-authored-by: arvinxx <arvinx@foxmail.com>
cy948 pushed a commit to cy948/lobe-chat that referenced this pull request Sep 21, 2024
## [Version&nbsp;1.19.0](lobehub/lobe-chat@v1.18.2...v1.19.0)
<sup>Released on **2024-09-18**</sup>

#### ✨ Features

- **misc**: Add Ai21Labs model provider, add Github Models provider, support native Artifacts just like Claude.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add Ai21Labs model provider, closes [lobehub#3727](lobehub#3727) ([d2fe0f0](lobehub@d2fe0f0))
* **misc**: Add Github Models provider, closes [lobehub#3869](lobehub#3869) ([8eac1bd](lobehub@8eac1bd))
* **misc**: Support native Artifacts just like Claude, closes [lobehub#3985](lobehub#3985) ([0c42c46](lobehub@0c42c46))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Model Provider 模型服务商 released size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants