INNER CODE UNIT · Python

conversation_of

skyportal/skyportal · services/assistant/app.py:477

def conversation_of(session, user_id, channel, up_to_id=None):
    """The conversation as it stood when `up_to_id` was asked.

    Anything written afterwards, including an earlier failure's apology, is not
    context for this answer.
    """
    query = sa.select(AssistantMessage).where(
        AssistantMessage.user_id == user_id,
        AssistantMessage.channel == channel
        if channel
        else AssistantMessage.channel.is_(None),
    )
    if up_to_id is not None:
        query = query.where(AssistantMessage.id <= up_to_id)
    messages = (
        session.scalars(query.order_by(AssistantMessage.created_at)).unique().all()
    )
    return [

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…