mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-28 08:51:59 +00:00
adding exceptional handling for serializing the metadata
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
54d28d13e9
commit
dc8e25c02b
2 changed files with 25 additions and 1 deletions
|
|
@ -144,7 +144,12 @@ def make_overlapped_chunks(
|
|||
) -> list[Chunk]:
|
||||
tokenizer = Tokenizer.get_instance()
|
||||
tokens = tokenizer.encode(text, bos=False, eos=False)
|
||||
metadata_tokens = tokenizer.encode(str(metadata), bos=False, eos=False)
|
||||
try:
|
||||
metadata_string = str(metadata)
|
||||
except Exception as e:
|
||||
raise ValueError("Failed to serialize metadata to string") from e
|
||||
|
||||
metadata_tokens = tokenizer.encode(metadata_string, bos=False, eos=False)
|
||||
|
||||
chunks = []
|
||||
for i in range(0, len(tokens), window_len - overlap_len):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue