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 multiple API Keys #1345

Merged
merged 13 commits into from
Feb 27, 2024
Merged

Conversation

luoweihua7
Copy link
Contributor

@luoweihua7 luoweihua7 commented Feb 21, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

启动时支持传入多个API Keys,通过Key之间使用英文逗号分割。接口调用时,API Keys支持随机(random)或者轮训(turn)方式获取。

增加参数 API_KEY_SELECT_MODE,用于控制Keys的选择模式。参数说明

  • random 随机从提供的Keys中获取一个
  • turn 按照提供的Keys顺序轮训获取
  • 其他值 使用第一个Key(注:空字符串也属于其他值的一种)
  • 不配置参数,使用 random 随机模式

📝 补充信息 | Additional Information

[RFC] 027 - API Key 字段支持使用多个Key

暂不支持请求失败时,使用下一个Key重新发起请求。

Copy link

vercel bot commented Feb 21, 2024

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

A member of the Team first needs to authorize it.

@lobehubbot
Copy link
Member

👍 @luoweihua7

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

@arvinxx arvinxx changed the title feat: Support multiple API Keys ✨ feat: Support multiple API Keys Feb 21, 2024
@arvinxx arvinxx changed the title ✨ feat: Support multiple API Keys ✨ feat: support OpenAI multiple API Keys Feb 21, 2024
@arvinxx arvinxx changed the title ✨ feat: support OpenAI multiple API Keys ✨ feat: support multiple API Keys Feb 21, 2024
Copy link
Contributor

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

麻烦按照 review 优化下实现~

src/app/api/chat/[provider]/agentRuntime.ts Outdated Show resolved Hide resolved
src/app/api/chat/[provider]/agentRuntime.ts Outdated Show resolved Hide resolved
src/app/api/chat/keyManager.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.39%. Comparing base (42ea0f5) to head (150d715).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1345      +/-   ##
==========================================
+ Coverage   86.33%   86.39%   +0.06%     
==========================================
  Files         217      218       +1     
  Lines       11059    11109      +50     
  Branches     1177     1186       +9     
==========================================
+ Hits         9548     9598      +50     
  Misses       1511     1511              

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

Copy link

vercel bot commented Feb 23, 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 27, 2024 3:55am

Copy link
Contributor

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

LGTM, I'll merge it. Great work~

@arvinxx arvinxx merged commit 17c5da3 into lobehub:main Feb 27, 2024
6 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @luoweihua7 ❤️

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 27, 2024
## [Version 0.130.0](v0.129.6...v0.130.0)
<sup>Released on **2024-02-27**</sup>

#### ✨ Features

- **misc**: Support multiple API Keys.

<br/>

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

#### What's improved

* **misc**: Support multiple API Keys, closes [#1345](#1345) ([17c5da3](17c5da3))

</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.130.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 Feb 27, 2024
## [Version&nbsp;1.12.0](v1.11.7...v1.12.0)
<sup>Released on **2024-02-27**</sup>

#### ✨ Features

- **misc**: Support multiple API Keys.

<br/>

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

#### What's improved

* **misc**: Support multiple API Keys, closes [lobehub#1345](https://github.com/bentwnghk/lobe-chat/issues/1345) ([17c5da3](17c5da3))

</details>

<div align="right">

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

</div>
573dave pushed a commit to 573dave/lobe-chat that referenced this pull request Mar 5, 2024
* ✨ feat: Support multiple API keys [RFC 027]

* 📝 docs: add env variable API_KEY_SELECT_MODE

* 🔧 chore: Adjust the parameter API_KEY_SELECT_MODE to be optional

* 🔧 fix: Adjustments made according to Code Review requirements

* ✅ test: add test for ApiKeyManager

* 🔧 fix: Support for multiple API Keys from user input on the client side

* 🔧 chore: handle Perplexity API Key

* 🔧 chore: update OpenAI or Azure API Key select

* 🔧 chore: update OpenAI or Azure API Key select
573dave pushed a commit to 573dave/lobe-chat that referenced this pull request Mar 5, 2024
## [Version&nbsp;0.130.0](lobehub/lobe-chat@v0.129.6...v0.130.0)
<sup>Released on **2024-02-27**</sup>

#### ✨ Features

- **misc**: Support multiple API Keys.

<br/>

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

#### What's improved

* **misc**: Support multiple API Keys, closes [lobehub#1345](lobehub#1345) ([17c5da3](lobehub@17c5da3))

</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.130.0](lobehub/lobe-chat@v0.129.6...v0.130.0)
<sup>Released on **2024-02-27**</sup>

#### ✨ Features

- **misc**: Support multiple API Keys.

<br/>

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

#### What's improved

* **misc**: Support multiple API Keys, closes [#1345](lobehub/lobe-chat#1345) ([17c5da3](lobehub/lobe-chat@17c5da3))

</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
3 participants