refine manual parser (#140)
This commit is contained in:
@@ -118,14 +118,13 @@ def message_fit_in(msg, max_length=4000):
|
||||
|
||||
c = count()
|
||||
if c < max_length: return c, msg
|
||||
msg = [m for m in msg if m.role in ["system", "user"]]
|
||||
c = count()
|
||||
if c < max_length: return c, msg
|
||||
|
||||
msg_ = [m for m in msg[:-1] if m.role == "system"]
|
||||
msg_.append(msg[-1])
|
||||
msg = msg_
|
||||
c = count()
|
||||
if c < max_length: return c, msg
|
||||
|
||||
ll = num_tokens_from_string(msg_[0].content)
|
||||
l = num_tokens_from_string(msg_[-1].content)
|
||||
if ll / (ll + l) > 0.8:
|
||||
|
||||
@@ -218,7 +218,7 @@ def rm():
|
||||
ELASTICSEARCH.deleteByQuery(Q("match", doc_id=doc.id), idxnm=search.index_name(tenant_id))
|
||||
|
||||
DocumentService.increment_chunk_num(doc.id, doc.kb_id, doc.token_num * -1, doc.chunk_num * -1, 0)
|
||||
if not DocumentService.delete_by_id(req["doc_id"]):
|
||||
if not DocumentService.delete(doc):
|
||||
return get_data_error_result(
|
||||
retmsg="Database error (Document removal)!")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user