lobe-chat
lobe-chat copied to clipboard
:sparkles: feat: support anthropic as model provider
💻 变更类型 | Change Type
- [x] ✨ feat
- [ ] 🐛 fix
- [ ] ♻️ refactor
- [ ] 💄 style
- [ ] 🔨 chore
- [ ] ⚡️ perf
- [ ] 📝 docs
🔀 变更说明 | Description of Change
Added a new model provider, Anthropic, along with the 3 models it currently provides.
📝 补充信息 | Additional Information
Anthropic API Geographic Restrictions
Here is a list of locations that Anthropic API supports: https://docs.anthropic.com/claude/reference/supported-regions.
If a lobe-chat service happens to be deployed to a location that it doesn't support, it will not work and it will return 403 errors. For example, you may notice that it doesn't always work on Vercel.ai because Vercel deploys code to its edge server around the world and usually uses the edge server that is closest to your location to serve your requests, and some of its edge servers may not be allowed to make requests to Anthropic API.
Different API Parameters
As far as I know, Anthropic API doesn't seem to support these parameters: presence_penalty, frequency_penalty
. Therefore these settings do not affect Anthropic models.
@danielglh is attempting to deploy a commit to the LobeHub Team on Vercel.
A member of the Team first needs to authorize it.
👍 @danielglh
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.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。
Codecov Report
Attention: Patch coverage is 86.92308%
with 34 lines
in your changes are missing coverage. Please review.
Project coverage is 92.37%. Comparing base (
aaedfa7
) to head (035e6dd
). Report is 2 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1409 +/- ##
==========================================
- Coverage 92.48% 92.37% -0.12%
==========================================
Files 227 230 +3
Lines 12022 12278 +256
Branches 1457 1483 +26
==========================================
+ Hits 11119 11342 +223
- Misses 903 936 +33
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thanks for your PR! A really nice work. Most of codes are LGTM. Please rebase the main branch and add a test for this provider~ (you can refer to MoonshotAI 's test)
Cool. I've rebased main branch and made necessary changes. Regarding test, Anthropic API is not compatible with OpenAI API so it probably takes more time to work on it. I noticed that other providers that are not compatible with OpenAI API don't have tests either. Not sure where to find a better reference.
@danielglh I will add the google provider test soon. And you can use the simmliar method to add tests:
@arvinxx sure will take a look
Hmm probably need to take some time to check how the streaming should be implemented. For some reason it's quite unstable.
@danielglh what's the mean of the streaming is unstable?
@danielglh what's the mean of the streaming is unstable?
@arvinxx for some reason the response stream was cut randomly when it was deployed to Vercel for preview
@arvinxx I think it might be limitations of the edge servers Vercel uses for preview. The streaming works perfectly fine when I run lobe-chat locally and on a remote dev server I have.
@danielglh I know there is a timeout of stream on vercel, but I don't know the accurate value.
Thanks for your PR! A really nice work. Most of codes are LGTM. Please rebase the main branch and add a test for this provider~ (you can refer to MoonshotAI 's test)
@arvinxx tests added for Anthropic, plz check again
Now claude-3.0 is released
@ckt1031 yes, @danielglh can we support Anthropic's new model in the PR?
@ckt1031 yes, @danielglh can we support Anthropic's new model in the PR?
I believe not only adding the new model, but also support vision feature by Claude 3.0 😅.
@ckt1031 yes, @danielglh can we support Anthropic's new model in the PR?
I believe not only adding the new model, but also support vision feature by Claude 3.0 😅.
I have supported the vision
@danielglh can you fix the test of anthropic test? I think the rest is well done enough to ship.
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 | Mar 5, 2024 2:39pm |
@danielglh can you fix the test of anthropic test? I think the rest is well done enough to ship.
@arvinxx tests fixed
@arvinxx I'm testing this on Vercel and still experiencing weird streaming problems:
Any suggestions? Cannot reproduce the issue in the local dev environment. It runs perfectly fine locally.
Found it ... not sure if it is a Vercel issue or an Anthropic SDK issue yet.
https://github.com/anthropics/anthropic-sdk-typescript/issues/292
I would suggest that we go ahead and ship this first. Not everyone uses Vercel. We just need to make it clear that there's a known issue with Vercel (maybe include it in the document?).
@danielglh I agree.
@arvinxx documents updated regarding the known issue with Anthropic SDK on Vercel/Cloudflare edge runtime.
❤️ Great PR @danielglh ❤️
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 消息。
:tada: This PR is included in version 0.132.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: