引導式測驗 · 中等 等級

如何使用 LLM API 建立聊天機器人測驗

圍繞 API 請求循環、狀態和提供者差異、串流、工具執行、令牌限制和安全錯誤處理來建立聊天機器人。

問題 1 的 8

在客戶端管理的聊天完成流程中,每個新回合通常會發送什麼上下文?

預覽每個問題8 問題

當您參加測驗時,就會出現答案和解釋。

  1. 在客戶端管理的聊天完成流程中,每個新回合通常會發送什麼上下文?
    • Only the newest user message
    • The full array of prior messages plus the new one
    • A compressed binary session token
    • Just the system prompt
  2. 在客戶端管理的無狀態聊天流程中,為什麼機器人可以引用先前的回合?
    • The model stores a session on the provider's server automatically
    • The client resends the full message history on every call
    • The API caches embeddings of prior turns
    • The model has a persistent memory across all users
  3. 根據該指南,聊天機器人中串流回應的主要實際好處是什麼?
    • It reduces the total token cost of the request
    • It allows the model to skip the system prompt
    • It improves perceived speed by rendering text as it arrives
    • It removes the need for error handling
  4. 根據指南,什麼應該觸發指數退避而不是立即重試?
    • A successful 200 response
    • Rate limit errors (429) and transient server errors (5xx)
    • Any assistant message longer than expected
    • A user typing a new message
  5. 工具呼叫如何融入基本的聊天機器人循環?
    • The model executes the function itself on the provider's servers
    • The application runs the requested function and appends its result as a message before calling the model again
    • Tool calls replace the system prompt entirely
    • The client must switch to a different API endpoint
  6. For a new OpenAI chatbot, what API and conversation-state approach does current documentation recommend?
    • Chat Completions is no longer supported
    • Responses is recommended for new projects; Chat Completions remains supported and commonly uses client-supplied message history
    • Responses can only accept one user turn
    • Both APIs always store the same server-side conversation
  7. Why is counting characters or words insufficient for managing a chatbot's context window?
    • Context limits are enforced in tokens, which don't map directly to characters or words
    • Characters are always more expensive than tokens
    • The API rejects any request with punctuation
    • Word counts are only relevant for streaming
  8. According to the guide, what is a recommended strategy when a conversation's message array grows too large for the context window?
    • Delete the system prompt to save space
    • Trim or summarize older turns before the limit is reached
    • Switch every message to the assistant role
    • Stop streaming responses