mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-19 00:09:40 +00:00
Fix agent executor
This commit is contained in:
parent
59ce047aea
commit
e0731ba353
4 changed files with 62 additions and 16 deletions
|
|
@ -21,6 +21,7 @@ from pypdf import PdfReader
|
|||
from llama_models.llama3.api.datatypes import * # noqa: F403
|
||||
from llama_models.llama3.api.tokenizer import Tokenizer
|
||||
|
||||
from llama_stack.apis.inference import InterleavedContent, TextContentItem
|
||||
from llama_stack.apis.memory import * # noqa: F403
|
||||
from llama_stack.apis.memory_banks import VectorMemoryBank
|
||||
from llama_stack.providers.datatypes import Api
|
||||
|
|
@ -88,6 +89,26 @@ def content_from_data(data_url: str) -> str:
|
|||
return ""
|
||||
|
||||
|
||||
def concat_interleaved_content(content: List[InterleavedContent]) -> InterleavedContent:
|
||||
"""concatenate interleaved content into a single list. ensure that 'str's are converted to TextContentItem when in a list"""
|
||||
|
||||
ret = []
|
||||
|
||||
def _process(c):
|
||||
if isinstance(c, str):
|
||||
ret.append(TextContentItem(text=c))
|
||||
elif isinstance(c, list):
|
||||
for item in c:
|
||||
_process(item)
|
||||
else:
|
||||
ret.append(c)
|
||||
|
||||
for c in content:
|
||||
_process(c)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
async def content_from_doc(doc: MemoryBankDocument) -> str:
|
||||
if isinstance(doc.content, URL):
|
||||
if doc.content.uri.startswith("data:"):
|
||||
|
|
@ -125,6 +146,7 @@ def make_overlapped_chunks(
|
|||
for i in range(0, len(tokens), window_len - overlap_len):
|
||||
toks = tokens[i : i + window_len]
|
||||
chunk = tokenizer.decode(toks)
|
||||
# chunk is a string
|
||||
chunks.append(
|
||||
Chunk(content=chunk, token_count=len(toks), document_id=document_id)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue