Skip to content

Commit

Permalink
feat: mesh streaming response support (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
caochengxiang authored Nov 8, 2024
2 parents eea7932 + fd49a9b commit b9f950b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.xiaomi.data.push.uds.context.TraceContext;
import com.xiaomi.data.push.uds.context.TraceEvent;
import com.xiaomi.data.push.uds.context.UdsClientContext;
import com.xiaomi.data.push.uds.handler.ClientStreamCallback;
import com.xiaomi.data.push.uds.handler.MessageTypes;
import com.xiaomi.data.push.uds.handler.UdsClientConnetManageHandler;
import com.xiaomi.data.push.uds.handler.UdsClientHandler;
import com.xiaomi.data.push.uds.po.UdsCommand;
Expand Down Expand Up @@ -144,6 +146,18 @@ public void call(Object msg) {
Send.send(this.channel, command);
}

/**
* 发送OpenAI流式请求
*/
public void stream(UdsCommand command, ClientStreamCallback callback) {
Map<String, String> attachments = command.getAttachments();
// 注册回调
((UdsClientHandler) channel.pipeline().last()).getStreamCallbacks()
.put(attachments.get(MessageTypes.STREAM_ID_KEY), callback);
// 发送请求
Send.send(this.channel, command);
}

@Override
public UdsCommand call(UdsCommand req) {
Stopwatch sw = Stopwatch.createStarted();
Expand Down

0 comments on commit b9f950b

Please sign in to comment.