fix memory url parsing (#81)

This commit is contained in:
Xi Yan 2024-09-19 13:35:03 -07:00 committed by GitHub
parent 132f9429b1
commit 59af1c8fec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,6 +102,15 @@ async def content_from_doc(doc: MemoryBankDocument) -> str:
r = await client.get(doc.content.uri) r = await client.get(doc.content.uri)
return r.text return r.text
pattern = re.compile("^(https?://|file://|data:)")
if pattern.match(doc.content):
if doc.content.startswith("data:"):
return content_from_data(doc.content)
else:
async with httpx.AsyncClient() as client:
r = await client.get(doc.content)
return r.text
return interleaved_text_media_as_str(doc.content) return interleaved_text_media_as_str(doc.content)