INNER CODE UNIT · Python

left

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

    left = deadline - time.monotonic()
    return left if left >= floor else None


def answer(conversation, context_type, context_id, user, token):
    """The answer, the tools it took to get there, and any filter it built."""
    tools = list_tools(token, context_type)
    offered = {tool["function"]["name"] for tool in tools}
    messages = build_messages(conversation, MAX_CONTEXT, context_type, context_id, user)
    trace = []

    deadline = time.monotonic() + ANSWER_TIMEOUT
    # One round-trip can ask for several tools at once, so count the calls
    # themselves. Counting round-trips lets a paging model run four times over.
    calls_made = 0
    while calls_made < MAX_TOOL_CALLS:
        if (left := remaining(deadline)) is None:
            log("out of time before the model finished; answering from what it has")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…