mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-06 05:25:04 +00:00
Harrison/virtual time (#4658)
Co-authored-by: ifsheldon <39153080+ifsheldon@users.noreply.github.com> Co-authored-by: maple.liang <maple.liang@gempoll.com>
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"['5c9f7c06-c9eb-45f2-aea5-efce5fb9f2bd']"
|
||||
"['d7f85756-2371-4bdf-9140-052780a0f9b3']"
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
@@ -93,7 +93,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[Document(page_content='hello world', metadata={'last_accessed_at': datetime.datetime(2023, 4, 16, 22, 9, 1, 966261), 'created_at': datetime.datetime(2023, 4, 16, 22, 9, 0, 374683), 'buffer_idx': 0})]"
|
||||
"[Document(page_content='hello world', metadata={'last_accessed_at': datetime.datetime(2023, 5, 13, 21, 0, 27, 678341), 'created_at': datetime.datetime(2023, 5, 13, 21, 0, 27, 279596), 'buffer_idx': 0})]"
|
||||
]
|
||||
},
|
||||
"execution_count": 4,
|
||||
@@ -177,10 +177,51 @@
|
||||
"retriever.get_relevant_documents(\"hello world\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "32e0131e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Virtual Time\n",
|
||||
"\n",
|
||||
"Using some utils in LangChain, you can mock out the time component"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "da080d40",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langchain.utils import mock_now\n",
|
||||
"import datetime"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "7c7deff1",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[Document(page_content='hello world', metadata={'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'created_at': datetime.datetime(2023, 5, 13, 21, 0, 27, 279596), 'buffer_idx': 0})]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Notice the last access time is that date time\n",
|
||||
"with mock_now(datetime.datetime(2011, 2, 3, 10, 11)):\n",
|
||||
" print(retriever.get_relevant_documents(\"hello world\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "bf6d8c90",
|
||||
"id": "c78d367d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
Reference in New Issue
Block a user