Skip to content

Commit 872f238

Browse files
committed
sort artifact
1 parent 9e42cf3 commit 872f238

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/llama-index-server/llama_index/server/api/utils/chat_request.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55

66
def get_artifacts(chat_request: ChatRequest) -> List[Artifact]:
7-
return [
7+
"""Return a list of artifacts sorted by their creation time. Artifacts without a creation time are placed at the end."""
8+
artifacts = [
89
Artifact.from_message(message) # type: ignore
910
for message in chat_request.messages
1011
if Artifact.from_message(message) is not None
1112
]
13+
return sorted(artifacts, key=lambda a: (a.created_at is None, a.created_at))
1214

1315

1416
def get_last_artifact(chat_request: ChatRequest) -> Optional[Artifact]:

0 commit comments

Comments
 (0)