Revert "feat: AgentIO abort previous request on new input"
This reverts commit 5fb7796df1d0b416ae978ecd95be076a037d30a7.
This commit is contained in:
parent
5fb7796df1
commit
8b4b9390a8
@ -343,11 +343,6 @@ bricks.AgentIO = class extends bricks.VBox {
|
||||
console.log('chunk end');
|
||||
}
|
||||
async user_inputed(e){
|
||||
// 中止上一次请求
|
||||
if (this._current_hr) {
|
||||
this._current_hr.abort();
|
||||
this._current_hr = null;
|
||||
}
|
||||
this.show_input(e.params);
|
||||
var params = e.params;
|
||||
params.llmid = this.agent_using_llmid;
|
||||
@ -366,15 +361,12 @@ bricks.AgentIO = class extends bricks.VBox {
|
||||
});
|
||||
this.msg_box.add_widget(mout);
|
||||
var hr = new bricks.HttpResponseStream();
|
||||
this._current_hr = hr;
|
||||
var resp = await hr.post(this.opts.url, {params:params});
|
||||
if (! resp) {
|
||||
mout.run_stopped();
|
||||
this._current_hr = null;
|
||||
return;
|
||||
}
|
||||
await hr.handle_chunk(resp, this.chunk_response.bind(this, mout));
|
||||
this._current_hr = null;
|
||||
this.chunk_ended();
|
||||
}
|
||||
async show_input(params){
|
||||
|
||||
@ -247,34 +247,6 @@ bricks.HttpResponse = class extends bricks.HttpText {
|
||||
}
|
||||
|
||||
bricks.HttpResponseStream = class extends bricks.HttpResponse {
|
||||
constructor(){
|
||||
super();
|
||||
this._controller = new AbortController();
|
||||
}
|
||||
abort(){
|
||||
this._controller.abort();
|
||||
}
|
||||
async bricks_fetch(url, {method='GET', headers=null, params=null, signal=null}={}){
|
||||
url = this.url_parse(url);
|
||||
var data = this.add_own_params(params);
|
||||
var header = this.add_own_headers(headers);
|
||||
var _params = {
|
||||
method:method,
|
||||
signal: signal || this._controller.signal
|
||||
}
|
||||
if (data instanceof FormData){
|
||||
method = 'POST';
|
||||
_params.body = data;
|
||||
} else {
|
||||
if (method == 'GET' || method == 'HEAD') {
|
||||
let pstr = url_params(data);
|
||||
url = url + '?' + pstr;
|
||||
} else {
|
||||
_params.body = JSON.stringify(data);
|
||||
}
|
||||
}
|
||||
return await fetch(url, _params);
|
||||
}
|
||||
async handle_chunk(resp, handler){
|
||||
const reader = resp.body.getReader();
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user