mirror of
https://github.com/LLM-Red-Team/kimi-free-api.git
synced 2024-12-22 21:09:20 +08:00
修复url解析
This commit is contained in:
parent
6284628d99
commit
cc0ea384a7
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kimi-free-api",
|
"name": "kimi-free-api",
|
||||||
"version": "0.0.3",
|
"version": "0.0.5",
|
||||||
"description": "Kimi Free Server",
|
"description": "Kimi Free Server",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -126,13 +126,17 @@ async function createCompletionStream(messages: any[], refreshToken: string, use
|
|||||||
|
|
||||||
function messagesPrepare(messages: any[]) {
|
function messagesPrepare(messages: any[]) {
|
||||||
const content = messages.reduce((content, message) => {
|
const content = messages.reduce((content, message) => {
|
||||||
return content += `${message.role || 'user'}:${message.content}\n`;
|
return content += `${message.role || 'user'}:${wrapUrlsToTags(message.content)}\n`;
|
||||||
}, '');
|
}, '');
|
||||||
return [
|
return [
|
||||||
{ role: 'user', content }
|
{ role: 'user', content }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wrapUrlsToTags(content: string) {
|
||||||
|
return content.replace(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi, url => `<url id="" type="url" status="" title="" wc="">${url}</url>`);
|
||||||
|
}
|
||||||
|
|
||||||
function checkResult(result: AxiosResponse, refreshToken: string) {
|
function checkResult(result: AxiosResponse, refreshToken: string) {
|
||||||
if(result.status == 401) {
|
if(result.status == 401) {
|
||||||
accessTokenMap.delete(refreshToken);
|
accessTokenMap.delete(refreshToken);
|
||||||
|
Loading…
Reference in New Issue
Block a user