mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-28 02:53:30 +00:00
Fix ValueError in case chunks are empty (#206)
This commit is contained in:
parent
a4e775c465
commit
53d440e952
1 changed files with 4 additions and 3 deletions
|
@ -673,7 +673,7 @@ class ChatAgent(ShieldRunnerMixin):
|
||||||
|
|
||||||
async def _retrieve_context(
|
async def _retrieve_context(
|
||||||
self, session_id: str, messages: List[Message], attachments: List[Attachment]
|
self, session_id: str, messages: List[Message], attachments: List[Attachment]
|
||||||
) -> Tuple[List[str], List[int]]: # (rag_context, bank_ids)
|
) -> Tuple[Optional[List[str]], Optional[List[int]]]: # (rag_context, bank_ids)
|
||||||
bank_ids = []
|
bank_ids = []
|
||||||
|
|
||||||
memory = self._memory_tool_definition()
|
memory = self._memory_tool_definition()
|
||||||
|
@ -722,12 +722,13 @@ class ChatAgent(ShieldRunnerMixin):
|
||||||
chunks = [c for r in results for c in r.chunks]
|
chunks = [c for r in results for c in r.chunks]
|
||||||
scores = [s for r in results for s in r.scores]
|
scores = [s for r in results for s in r.scores]
|
||||||
|
|
||||||
|
if not chunks:
|
||||||
|
return None, bank_ids
|
||||||
|
|
||||||
# sort by score
|
# sort by score
|
||||||
chunks, scores = zip(
|
chunks, scores = zip(
|
||||||
*sorted(zip(chunks, scores), key=lambda x: x[1], reverse=True)
|
*sorted(zip(chunks, scores), key=lambda x: x[1], reverse=True)
|
||||||
)
|
)
|
||||||
if not chunks:
|
|
||||||
return None, bank_ids
|
|
||||||
|
|
||||||
tokens = 0
|
tokens = 0
|
||||||
picked = []
|
picked = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue