support data: in URL for memory. Add ootb support for pdfs

This commit is contained in:
Hardik Shah 2024-09-12 10:54:55 -07:00
parent a11d92601b
commit 5f49dce839
5 changed files with 82 additions and 12 deletions

View file

@ -5,11 +5,14 @@
# the root directory of this source tree.
import asyncio
import json
from pathlib import Path
from typing import Any, Dict, List, Optional
import fire
import httpx
from termcolor import cprint
from llama_toolchain.core.datatypes import RemoteProviderConfig
@ -120,7 +123,7 @@ async def run_main(host: str, port: int, stream: bool):
overlap_size_in_tokens=64,
),
)
print(bank)
cprint(json.dumps(bank.dict(), indent=4), "green")
retrieved_bank = await client.get_memory_bank(bank.bank_id)
assert retrieved_bank is not None
@ -145,6 +148,16 @@ async def run_main(host: str, port: int, stream: bool):
for i, url in enumerate(urls)
]
this_dir = os.path.dirname(__file__)
files = [Path(this_dir).parent.parent / "CONTRIBUTING.md"]
documents += [
MemoryBankDocument(
document_id=f"num-{i}",
content=data_url_from_file(path),
)
for i, path in enumerate(files)
]
# insert some documents
await client.insert_documents(
bank_id=bank.bank_id,