RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Turn the relative date in question to absolute date (#3372)
Kevin Hu667d0e55370b
diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.pyindex 1c82cab51a..3cad184ae6 100644--- a/api/db/services/dialog_service.py+++ b/api/db/services/dialog_service.py@@ -19,8 +19,8 @@ import jsonimport refrom copy import deepcopyfrom timeit import default_timer as timer--+import datetime+from datetime import timedeltafrom api.db import LLMType, ParserType,StatusEnumfrom api.db.db_models import Dialog, Conversation,DBfrom api.db.services.common_service import CommonService@@ -526,9 +526,16 @@ def full_question(tenant_id, llm_id, messages):if m["role"] not in ["user", "assistant"]: continueconv.append("{}: {}".format(m["role"].upper(), m["content"]))conv = "\n".join(conv)+ today = datetime.date.today().isoformat()+ yesterday = (datetime.date.today() - timedelta(days=1)).isoformat()+ tomorrow = (datetime.date.today() + timedelta(days=1)).isoformat()prompt = f"""Role: A helpful assistant-Task: Generate a full user question that would follow the conversation.++Task and steps:+ 1. Generate a full user question that would follow the conversation.+ 2. If the user's question involves relative date, you need to convert it into absolute date based on the current date, which is {today}. For example: 'yesterday' would be converted to {yesterday}.+Requirements & Restrictions:- Text generated MUST be in the same language of the original user's question.- If the user's latest question is completely, don't do anything, just return the original question.@@ -557,6 +564,14 @@ User: What's her full name?###############Output: What's the full name of Donald Trump's mother Mary Trump?+------------+# Example 3+## Conversation+USER: What's the weather today in London?+ASSISTANT: Cloudy.+USER: What's about tomorrow in Rochester?+###############+Output: What's the weather in Rochester on {tomorrow}?####################### Real Data