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: support Moonshot AI #1232

Merged
merged 3 commits into from
Feb 6, 2024
Merged

✨ feat: support Moonshot AI #1232

merged 3 commits into from
Feb 6, 2024

Conversation

arvinxx
Copy link
Contributor

@arvinxx arvinxx commented Feb 5, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

Moonshot 今天发布 API 开放平台,尝试了下 1 小时完成接入:

image

📝 补充信息 | Additional Information

以此为示例,验证一下现有的链路,接入一个新 Provider 大致的流程和步骤。

服务端:

  1. 服务端环境变量 :config/server/provider.ts 新增 MOONSHOT_API_KEY 等环境变量;
  2. Moonshot 运行时 libs/agent-runtime 新增 LobeMoonshotAI ,
  • 实现 initchat 两个方法;
  • 完善相应的 InvalidMoonshotAPIKeyMoonshotBizError 两个错误状态
  1. 路由定义: api/chat/[provider]/agentRuntime.ts 新增 moonshotRuntime 初始化逻辑(客户端key 与 环境变量)
  2. 服务端配置: api/config/route.ts 定义 Provider 默认开启逻辑
  3. 错误响应状态码处理: api/errorResponse.ts 定义 MoonshotBizError 状态码

客户端:

  1. 模型元数据定义(config/modelProviders),补充完善相应的模型元信息
  2. 模型设置: types/settings/modelProvider 定义 MoonshotConfig,在 const/settings 设定默认值;
  3. 取数 seletors: store/global/slices/settings/selector/modelProvider.ts 补充取数 selector (enableMoonshot、 moonshotAPIKey)
  4. 前端鉴权 token: services/_auth 补充获取 apiKey 相关逻辑;
  5. 模型UI (模型选择器、模型 Tag ):
    • Provider Logo: components/ModelProviderIcon 更新
    • Model Logo: components/ModelIcon 更新
    • Model Tag: components/ModelTag 更新
  6. 错误处理 features/Conversation/Error 新增一种对应的 APIKeyForm
  7. 全局模型设置 app/settings/llm 新增一个配置组件(可以拷贝复用 Zhipu )

Copy link

vercel bot commented Feb 5, 2024

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

Name Status Preview Comments Updated (UTC)
lobe-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2024 7:45am

@lobehubbot
Copy link
Member

👍 @arvinxx

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.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Attention: 71 lines in your changes are missing coverage. Please review.

Comparison is base (2d133e9) 86.86% compared to head (115d80f) 86.37%.
Report is 1 commits behind head on main.

Files Patch % Lines
src/libs/agent-runtime/moonshot/index.ts 20.73% 65 Missing ⚠️
src/services/_auth.ts 0.00% 4 Missing ⚠️
src/app/api/errorResponse.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1232      +/-   ##
==========================================
- Coverage   86.86%   86.37%   -0.50%     
==========================================
  Files         212      214       +2     
  Lines       10395    10540     +145     
  Branches     1134     1140       +6     
==========================================
+ Hits         9030     9104      +74     
- Misses       1365     1436      +71     

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

@arvinxx arvinxx merged commit a6de202 into main Feb 6, 2024
8 of 10 checks passed
@arvinxx arvinxx deleted the feat/moonshoot branch February 6, 2024 08:03
@lobehubbot
Copy link
Member

❤️ Great PR @arvinxx ❤️

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 Feb 6, 2024
## [Version 0.124.0](v0.123.4...v0.124.0)
<sup>Released on **2024-02-06**</sup>

#### ✨ Features

- **misc**: Support Moonshot AI Provider.

<br/>

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

#### What's improved

* **misc**: Support Moonshot AI Provider, closes [#1232](#1232) ([a6de202](a6de202))

</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 0.124.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gijigae pushed a commit to gijigae/lobe-chat that referenced this pull request Feb 6, 2024
* ✨ feat: support moonshot

* 📝 docs: update documents

* 🎨 chore: clean code
gijigae pushed a commit to gijigae/lobe-chat that referenced this pull request Feb 6, 2024
## [Version&nbsp;0.124.0](lobehub/lobe-chat@v0.123.4...v0.124.0)
<sup>Released on **2024-02-06**</sup>

#### ✨ Features

- **misc**: Support Moonshot AI Provider.

<br/>

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

#### What's improved

* **misc**: Support Moonshot AI Provider, closes [lobehub#1232](lobehub#1232) ([a6de202](lobehub@a6de202))

</details>

<div align="right">

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

</div>
github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Feb 6, 2024
## [Version&nbsp;1.6.0](v1.5.3...v1.6.0)
<sup>Released on **2024-02-06**</sup>

#### ✨ Features

- **misc**: Support Moonshot AI Provider.

#### 🐛 Bug Fixes

- **misc**: Fix non-https `crypto.subtile` missing error, fix rename.

#### 💄 Styles

- **misc**: Add moonshot i18n, improve clear topic tips, improve direction UX.

<br/>

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

#### What's improved

* **misc**: Support Moonshot AI Provider, closes [lobehub#1232](https://github.com/bentwnghk/lobe-chat/issues/1232) ([a6de202](a6de202))

#### What's fixed

* **misc**: Fix non-https `crypto.subtile` missing error, closes [lobehub#1238](https://github.com/bentwnghk/lobe-chat/issues/1238) ([1750d0b](1750d0b))
* **misc**: Fix rename ([c94391e](c94391e))

#### Styles

* **misc**: Add moonshot i18n, closes [lobehub#1251](https://github.com/bentwnghk/lobe-chat/issues/1251) ([4b6663b](4b6663b))
* **misc**: Improve clear topic tips, closes [lobehub#1247](https://github.com/bentwnghk/lobe-chat/issues/1247) ([2d133e9](2d133e9))
* **misc**: Improve direction UX, closes [lobehub#1169](https://github.com/bentwnghk/lobe-chat/issues/1169) ([e3929dc](e3929dc))

</details>

<div align="right">

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

</div>
OskarMast added a commit to OskarMast/OpenAI_Integraion_platform that referenced this pull request Apr 5, 2024
## [Version&nbsp;0.124.0](lobehub/lobe-chat@v0.123.4...v0.124.0)
<sup>Released on **2024-02-06**</sup>

#### ✨ Features

- **misc**: Support Moonshot AI Provider.

<br/>

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

#### What's improved

* **misc**: Support Moonshot AI Provider, closes [#1232](lobehub/lobe-chat#1232) ([a6de202](lobehub/lobe-chat@a6de202))

</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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants