← 返回 openai 的题目列表Build a ChatGPT Chat Interface in an Existing iOS Project
类型:online_judge
Problem: Build a ChatGPT Chat Interface in an Existing iOS Project
You are given a minimal Xcode project. Implement a ChatGPT-like chat interface from scratch. You may use SwiftUI, UIKit with Swift, or Objective-C.
Functional Requirements
Display a chat screen with a visual style similar to ChatGPT.
Support rendering user messages and assistant messages.
User and assistant messages should be visually distinguishable, for example by alignment, background color, avatar, or title.
Provide a text input field and a send button at the bottom.
When the user enters text and taps send, append the message to the chat list.
Clear the input field after sending.
Correctly handle long messages, many messages, and scrolling.
When a new message appears, the chat list should preferably scroll to the bottom.
Provide basic error handling, such as showing an error state or message when sending fails.
Bonus
Integrate with the existing mock API or networking layer in the project.
Support a loading state, such as a typing indicator while the assistant is responding.
Support retry.
Correctly handle keyboard appearance and keep the input bar visible.
Support dark mode.
Support accessibility labels and dynamic type.
Constraints
The project must compile and run correctly.
Prioritize a complete core chat UI and clean code structure.
You may inspect the project structure first and explain your plan.
You may clarify priorities with the interviewer, such as whether to focus on UI first or login/networking first.