mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-09-12 12:03:06 +08:00
Added readable exception if no posts were found for task
This commit is contained in:
committed by
Andreas Köpf
parent
c5053ed6c9
commit
4ead078f89
@@ -34,6 +34,7 @@ class OasstErrorCode(IntEnum):
|
|||||||
INVALID_TASK_TYPE = 2004
|
INVALID_TASK_TYPE = 2004
|
||||||
USER_NOT_SPECIFIED = 2005
|
USER_NOT_SPECIFIED = 2005
|
||||||
NO_THREADS_FOUND = 2006
|
NO_THREADS_FOUND = 2006
|
||||||
|
NO_REPLIES_FOUND = 2007
|
||||||
WORK_PACKAGE_NOT_FOUND = 2100
|
WORK_PACKAGE_NOT_FOUND = 2100
|
||||||
WORK_PACKAGE_EXPIRED = 2101
|
WORK_PACKAGE_EXPIRED = 2101
|
||||||
WORK_PACKAGE_PAYLOAD_TYPE_MISMATCH = 2102
|
WORK_PACKAGE_PAYLOAD_TYPE_MISMATCH = 2102
|
||||||
|
|||||||
@@ -445,6 +445,8 @@ class PromptRepository:
|
|||||||
|
|
||||||
parent = parent.order_by(func.random()).limit(1).subquery()
|
parent = parent.order_by(func.random()).limit(1).subquery()
|
||||||
replies = self.db.query(Post).filter(Post.parent_id.in_(parent)).order_by(func.random()).limit(max_size).all()
|
replies = self.db.query(Post).filter(Post.parent_id.in_(parent)).order_by(func.random()).limit(max_size).all()
|
||||||
|
if not replies:
|
||||||
|
raise OasstError("No replies found", OasstErrorCode.NO_REPLIES_FOUND)
|
||||||
|
|
||||||
thread = self.fetch_thread(replies[0].thread_id)
|
thread = self.fetch_thread(replies[0].thread_id)
|
||||||
thread = {p.id: p for p in thread}
|
thread = {p.id: p for p in thread}
|
||||||
|
|||||||
Reference in New Issue
Block a user