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 Spark model provider #3098

Merged
merged 46 commits into from
Sep 10, 2024
Merged

✨ feat: Add Spark model provider #3098

merged 46 commits into from
Sep 10, 2024

Conversation

hezhijie0327
Copy link
Contributor

@hezhijie0327 hezhijie0327 commented Jul 1, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

基于 #2804 实现支持讯飞星火大模型

讯飞的 API 比较特殊,APIKey:APISecret 8月改用 APIPassword

https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html#_3-%E8%AF%B7%E6%B1%82%E8%AF%B4%E6%98%8E

📝 补充信息 | Additional Information

image
image
image
image

Copy link

vercel bot commented Jul 1, 2024

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

A member of the Team first needs to authorize it.

@lobehubbot
Copy link
Member

👍 @hezhijie0327

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 Jul 1, 2024

Codecov Report

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

Project coverage is 91.83%. Comparing base (dd7c8df) to head (c189428).
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    #3098      +/-   ##
==========================================
- Coverage   91.83%   91.83%   -0.01%     
==========================================
  Files         455      457       +2     
  Lines       30452    30557     +105     
  Branches     2116     1968     -148     
==========================================
+ Hits        27965    28061      +96     
- Misses       2487     2496       +9     
Flag Coverage Δ
app 91.83% <91.50%> (-0.01%) ⬇️
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.

@arvinxx
Copy link
Contributor

arvinxx commented Jul 1, 2024

配置页面是不是应该改成 APIKey 和 APISecret 分开配置比较合适?不然用户很有可能会配错

@lobehubbot
Copy link
Member

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


Should the configuration page be changed to configure APIKey and APISecret separately? Otherwise, the user is likely to mismatch the

@hezhijie0327
Copy link
Contributor Author

逻辑都通了,自动将 APIKey 与 API Secret 合并成完整 API

但是遇到个问题,这个文言显示搞不明白
image

@arvinxx
Copy link
Contributor

arvinxx commented Jul 1, 2024

@lobehubbot
Copy link
Member

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


Is it locale? Reference here to add i18n:

https://github.com/lobehub/lobe-chat/blob/main/src/locales/default/modelProvider.ts#L22-L48

@hezhijie0327
Copy link
Contributor Author

是 locale 吗? 参考这里补充 i18n:

https://github.com/lobehub/lobe-chat/blob/main/src/locales/default/modelProvider.ts#L22-L48

放进去了 但是貌似没调用 不清楚哪里写错了

@lobehubbot
Copy link
Member

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


Is it locale? Reference here to add i18n:

https://github.com/lobehub/lobe-chat/blob/main/src/locales/default/modelProvider.ts#L22-L48

I put it in, but it doesn’t seem to be called. I’m not sure where I made the mistake.

@arvinxx
Copy link
Contributor

arvinxx commented Jul 1, 2024

@hezhijie0327 dev没用还是prod没用?prod没用的话需要 npm run i18n 去自动生成其他语言的 locale

@lobehubbot
Copy link
Member

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


@hezhijie0327 Is dev useless or prod useless? If prod is useless, you need npm run i18n to automatically generate locales in other languages.

@hezhijie0327
Copy link
Contributor Author

@hezhijie0327 dev没用还是prod没用?prod没用的话需要 npm run i18n 去自动生成其他语言的 locale

dev 下本地 Build,这应该是缺省值吧,缺少 locale 的话应该也能显示的吧。我先跑下 npm run i18n 看看

@lobehubbot
Copy link
Member

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


@hezhijie0327 Is dev useless or prod useless? If prod is not used, you need npm run i18n to automatically generate locales in other languages.

Local Build under dev, this should be the default value. If locale is missing, it should also be displayed. Let me run npm run i18n first to see

@arvinxx
Copy link
Contributor

arvinxx commented Jul 1, 2024

dev 下本地 Build,这应该是缺省值吧,缺少 locale 的话应该也能显示的吧

没,故意做成不显示的,不然发布版本默认兜底成中文的话,没法让开发者意识到要跑 locale: https://github.com/lobehub/lobe-chat/blob/main/src/locales/create.ts#L21-L25

这样一来 build 过的生产版本,如果没有 locale 必然就只会显示 locale key ,更容易发现没国际化的问题。

@lobehubbot
Copy link
Member

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


Local Build under dev. This should be the default value. If locale is missing, it should also be displayed.

No, it is not displayed on purpose. Otherwise, if the release version defaults to Chinese, it will not make developers realize that they need to run locale: https://github.com/lobehub/lobe-chat/blob/main/src/locales /create.ts#L21-L25

In this way, the built production version will only display the locale key if there is no locale, making it easier to find problems without internationalization.

@hezhijie0327
Copy link
Contributor Author

dev 下本地 Build,这应该是缺省值吧,缺少 locale 的话应该也能显示的吧

没,故意做成不显示的,不然发布版本默认兜底成中文的话,没法让开发者意识到要跑 locale: https://github.com/lobehub/lobe-chat/blob/main/src/locales/create.ts#L21-L25

这样一来 build 过的生产版本,如果没有 locale 必然就只会显示 locale key ,更容易发现没国际化的问题。

懂了,其实一直都没 BUG 哈哈哈
image

@lobehubbot
Copy link
Member

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


Local Build under dev. This should be the default value. If locale is missing, it should also be displayed.

