← 返回 openai 的题目列表Refactor a Chatbot Codebase
类型:online_judge
You are given a piece of chatbot-related code/module that suffers from poor readability, duplicated logic, and inconsistent edge-case handling. Refactor it while preserving external behavior.
Requirements:
Keep the public interface unchanged (function signatures / I/O protocol as provided).
Improve structure: remove duplication, clarify responsibilities, use clear naming.
Handle edge cases consistently (empty input, error paths, timeouts/cancellation, as constrained by the prompt).
If requested, add unit tests or a minimal verification harness.
Explain what you changed and why.