mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-30 08:35:33 +08:00
Feat: message manage (#12083)
### What problem does this PR solve? Message CRUD. Issue #4213 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -136,6 +136,19 @@ def kb_prompt(kbinfos, max_tokens, hash_id=False):
|
||||
return knowledges
|
||||
|
||||
|
||||
def memory_prompt(message_list, max_tokens):
|
||||
used_token_count = 0
|
||||
content_list = []
|
||||
for message in message_list:
|
||||
current_content_tokens = num_tokens_from_string(message["content"])
|
||||
if used_token_count + current_content_tokens > max_tokens * 0.97:
|
||||
logging.warning(f"Not all the retrieval into prompt: {len(content_list)}/{len(message_list)}")
|
||||
break
|
||||
content_list.append(message["content"])
|
||||
used_token_count += current_content_tokens
|
||||
return content_list
|
||||
|
||||
|
||||
CITATION_PROMPT_TEMPLATE = load_prompt("citation_prompt")
|
||||
CITATION_PLUS_TEMPLATE = load_prompt("citation_plus")
|
||||
CONTENT_TAGGING_PROMPT_TEMPLATE = load_prompt("content_tagging_prompt")
|
||||
|
||||
Reference in New Issue
Block a user