-
Notifications
You must be signed in to change notification settings - Fork 844
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
适配讯飞星火4.0模型,新增讯飞星火自定义prompt功能 #239
Open
printlndarling
wants to merge
2
commits into
wangrongding:main
Choose a base branch
from
printlndarling:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,10 @@ const appID = env.XUNFEI_APP_ID | |
const apiKey = env.XUNFEI_API_KEY | ||
const apiSecret = env.XUNFEI_API_SECRET | ||
// 地址必须填写,代表着大模型的版本号!!!!!!!!!!!!!!!! | ||
const httpUrl = new URL('https://spark-api.xf-yun.com/v3.5/chat') | ||
const httpUrl = new URL('https://spark-api.xf-yun.com/v4.0/chat') | ||
|
||
// 新增用户自定义prompt设定 | ||
const prompt = env.XUNFEI_PROMPT | ||
|
||
let modelDomain // V1.1-V3.5动态获取,高于以上版本手动指定 | ||
function authenticate() { | ||
|
@@ -29,6 +32,15 @@ function authenticate() { | |
case '/v3.5/chat': | ||
modelDomain = 'generalv3.5' | ||
break | ||
case '/chat/pro-128k': | ||
modelDomain = 'pro-128k' | ||
break | ||
case '/chat/max-32k': | ||
modelDomain = 'max-32k' | ||
break | ||
case '/v4.0/chat': | ||
modelDomain = '4.0Ultra' | ||
break | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
|
@@ -77,8 +89,9 @@ export async function xunfeiSendMsg(inputVal) { | |
// 如果想获取结合上下文的回答,需要开发者每次将历史问答信息一起传给服务端,如下示例 | ||
// 注意:text里面的所有content内容加一起的tokens需要控制在8192以内,开发者如有较长对话需求,需要适当裁剪历史信息 | ||
text: [ | ||
{ role: 'user', content: '你是谁' }, //# 用户的历史问题 | ||
{ role: 'assistant', content: '你是一个专业的智能助手' }, //# AI的历史回答结果 | ||
// { role: 'user', content: '你是谁' }, //# 用户的历史问题 | ||
{ role: 'system', content: prompt }, //# 自行设定的prompt | ||
// { role: 'assistant', content: '你是一个专业的智能助手' }, //# AI的历史回答结果 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里做一下兼容处理,如果没填自定义 prompt 还用之前的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prompt已做处理 |
||
// ....... 省略的历史对话 | ||
{ role: 'user', content: inputVal }, //# 最新的一条问题,如无需上下文,可只传最新一条问题 | ||
], | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是现在将版本号放到 env 里去配置更好,因为默认的会导致部分用户不看代码,不知道为什么匹配不上模型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改,.env里面也有说明