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 SenseNova (商汤) model provider #4162

Merged
merged 59 commits into from
Oct 25, 2024

Conversation

hezhijie0327
Copy link
Contributor

@hezhijie0327 hezhijie0327 commented Sep 26, 2024

💻 变更类型 | Change Type

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

🔀 变更说明 | Description of Change

  1. 使用 OpenAI 兼容模式,初步实现对话
  2. 覆写 frequency_penaltytop_p 范围 [TODO] https://console.sensecore.cn/help/docs/model-as-a-service/nova/chat/ChatCompletions/ChatCompletion
  3. 禁用客户端模式,不支持
  4. 更新模型列表,版本 [TODO]
  5. 添加商汤图标 [TODO] [Request] 帮忙增加下 SenseChat (SenseNova / SenseCore) 模型 Icon lobe-icons#43
  6. APIToken 计算逻辑如下
    a. 输入 AccessKeyIDAccessKeySecret,使用 : 进行拼接存入 apiKey
    b. 计算时以 : 进行拆分,并按照官网文档参数进行 JWT 计算,并返回 apiKey
    c. APIToken 有效期为当前时间的 -5s 至 +1800s,每次对话前会重新计算

Note:
1. 获取临时 TOKEN:https://console.sensecore.cn/iam/Security/private-security
2. 创建有效期 TOKEN: https://console.sensecore.cn/help/docs/model-as-a-service/nova/overview/Authorization
3. SenseChat-Vision 不支持 Base64 URL

📝 补充信息 | Additional Information

对话
image
工具调用
image
多模态
image
模型列表
image
image

Copy link

vercel bot commented Sep 26, 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 Sep 26, 2024

Codecov Report

Attention: Patch coverage is 92.50000% with 24 lines in your changes missing coverage. Please review.

Project coverage is 92.29%. Comparing base (852dd47) to head (9d9f82d).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/services/_auth.ts 14.28% 12 Missing ⚠️
src/server/modules/AgentRuntime/index.ts 10.00% 9 Missing ⚠️
src/libs/agent-runtime/AgentRuntime.ts 57.14% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #4162    +/-   ##
========================================
  Coverage   92.29%   92.29%            
========================================
  Files         493      496     +3     
  Lines       35906    36226   +320     
  Branches     3268     3445   +177     
========================================
+ Hits        33140    33436   +296     
- Misses       2766     2790    +24     
Flag Coverage Δ
app 92.29% <92.50%> (+<0.01%) ⬆️
server 97.33% <ø> (ø)

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.

@lobehubbot
Copy link
Member

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


Codecov Report

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

Project coverage is 92.49%. Comparing base (40d347f) to head (68dd185).

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    #4162      +/-   ##
==========================================
+ Coverage   92.48%   92.49%   +0.01%     
==========================================
  Files         482      484       +2     
  Lines       34488    34664     +176     
  Branches     3231     2139    -1092     
==========================================
+ Hits        31896    32063     +167     
- Misses       2592     2601       +9     
Flag Coverage Δ
app 92.49% <94.88%> (+0.01%) ⬆️
server ?

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.

@LovelyGuYiMeng
Copy link
Contributor

LovelyGuYiMeng commented Sep 26, 2024

商汤的话,根据模型和体量,我建议放在零一万物和阶跃星辰中间
模型排序推荐如下样式:
SenseChat 5.5
SenseChat 5.5 Vision
SenseChat 5.0 Cantonese
SenseChat 5.0 Turbo
SenseChat 4.0
SenseChat 4.0 32k
SenseChat 4.0 128k
SenseChat Character
SenseChat Character Pro
默认开启就除了Cantonese和Character都开吧

@lobehubbot
Copy link
Member

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


As for Shangtang, based on the model and volume, I suggest placing it between Zero One Thing and Stepping Stars.
The following style is recommended for model sorting:
SenseChat 5.5
SenseChat 5.0 (128K)
SenseChat 5.0 Cantonese
SenseChat 5.0 Turbo
SenseChat 5.0 Vision
SenseChat 4.0
SenseChat 4.0 32k
SenseChat Character
SenseChat Character Pro
5.5, 5.0 (except Cantonese), 4.0 and Character are not enabled by default.

@LovelyGuYiMeng
Copy link
Contributor

128K模型是4.0,vision模型是5.5
image
image

@lobehubbot
Copy link
Member

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


The 128K model is 4.0 and the vision model is 5.5
image
image

@hezhijie0327
Copy link
Contributor Author

欸 这个等计算 API_TOKEN 这个做完并过去再改,先放 TODO...

商汤这个非固定 API Key 有点意思

@lobehubbot
Copy link
Member

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


Well, wait until the calculation of API_TOKEN is completed and then change it. Put TODO first...

SenseTime’s non-fixed API Key is a bit interesting

@hezhijie0327
Copy link
Contributor Author

@LovelyGuYiMeng 这个模型版本有点歧义,官网的几个文档信息貌似没同步... 由于模型广场中有更新时间,采信度较高,目前以这个为主

https://console.sensecore.cn/help/docs/model-as-a-service/nova/model/llm/GeneralLLM
image

https://platform.sensenova.cn/doc?path=/model/llm/GeneralLLM.md
image

https://console.sensecore.cn/aistudio/plaza?sort=sort_default&page=1&size=24
image

@lobehubbot
Copy link
Member

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


@LovelyGuYiMeng This model version is a bit ambiguous. Several document information on the official website seems to be out of sync... Since there is an update time in the model square, it has a high degree of acceptance. Currently, this is the main one.

https://console.sensecore.cn/help/docs/model-as-a-service/nova/model/llm/GeneralLLM
image

https://platform.sensenova.cn/doc?path=/model/llm/GeneralLLM.md
image

https://console.sensecore.cn/aistudio/plaza?sort=sort_default&page=1&size=24
image

@hezhijie0327 hezhijie0327 marked this pull request as ready for review September 27, 2024 14:11
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🌠 Feature Request New feature or request | 特性与建议 labels Sep 27, 2024
@LovelyGuYiMeng
Copy link
Contributor

LovelyGuYiMeng commented Sep 27, 2024

我个人感觉https://platform.sensenova.cn/doc?path=/model/llm/GeneralLLM.md 的正确
另外你再看这个价格列表的模型版本号,也是一样https://platform.sensenova.cn/pricing
再不确定的话我已经发邮件问商汤支持了,等回复看看也行

@lobehubbot
Copy link
Member

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


I personally feel that https://platform.sensenova.cn/doc?path=/model/llm/GeneralLLM.md is correct
In addition, if you look at the model version number of this price list, it is the same https://platform.sensenova.cn/pricing
If you are still unsure, I have already sent an email to ask SenseTime for support. I will wait and see for the reply.

Copy link

vercel bot commented Oct 21, 2024

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

Name Status Preview Comments Updated (UTC)
lobe-chat-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 25, 2024 1:03pm

@arvinxx arvinxx merged commit 7a4e0b3 into lobehub:main Oct 25, 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 消息。

@hezhijie0327 hezhijie0327 deleted the sensecore branch October 25, 2024 13:07
github-actions bot pushed a commit that referenced this pull request Oct 25, 2024
## [Version&nbsp;1.24.0](v1.23.1...v1.24.0)
<sup>Released on **2024-10-25**</sup>

#### ✨ Features

- **misc**: Add SenseNova (商汤) model provider.

<br/>

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

#### What's improved

* **misc**: Add SenseNova (商汤) model provider, closes [#4162](#4162) ([7a4e0b3](7a4e0b3))

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

The release is available on:

Your semantic-release bot 📦🚀

@LovelyGuYiMeng
Copy link
Contributor

image
vision模型有问题

@lobehubbot
Copy link
Member

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


image
There is a problem with the vision model

@hezhijie0327
Copy link
Contributor Author

已知问题见 PR 备注,API Endpoint 不支持 Base64 格式图片,需要设置 LLM_VISION_IMAGE_USE_BASE64="0"
image

@LovelyGuYiMeng
Copy link
Contributor

已知问题见 PR 备注,API Endpoint 不支持 Base64 格式图片,需要设置 LLM_VISION_IMAGE_USE_BASE64="0" image

但是我不发图片光文字也报错

@lobehubbot
Copy link
Member

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


For known issues, see the PR note. API Endpoint does not support Base64 format images, so you need to set LLM_VISION_IMAGE_USE_BASE64="0" ![image](https://private-user-images.githubusercontent.com/58100052/380191624-9c6d48a3- 99f4-479f-9806-935fcadaa379.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..hSL6Zy9yZ--Nsz1xODpkEBTXD_vE2CtMMSSirqgYP1Y)

But I get an error even if I don’t send pictures, just text.

@hezhijie0327
Copy link
Contributor Author

我试了下,他这模型对话必须得带图片... 这个限制无解

#!/bin/bash

#API_ENDPOINT="https://api.sensenova.cn/compatible-mode/v1/chat/completions"
API_ENDPOINT="https://api.sensenova.cn/v1/llm/chat-completions"
API_KEY=""
MODEL="SenseChat-Vision"

JSON_PAYLOAD=$(cat <<EOF
{
  "model": "$MODEL",
  "messages": [
    {
      "role": "user",
      "content": "Hi"
    }
  ],
  "stream": false
}
EOF
)

curl --request POST "${API_ENDPOINT}" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d "$JSON_PAYLOAD"

image

@lobehubbot
Copy link
Member

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


I tried it, but his model dialogue must include pictures... There is no solution to this restriction.

#!/bin/bash

#API_ENDPOINT="https://api.sensenova.cn/compatible-mode/v1/chat/completions"
API_ENDPOINT="https://api.sensenova.cn/v1/llm/chat-completions"
API_KEY=""
MODEL="SenseChat-Vision"

JSON_PAYLOAD=$(cat <<EOF
{
  "model": "$MODEL",
  "messages": [
    {
      "role": "user",
      "content": "Hi"
    }
  ],
  "stream": false
}
EOF
)

curl --request POST "${API_ENDPOINT}" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d "$JSON_PAYLOAD"

image

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Oct 25, 2024
## [Version&nbsp;1.67.0](v1.66.1...v1.67.0)
<sup>Released on **2024-10-25**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor the Google Gen AI.

#### ✨ Features

- **misc**: Add SenseNova (商汤) model provider.

<br/>

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

#### Code refactoring

* **misc**: Refactor the Google Gen AI, closes [lobehub#4484](https://github.com/bentwnghk/lobe-chat/issues/4484) ([b890e8d](b890e8d))

#### What's improved

* **misc**: Add SenseNova (商汤) model provider, closes [lobehub#4162](https://github.com/bentwnghk/lobe-chat/issues/4162) ([7a4e0b3](7a4e0b3))

</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
🌠 Feature Request New feature or request | 特性与建议 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.

4 participants