songquanpeng / one-api

OpenAI 接口管理 & 分发系统,支持 Azure、Anthropic Claude、Google PaLM 2 & Gemini、智谱 ChatGLM、百度文心一言、讯飞星火认知、阿里通义千问、360 智脑以及腾讯混元,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用. OpenAI key management & redistribution system, using a single API for all LLMs, and features an English UI.
https://openai.justsong.cn/
MIT License
17.93k stars 4.06k forks source link

FastGPT使用文心一言 API,应用配置上知识库的时候,对话会出错! oneapi-0.5.2-alpha.5 oneapi-0.5.3-alpha.1 实测都不行-更新到 FastGPT-4.0 版本使用Embeding-V1 还是同样错误 #369

Closed muzibaby closed 1 year ago

muzibaby commented 1 year ago

例行检查

问题描述 使用 FastGPT main 最新分支,配置 oneapi之后了,使用 ChatGPT 对话正常,但是使用文心一言之后,给应用配置了知识库之后,会话就会发生错误。 复现步骤 请求消息体如下: Sending request with body: {

model: 'gpt-3.5-turbo-16k',

apiKey: 'sk-5sslNl97GBDKY4P81173A3Bc6fBd4a05Be0826B9F1D0EdA9',

temperature: 0,

maxToken: 4000,

messages: [

{

 obj: 'System',

 value: '知识库:\n' +

   '1: [李逵,唐原王,唐代宗李豫第十九子,唐德宗李适异母弟。大历十年,田承嗣不臣,而昭靖夭,无强王,帝乃悉王诸子,领诸镇军,威天下。于是以逵为原王,并开府仪同三司,然不出閤。大和六年薨。\n' +

   ']'

},

{

 obj: 'Human',

 value: '知识库是关于 文心一言测试 的内容,参考知识库回答问题。与 "文心一言测试" 无关内容,直接回复: "我不知道"。'

},

{ _id: '64ccd019ab86e5f6b04db0a7', obj: 'Human', value: '李逵' }

],

stream: true,

res: ServerResponse {

_events: [Object: null prototype] {

 finish: [Function: bound resOnFinish],

 close: [Function (anonymous)],

 error: [Function (anonymous)]

},

_eventsCount: 3,

_maxListeners: undefined,

outputData: [],

outputSize: 0,

writable: true,

destroyed: false,

_last: false,

chunkedEncoding: false,

shouldKeepAlive: true,

maxRequestsOnConnectionReached: false,

_defaultKeepAlive: true,

useChunkedEncodingByDefault: true,

sendDate: true,

_removedConnection: false,

_removedContLen: false,

_removedTE: false,

strictContentLength: false,

_contentLength: null,

_hasBody: true,

_trailer: '',

finished: false,

_headerSent: false,

_closed: false,

socket: Socket {

 connecting: false,

 _hadError: false,

 _parent: null,

 _host: null,

 _closeAfterHandlingError: false,

 _readableState: [ReadableState],

 _events: [Object: null prototype],

 _eventsCount: 8,

 _maxListeners: undefined,

 _writableState: [WritableState],

 allowHalfOpen: true,

 _sockname: null,

 _pendingData: null,

 _pendingEncoding: '',

 server: [Server],

 _server: [Server],

 parser: [HTTPParser],

 on: [Function: socketListenerWrap],

 addListener: [Function: socketListenerWrap],

 prependListener: [Function: socketListenerWrap],

 setEncoding: [Function: socketSetEncoding],

 _paused: false,

 _httpMessage: [Circular *1],

 timeout: 0,

 [Symbol(async_id_symbol)]: 12007,

 [Symbol(kHandle)]: [TCP],

 [Symbol(lastWriteQueueSize)]: 0,

 [Symbol(timeout)]: Timeout {

   _idleTimeout: -1,

   _idlePrev: null,

   _idleNext: null,

   _idleStart: 182520,

   _onTimeout: null,

   _timerArgs: undefined,

   _repeat: null,

   _destroyed: true,

   [Symbol(refed)]: false,

   [Symbol(kHasPrimitive)]: false,

   [Symbol(asyncId)]: 12030,

   [Symbol(triggerId)]: 12028

 },

 [Symbol(kBuffer)]: null,

 [Symbol(kBufferCb)]: null,

 [Symbol(kBufferGen)]: null,

 [Symbol(kCapture)]: false,

 [Symbol(kSetNoDelay)]: true,

 [Symbol(kSetKeepAlive)]: false,

 [Symbol(kSetKeepAliveInitialDelay)]: 0,

 [Symbol(kBytesRead)]: 0,

 [Symbol(kBytesWritten)]: 0

},

_header: null,

_keepAliveTimeout: 5000,

_onPendingData: [Function: bound updateOutgoingData],

req: IncomingMessage {

 _readableState: [ReadableState],

 _events: [Object: null prototype],

 _eventsCount: 2,

 _maxListeners: undefined,

 socket: [Socket],

 httpVersionMajor: 1,

 httpVersionMinor: 1,

 httpVersion: '1.1',

 complete: true,

 rawHeaders: [Array],

 rawTrailers: [],

 joinDuplicateHeaders: null,

 aborted: false,

 upgrade: false,

 url: '/api/openapi/v1/chat/completions',

 method: 'POST',

 statusCode: null,

 statusMessage: null,

 client: [Socket],

 _consuming: true,

 _dumped: false,

 cookies: [Getter/Setter],

 query: {},

 previewData: [Getter/Setter],

 preview: [Getter/Setter],

 body: [Object],

 [Symbol(kCapture)]: false,

 [Symbol(kHeaders)]: [Object],

 [Symbol(kHeadersCount)]: 28,

 [Symbol(kTrailers)]: null,

 [Symbol(kTrailersCount)]: 0,

 [Symbol(NextRequestMeta)]: [Object]

},

_sent100: false,

_expect_continue: false,

_maxRequestsPerSocket: 0,

setHeader: [Function (anonymous)],

statusCode: 200,

flush: [Function: flush],

write: [Function (anonymous)],

end: [Function (anonymous)],

on: [Function: on],

writeHead: [Function: writeHead],

status: [Function (anonymous)],

send: [Function (anonymous)],

json: [Function (anonymous)],

redirect: [Function (anonymous)],

setPreviewData: [Function (anonymous)],

clearPreviewData: [Function (anonymous)],

revalidate: [Function (anonymous)],

[Symbol(kOutHeaders)]: [Object: null prototype] {

 'access-control-allow-origin': [Array],

 vary: [Array]

},

}

}

api response time: 1.216s

{

message: 'the length of messages must be an odd number',

type: 'baidu_error',

param: '',

code: 336003

}

预期结果 希望可以正常使用知识库对话的功能 相关截图 如果没有的话,请删除此节。

songquanpeng commented 1 year ago

但是为什么其他人可以呢?可以到群里先沟通问一下

songquanpeng commented 1 year ago

有删除聊天记录吗?这个之前已经适配过 system message 了。

如果问题能复现依旧存在,欢迎重开 issue

muzibaby commented 1 year ago

您自己试过吗? Regards, Vigo Song
---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2023年08月10日 01:02 | | 收件人 | songquanpeng/one-api @.> | | 抄送人 | vigo @.>, Author @.> | | 主题 | Re: [songquanpeng/one-api] FastGPT使用文心一言 API,应用配置上知识库的时候,对话会出错! oneapi-0.5.2-alpha.5 oneapi-0.5.3-alpha.1 实测都不行 (Issue #369) |

但是为什么其他人可以呢?可以到群里先沟通问一下

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

songquanpeng commented 1 year ago

我自己没有环境,我问过部署过的人,确定能复现才会开始 debug

muzibaby commented 1 year ago

好的,谢谢,我再确认下 Regards, Vigo Song
---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2023年08月13日 11:43 | | 收件人 | songquanpeng/one-api @.> | | 抄送人 | vigo @.>, Author @.> | | 主题 | Re: [songquanpeng/one-api] FastGPT使用文心一言 API,应用配置上知识库的时候,对话会出错! oneapi-0.5.2-alpha.5 oneapi-0.5.3-alpha.1 实测都不行 (Issue #369) |

我自己没有环境,我问过部署过的人,确定能复现才会开始 debug

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

muzibaby commented 1 year ago

更新了 FastGPT-3.9.4 配合 oneapi-0.5.3-alpha.1 ,清空了数据,重新创建应用,知识库,关联知识库后,对话还是出错,不关联知识库正常对话,确认有这个问题,其他同学应该没这么用过。 图片 图片

日志: Error: Request failed with status code 500 at createError (/app/node_modules/.pnpm/registry.npmmirror.com+axios@0.26.1/node_modules/axios/lib/core/createError.js:16:15) at settle (/app/node_modules/.pnpm/registry.npmmirror.com+axios@0.26.1/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/app/node_modules/.pnpm/registry.npmmirror.com+axios@0.26.1/node_modules/axios/lib/adapters/http.js:322:11) at IncomingMessage.emit (node:events:526:35) at endReadableNT (node:internal/streams/readable:1376:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { config: { transitional: { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }, adapter: [Function: httpAdapter], transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 60000, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], headers: { Accept: 'application/json, text/plain, /', 'Content-Type': 'application/json', 'User-Agent': 'OpenAI/NodeJS/3.3.0', Authorization: 'Bearer sk-5sslNl97GBDKY4P81173A3Bc6fBd4a05Be0826B9F1D0EdA9', auth: 'auth', 'Content-Length': 53 }, method: 'post', baseURL: 'http://172.29.91.79:3001/v1', data: '{"model":"text-embedding-ada-002","input":["您好"]}', url: 'http://172.29.91.79:3001/v1/embeddings' }, request: <ref *1> ClientRequest { _events: [Object: null prototype] { abort: [Function (anonymous)], aborted: [Function (anonymous)], connect: [Function (anonymous)], error: [Function (anonymous)], socket: [Function (anonymous)], timeout: [Function (anonymous)], finish: [Function: requestOnFinish] }, _eventsCount: 7, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: true, _last: false, chunkedEncoding: false, shouldKeepAlive: true, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: 53, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: true, socket: Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: [ReadableState], _events: [Object: null prototype], _eventsCount: 6, _maxListeners: undefined, _writableState: [WritableState], allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, timeout: 5000, parser: null, _httpMessage: null,

  [Symbol(kHandle)]: [TCP],
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: Timeout {
    _idleTimeout: 5000,
    _idlePrev: [TimersList],
    _idleNext: [TimersList],
    _idleStart: 634280,
    _onTimeout: [Function: bound ],
    _timerArgs: undefined,
    _repeat: null,
    _destroyed: false,
    [Symbol(refed)]: false,
    [Symbol(kHasPrimitive)]: false,
    [Symbol(asyncId)]: 18290,
    [Symbol(triggerId)]: 18288
  },
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kSetNoDelay)]: true,
  [Symbol(kSetKeepAlive)]: true,
  [Symbol(kSetKeepAliveInitialDelay)]: 1,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0
},
_header: 'POST /v1/embeddings HTTP/1.1\r\n' +
  'Accept: application/json, text/plain, */*\r\n' +
  'Content-Type: application/json\r\n' +
  'User-Agent: OpenAI/NodeJS/3.3.0\r\n' +
  'Authorization: Bearer sk-5sslNl97GBDKY4P81173A3Bc6fBd4a05Be0826B9F1D0EdA9\r\n' +
  'auth: auth\r\n' +
  'Content-Length: 53\r\n' +
  'Host: 172.29.91.79:3001\r\n' +
  'Connection: keep-alive\r\n' +
  '\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  defaultPort: 80,
  protocol: 'http:',
  options: [Object: null prototype],
  requests: [Object: null prototype] {},
  sockets: [Object: null prototype] {},
  freeSockets: [Object: null prototype],
  keepAliveMsecs: 1000,
  keepAlive: true,
  maxSockets: Infinity,
  maxFreeSockets: 256,
  scheduling: 'lifo',
  maxTotalSockets: Infinity,
  totalSocketCount: 1,
  [Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/v1/embeddings',
_ended: true,
res: IncomingMessage {
  _readableState: [ReadableState],
  _events: [Object: null prototype],
  _eventsCount: 4,
  _maxListeners: undefined,
  socket: null,
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  rawHeaders: [Array],
  rawTrailers: [],
  joinDuplicateHeaders: undefined,
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 500,
  statusMessage: 'Internal Server Error',
  client: [Socket],
  _consuming: false,
  _dumped: false,
  req: [Circular *1],
  responseUrl: 'http://172.29.91.79:3001/v1/embeddings',
  redirects: [],
  [Symbol(kCapture)]: false,
  [Symbol(kHeaders)]: [Object],
  [Symbol(kHeadersCount)]: 6,
  [Symbol(kTrailers)]: null,
  [Symbol(kTrailersCount)]: 0
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: '172.29.91.79',
protocol: 'http:',
_redirectable: Writable {
  _writableState: [WritableState],
  _events: [Object: null prototype],
  _eventsCount: 3,
  _maxListeners: undefined,
  _options: [Object],
  _ended: true,
  _ending: true,
  _redirectCount: 0,
  _redirects: [],
  _requestBodyLength: 53,
  _requestBodyBuffers: [],
  _onNativeResponse: [Function (anonymous)],
  _currentRequest: [Circular *1],
  _currentUrl: 'http://172.29.91.79:3001/v1/embeddings',
  _timeout: null,
  [Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
  accept: [Array],
  'content-type': [Array],
  'user-agent': [Array],
  authorization: [Array],
  auth: [Array],
  'content-length': [Array],
  host: [Array]
},
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null

}, response: { status: 500, statusText: 'Internal Server Error', headers: { 'content-type': 'application/json; charset=utf-8', date: 'Mon, 14 Aug 2023 02:38:53 GMT', 'content-length': '155' }, config: { transitional: [Object], adapter: [Function: httpAdapter], transformRequest: [Array], transformResponse: [Array], timeout: 60000, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: [Function: validateStatus], headers: [Object], method: 'post', baseURL: 'http://172.29.91.79:3001/v1', data: '{"model":"text-embedding-ada-002","input":["您好"]}', url: 'http://172.29.91.79:3001/v1/embeddings' }, request: <ref 1> ClientRequest { _events: [Object: null prototype], _eventsCount: 7, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: true, _last: false, chunkedEncoding: false, shouldKeepAlive: true, maxRequestsOnConnectionReached: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: true, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, strictContentLength: false, _contentLength: 53, _hasBody: true, _trailer: '', finished: true, _headerSent: true, _closed: true, socket: [Socket], _header: 'POST /v1/embeddings HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /*\r\n' + 'Content-Type: application/json\r\n' + 'User-Agent: OpenAI/NodeJS/3.3.0\r\n' + 'Authorization: Bearer sk-5sslNl97GBDKY4P81173A3Bc6fBd4a05Be0826B9F1D0EdA9\r\n' + 'auth: auth\r\n' + 'Content-Length: 53\r\n' + 'Host: 172.29.91.79:3001\r\n' + 'Connection: keep-alive\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: nop], agent: [Agent], socketPath: undefined, method: 'POST', maxHeaderSize: undefined, insecureHTTPParser: undefined, joinDuplicateHeaders: undefined, path: '/v1/embeddings', _ended: true, res: [IncomingMessage], aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: '172.29.91.79', protocol: 'http:', _redirectable: [Writable],

  [Symbol(kBytesWritten)]: 0,
  [Symbol(kNeedDrain)]: false,
  [Symbol(corked)]: 0,
  [Symbol(kOutHeaders)]: [Object: null prototype],
  [Symbol(errored)]: null,
  [Symbol(kHighWaterMark)]: 16384,
  [Symbol(kRejectNonStandardBodyWrites)]: false,
  [Symbol(kUniqueHeaders)]: null
},
data: { error: [Object] }

}, isAxiosError: true, toJSON: [Function: toJSON] }

---------------oneapi-------------------------- [SYS] 2023/08/14 - 10:38:53 | relay error (channel #2): invalid character '<' looking for beginning of value

muzibaby commented 1 year ago

增加了模型映射后:

图片

出现如下错误: [SYS] 2023/08/14 - 13:15:33 | relay error (channel #2): embeddings max batch size is 16, and can not be 0

如果直接采用微信一言的 chat 配合 opeanai的 text-embedding-ada-002,提示如下错误: [SYS] 2023/08/14 - 13:14:22 | relay error (channel #2): invalid character '<' looking for beginning of value

c121914yu commented 1 year ago

3.9因为限定词是用Human role,和文心不匹配。v4版本切换成system是可以的

muzibaby commented 1 year ago

请问是否有意向再兼容 3.X 版本嘛。

songquanpeng commented 1 year ago

那看来不是 One API 的问题

c121914yu commented 1 year ago

请问是否有意向再兼容 3.X 版本嘛。

没有,已经不维护了

muzibaby commented 1 year ago

图片 FastGPT-4.0 使用 Embeding-V1 过来 也不支持

igophper commented 1 year ago

图片 FastGPT-4.0 使用 Embeding-V1 过来 也不支持

你有使用最新版本吗?我记得好像修复了,可以去tag那里下载最新版本