mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-15 04:32:22 +00:00
5.5 KiB
5.5 KiB
In [1]:
from langchain.document_loaders.recursive_url_loader import RecursiveUrlLoaderIn [2]:
url = "https://js.langchain.com/docs/modules/memory/examples/"
loader = RecursiveUrlLoader(url=url)
docs = loader.load()In [3]:
len(docs)Out [3]:
12
In [4]:
docs[0].page_content[:50]Out [4]:
'\n\n\n\n\nBuffer Window Memory | 🦜️🔗 Langchain\n\n\n\n\n\nSki'
In [5]:
docs[0].metadataOut [5]:
{'source': 'https://js.langchain.com/docs/modules/memory/examples/buffer_window_memory',
'title': 'Buffer Window Memory | 🦜️🔗 Langchain',
'description': 'BufferWindowMemory keeps track of the back-and-forths in conversation, and then uses a window of size k to surface the last k back-and-forths to use as memory.',
'language': 'en'}In [ ]:
url = "https://js.langchain.com/docs/"
exclude_dirs = ["https://js.langchain.com/docs/api/"]
loader = RecursiveUrlLoader(url=url, exclude_dirs=exclude_dirs)
# Lazy load each
docs = [print(doc) or doc for doc in loader.lazy_load()]In [7]:
# Load all pages
docs = loader.load()In [8]:
len(docs)Out [8]:
188
In [9]:
docs[0].page_content[:50]Out [9]:
'\n\n\n\n\nAgent Simulations | 🦜️🔗 Langchain\n\n\n\n\n\nSkip t'
In [10]:
docs[0].metadataOut [10]:
{'source': 'https://js.langchain.com/docs/use_cases/agent_simulations/',
'title': 'Agent Simulations | 🦜️🔗 Langchain',
'description': 'Agent simulations involve taking multiple agents and having them interact with each other.',
'language': 'en'}