Find answers from the community

Updated 3 months ago

Hi everyone, I am new to llamaindex. I

Hi everyone, I am new to llamaindex. I am trying to build a chatbot that reads my own content, currently I am using the SitemapReader to read from a sitemap.xml file but I am struggling to append the URL that the sitemap reader reads to the document object's metadata field. The purpose of this is to always include the source URL (if it's available) in the answer just like what kapa.ai does.
W
l
3 comments
You can add it manually too!

Plain Text
doc = SiteMapReader.load_dat()
doc.metadata = {"url":"Add url here"}
then in the response you can fetch the url from the source nodes and display it as you want to
Hi @WhiteFang_Jr thanks for the reply, in the provided sitemap there are multiple urls that look like this:
Plain Text
<url>
  <loc>url1</loc>
  <lastmod>2024-09-22</lastmod>
</url>

<url>
  <loc>url2</loc>
  <lastmod>2024-09-22</lastmod>
</url>

<url>
  <loc>url3</loc>
  <lastmod>2024-09-22</lastmod>
</url>

...

SiteMapReader.load_data() returns a list of documents by default. I assume each of these documents is created by reading each individual URL stored in the sitemap file. The metadata is different for each document object
Add a reply
Sign up and join the conversation on Discord