Skip to content

Replace ChatGPT help with streaming AI assistant conversations - #9274

Open
iHiD wants to merge 2 commits into
mainfrom
assistant-chat
Open

Replace ChatGPT help with streaming AI assistant conversations#9274
iHiD wants to merge 2 commits into
mainfrom
assistant-chat

Conversation

@iHiD

@iHiD iHiD commented Jul 17, 2026

Copy link
Copy Markdown
Member

Shifts the editor's AI help to the same model as Jiki's llm-chat-proxy: the browser talks directly to a Cloudflare Worker (exercism/llm-chat-proxy) which streams Socratic-mentor responses from Gemini, replacing the old fire-and-forget ChatGPT proxy + SPI callback + ActionCable round-trip.

Entitlement model

  • Insiders: unlimited conversations on every exercise.
  • Everyone else: one free exercise conversation, ever, pinned to the first exercise they start a conversation on.
  • Uniform cost caps enforced by the worker (10 msgs/min burst, 100/day, 500/month per user), matching Jiki.

Rails

  • Solution::AssistantConversation model (JSON messages column, unique per solution) + Mandate commands mirroring Jiki's: CreateConversationToken (1h HS256 JWT bound to the solution), CheckUserAccess, FindOrCreate, AddUserMessage, AddAssistantMessage, AddMessage, VerifyHMAC, VerifyConversationToken.
  • POST /api/v2/solutions/:uuid/assistant_conversation mints tokens, gated by Cloudflare Turnstile (Captcha::VerifyTurnstileToken, fail-open on CF outage). user_messages / assistant_messages persist the transcript; assistant messages must carry a valid HMAC signature from the worker (payload includes the solution uuid and a 10-minute freshness window, closing Jiki's replay gap).
  • GET /api/v2/solutions/:uuid/assistant_context serves instructions + tests to the worker, authenticated with the same conversation JWT.

Front-end

  • New editor/AssistantChat module ported from Jiki: streaming chat panel with token caching (one Turnstile pass per session), transparent refresh on token expiry, usage warnings at 90%, cap/upsell states, and free-conversation upsell for non-insiders.
  • Replaces the ChatGPT panel/dialog/model-picker; Stuck? button now routes to the assistant tab for everyone.

Removed

The entire legacy pipeline: Submission::AI::ChatGPT::*, the ai_help endpoint, /spi/chatgpt_responses, Submission::AIHelpRecordsChannel, ResetChatGPTUsageJob + schedule, chatgpt usage counters, and the ChatGptFeedback components. The submission_ai_help_records table is left in place (nothing reads it). The OpenAI training-data/tagging pipeline is untouched.

Requires before deploy

  • exercism-config: assistant_chat_jwt_secret, assistant_chat_hmac_secret (secrets, shared with the worker) and assistant_chat_url (config; prod https://chat.exercism.org, local http://local.exercism.io:3027).
  • The worker deployed from exercism/llm-chat-proxy (see its PR).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WJjLSVfCaDvJQM3oATNcL6

iHiD and others added 2 commits July 17, 2026 23:40
Add a version component to the landing page etag so cached responses
are invalidated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QCkfS91ZjSLcGmbDehDAeH
Shifts the editor's AI help to the same model as Jiki's: the browser
talks directly to a Cloudflare Worker (exercism/llm-chat-proxy) which
streams Socratic-mentor responses from Gemini, instead of the old
fire-and-forget ChatGPT proxy + ActionCable round-trip.

Rails now:
- mints short-lived per-solution conversation JWTs (Turnstile-gated)
- enforces entitlement: Insiders unlimited; everyone else gets one
  free exercise conversation, ever (pinned to their first)
- serves the exercise context (instructions, tests) to the worker,
  authenticated by the same JWT
- persists conversations, verifying an HMAC signature over each
  assistant message so clients can't fabricate them

The editor gains a multi-turn streaming chat panel replacing the old
single-shot ChatGPT panel, and the ChatGPT pipeline (commands, SPI
callback, ActionCable channel, usage counters, reset job) is removed.

Requires (exercism-config): assistant_chat_jwt_secret,
assistant_chat_hmac_secret, and assistant_chat_url.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJjLSVfCaDvJQM3oATNcL6
@iHiD
iHiD requested a review from dem4ron as a code owner July 17, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant