This commit is contained in:
yumoqing 2024-04-17 18:42:45 +08:00
parent e883fbce20
commit 6c6f43091b

View File

@ -37,18 +37,18 @@ class LlmProxy:
print('write_chunk(),l=', ll) print('write_chunk(),l=', ll)
l = self.line_chunk_match(ll) l = self.line_chunk_match(ll)
d = DictObject(** json.loads(l)) d = DictObject(** json.loads(l))
j = {}
for r in self.api.resp or []:
j[r.name] = d.get_data_by_keys(r.value);
if self.api.chunk_filter: if self.api.chunk_filter:
v = d.get_data_by_keys(self.api.chunk_filter.name) v = d.get_data_by_keys(self.api.chunk_filter.name)
v1 = self.api.chunk_filter.value v1 = self.api.chunk_filter.value
op = self.api.chunk_filter.op op = self.api.chunk_filter.op
f = opfuncs.get(op) f = opfuncs.get(op)
if f and f(v,v1): if f and f(v,v1):
print('filtered', v, op, v1, f) j[self.api.chunk_filter.field] = ''
return print('filtered j=', j)
j = {}
for r in self.api.resp or []:
j[r.name] = d.get_data_by_keys(r.value);
jstr = json.dumps(j) + '\n' jstr = json.dumps(j) + '\n'
bin = jstr.encode('utf-8') bin = jstr.encode('utf-8')