mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-05 04:17:32 +00:00
support data: in URL for memory. Add ootb support for pdfs
This commit is contained in:
parent
a11d92601b
commit
5f49dce839
5 changed files with 82 additions and 12 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue