Replies: 3 comments 10 replies
-
感谢您提供详细的需求和设计方案。您提到的关于 XRequest
useXAgent
useXChat
这些改进建议将有助于提高这些功能在实际应用中的灵活性和可靠性。我们会将您的建议纳入考虑,并在后续版本中进行评估和实施。 如果您有更多的建议或需要进一步的帮助,请随时告知。 🪧 TipsFor further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. |
Beta Was this translation helpful? Give feedback.
0 replies
-
useXChat 考虑支持多对话吗?现在demo里是单对话。 |
Beta Was this translation helpful? Give feedback.
8 replies
-
我大概推导了一下单实例需要解决的问题 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
useXAgent, useXChat,XRequest在真实请求场景下对流的支持
Motivation
在服务群、样板间、业务中使用useXAgent, useXChat,XRequest发现对于真实请求的流解析、控制等都有欠缺,以及官网一些demo错误,因此对useXAgent, useXChat,XRequest做完善和修改。
Detailed Design & Example Usage
XRequest
ISSUE
1、作为最基础的数据请求方法XRequest 对fetch进行了封装 但没有提供终止的方法
2、在useXChat提供的打断输出demo是基于自定义
request
,同时是使用readableStream
去做的,此实例只可读取一次就会被锁定,限制比较大一般不会用这个去做abort,建议使用AbortController。API
在 XRequestCallbacks新增 onStream 返回 abortController(后续还可以扩展其他参数)。

Example Usage
useXAgent
ISSUE
1、没有提供终止方法
2、demo模拟的流很简单内容也为简单字符串实际模型返回的是json string需要做解析,目前如果要自己做解析只能自定义
request
成本较高。API
继承XRequest 的
onStream
和transformStream
Example Usage
同 XRequest
useXChat
ISSUE
以下三点会直接导致 useXChat 根本不能落地
1、无法自定义params ,导致默认非流式 stream = false.
2、无法终止回答,现在的demo基于自定义
request
,同时使用API目前不建议,建议删掉demo,新的能力需要请求真实接口,会给出新的demo3、无法处理模型接口数据,demo都是简单字符串,message也处理的比较死,真实接口为json string,已有的
parser
无法处理流式数据同时,也没有真实变更messages
导致再次发送的数据和模型入参数据不一致而报错,根本无法使用。API
新增resolveAbortController透出 AbortController,transformMessage 将模型数据转化成message,也免去用户写 transformStream 的痛苦。

onRequest 扩展用户的传入参数
Example Usage
0 votes ·
Beta Was this translation helpful? Give feedback.
All reactions