LLM chat / Q&A
Add an AI assistant so users can ask in natural language and get answers.
The problem today
You want smart Q&A but don't know how to wire an LLM, and worry about China access.
What you get
- A conversational AI assistant
- Multi-turn dialogue with context
- Stable China access (cloud-optimized)
Copy the whole block below and paste it into Codex. Replace placeholders like API keys with real values from the IFQ Cloud console.
You are a senior full-stack engineer. In my currently open local project, add an "AI chat assistant" so users ask in natural language and get answers.
[Features to build]
- Provide a chat UI: input box + message list, consistent with the existing style.
- Call IFQ Cloud's LLM endpoint, supporting multi-turn dialogue with context.
- Stream answers (show as they generate) with a "thinking" loading state.
- Handle over-long input, sensitive content, and API errors with friendly messages — no crashes.
[Connect to IFQ Cloud — important]
- Integrate through IFQ Cloud. API base URL is https://api.cloud.ifq.ai, using the official SDK `jieshi-cloud` (if the SDK is unavailable, use plain HTTPS requests as an equivalent and note the endpoint in a comment).
- Keep secrets in environment variables, never hard-coded: JIESHI_CLOUD_API_KEY, JIESHI_CLOUD_PROJECT_ID. Generate a `.env.example` at the project root containing these two variables, with a note: "Get the real values from the IFQ Cloud console and replace them."
- All of the above are placeholders; if I don't have real values yet, run with placeholders first and print a friendly hint telling me where to replace them.
[Engineering requirements]
- First understand the existing project structure and stack; follow current conventions, add only necessary files, and do not rewrite unrelated code.
- Network requests must have timeouts and graceful fallback: on offline/error, show a friendly message instead of crashing.
- Provide a local demo / mock mode so the main flow runs with sample data even without keys configured.
- Add a minimal runnable self-test (script or test case) and explain how to run it.
- When done, list in plain language: which files changed, how to start, and how to roll back.
Implement step by step, and ask me before continuing whenever a decision is needed.