No, it is not displayed on purpose. Otherwise, if the release version defaults to Chinese, it will not make developers realize that they need to run the locale: https://github.com/lobehub/lobe-chat/blob/main/src/ locales/create.ts#L21-L25

In this way, the built production version will only display the locale key if there is no locale, making it easier to find problems without internationalization.

Got it, actually there has never been a bug hahaha
image

@hezhijie0327
Copy link
Contributor Author

hezhijie0327 commented Jul 1, 2024

FYI. 已修复 provider Avatar 问题
image

@lobehubbot
Copy link
Member

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


FYI. provider Avatar issue fixed

@hezhijie0327
Copy link
Contributor Author

hezhijie0327 commented Jul 2, 2024

暂时禁用 Lite 和 V2.0 模型,开了工单给讯飞,其余模型均可正常工作
image
感觉他们 API 没做好,模型处任意填写都能过然后 Fallback 到 Pro 模型

curl -i -k -X POST 'https://spark-api-open.xf-yun.com/v1/chat/completions' \
--header 'Authorization: Bearer apiKey:apiSecret' \
--header 'Content-Type: application/json' \
--data '{
    "model":"general", // general, generalv2
    "messages": [
        {
            "role": "user",
            "content": "Hi"
        }
    ]
}'

image

@lobehubbot
Copy link
Member

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


Temporarily disable the Lite and V2.0 models and open a work order to iFlytek. All other models can work normally.
image
I feel like their API is not done well. You can fill in any part of the model and then fallback to the Pro model.

curl -i -k -X POST 'https://spark-api-open.xf-yun.com/v1/chat/completions' \
--header 'Authorization: Bearer apiKey:apiSecret' \
--header 'Content-Type: application/json' \
--data '{
    "model":"general", // general, generalv2
    "messages": [
        {
            "role": "user",
            "content": "Hi"
        }
    ]
}'

@hezhijie0327
Copy link
Contributor Author

最近讯飞做了 Break Change... 改用了每个模型独立 APIPassword,原先 APIKey:APISecret 不再可用
image

@hezhijie0327
Copy link
Contributor Author

Rollback 自定义 API 表单为通用 OpenAI 表单以适配最新的讯飞 HTTP SDK

吐槽一下,控制台中每个模型的 APIPassword 显示不同,但是实际通用,又是个神奇的 BUG
image
image

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Aug 28, 2024
@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 Aug 28, 2024
@arvinxx arvinxx merged commit fc85c20 into lobehub:main Sep 10, 2024
7 of 8 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @hezhijie0327 ❤️

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 10, 2024
## [Version&nbsp;1.16.0](v1.15.35...v1.16.0)
<sup>Released on **2024-09-10**</sup>

#### ✨ Features

- **misc**: Add Fireworks AI Model Provider, Add Spark model provider.

<br/>

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

#### What's improved

* **misc**: Add Fireworks AI Model Provider, closes [#3392](#3392) [#48](#48) ([fa0d84d](fa0d84d))
* **misc**: Add Spark model provider, closes [#3098](#3098) [#25](#25) ([fc85c20](fc85c20))

</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.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@hezhijie0327 hezhijie0327 deleted the spark branch September 11, 2024 01:57
github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Sep 11, 2024
## [Version&nbsp;1.59.0](v1.58.16...v1.59.0)
<sup>Released on **2024-09-11**</sup>

#### ✨ Features

- **misc**: Add Fireworks AI Model Provider, Add Spark model provider.

#### 🐛 Bug Fixes

- **misc**: Add `LLM_VISION_IMAGE_USE_BASE64` to support local s3 in vision model.

#### 💄 Styles

- **ui**: Improve UI layout and text.
- **misc**: Reorder the provider list, Update CustomLogo, update spark check model to spark-lite & default disable useless model, update Upstage model list.

<br/>

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

#### What's improved

* **misc**: Add Fireworks AI Model Provider, closes [lobehub#3392](https://github.com/bentwnghk/lobe-chat/issues/3392) [lobehub#48](https://github.com/bentwnghk/lobe-chat/issues/48) ([fa0d84d](fa0d84d))
* **misc**: Add Spark model provider, closes [lobehub#3098](https://github.com/bentwnghk/lobe-chat/issues/3098) [lobehub#25](https://github.com/bentwnghk/lobe-chat/issues/25) ([fc85c20](fc85c20))

#### What's fixed

* **misc**: Add `LLM_VISION_IMAGE_USE_BASE64` to support local s3 in vision model, closes [lobehub#3887](https://github.com/bentwnghk/lobe-chat/issues/3887) ([16e57ed](16e57ed))

#### Styles

* **ui**: Improve UI layout and text, closes [lobehub#3762](https://github.com/bentwnghk/lobe-chat/issues/3762) ([7c08f29](7c08f29))
* **misc**: Reorder the provider list, closes [lobehub#3886](https://github.com/bentwnghk/lobe-chat/issues/3886) ([4d641f5](4d641f5))
* **misc**: Update CustomLogo, closes [lobehub#3874](https://github.com/bentwnghk/lobe-chat/issues/3874) ([dd7c8df](dd7c8df))
* **misc**: Update spark check model to spark-lite & default disable useless model, closes [lobehub#3885](https://github.com/bentwnghk/lobe-chat/issues/3885) ([9d7e47c](9d7e47c))
* **misc**: Update Upstage model list, closes [lobehub#3890](https://github.com/bentwnghk/lobe-chat/issues/3890) ([82e2570](82e2570))

</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
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.

3 participants