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)
l = self.line_chunk_match(ll)
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:
v = d.get_data_by_keys(self.api.chunk_filter.name)
v1 = self.api.chunk_filter.value
op = self.api.chunk_filter.op
f = opfuncs.get(op)
if f and f(v,v1):
print('filtered', v, op, v1, f)
return
j = {}
for r in self.api.resp or []:
j[r.name] = d.get_data_by_keys(r.value);
j[self.api.chunk_filter.field] = ''
print('filtered j=', j)
jstr = json.dumps(j) + '\n'
bin = jstr.encode('utf-8')