Skip to content

Commit e09de60

Browse files
committed
fix mypy
1 parent 872f238 commit e09de60

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44

55

66
def get_artifacts(chat_request: ChatRequest) -> List[Artifact]:
7-
"""Return a list of artifacts sorted by their creation time. Artifacts without a creation time are placed at the end."""
8-
artifacts = [
9-
Artifact.from_message(message) # type: ignore
10-
for message in chat_request.messages
11-
if Artifact.from_message(message) is not None
12-
]
13-
return sorted(artifacts, key=lambda a: (a.created_at is None, a.created_at))
7+
"""
8+
Return a list of artifacts sorted by their creation time.
9+
Artifacts without a creation time are placed at the end.
10+
"""
11+
return sorted(
12+
[
13+
artifact
14+
for artifact in (Artifact.from_message(m) for m in chat_request.messages)
15+
if artifact is not None
16+
],
17+
key=lambda a: (a.created_at is None, a.created_at),
18+
)
1419

1520

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

0 commit comments

Comments
 (0)