Skip to content

Latest commit

 

History

History
285 lines (215 loc) · 7.88 KB

File metadata and controls

285 lines (215 loc) · 7.88 KB

REPL Modes by Example

This document walks through real sessions in each of llammer's four REPL modes. Every transcript below reflects the shipped behaviour; where the small embedded dictionary produces a modest or surprising correction, the transcript shows the real result rather than an idealized one. For the architecture behind these sessions, see the REPL Overview.

Three things to keep in mind:

  • All modes are local and single-process. agent and customer do not open sockets or connect to anything; they are the same local loop with different labels and banners. See the REPL Overview §7.
  • Corrections are stateless. The conversation is recorded for /history, /save, and /load, but is never used to influence a correction.
  • Correction quality is bounded by the embedded 363-word dictionary. Words outside it are left unchanged; edit-distance ties are broken without a language model, so some corrections are imperfect (e.g. helo → help). See the Correction Model.

Logging. By default a Loading models... / Starting … REPL INFO line is printed to stdout before the banner. Prefix a launch with RUST_LOG=off to suppress it (done in the transcripts below).


1. Standalone Mode

The default mode: type a line, get a correction.

$ RUST_LOG=off llammer repl
llammer - Grammatical Correction REPL
Language: en-US
Type /help for commands, /exit to quit

> thier problm
  [original] thier problm
[corrected] their problem

  thier → their (confidence: 67%)
  problm → problem (confidence: 67%)
> documnet and infrmation
  [original] documnet and infrmation
[corrected] document and information

  documnet → document (confidence: 67%)
  infrmation → information (confidence: 67%)
> /exit
Goodbye!

1.1 Commands

/help prints the exact command list, and /autocorrect toggles correction (it takes no argument):

> /help

Commands:
  /help, /h, /?       Show this help message
  /exit, /quit, /q    Exit the REPL
  /clear, /cls        Clear the screen
  /history            Show conversation history
  /clearhistory       Clear conversation history
  /autocorrect, /ac   Toggle auto-correction
  /lang <code>        Set language (e.g., /lang en-US)
  /save <path>        Save conversation to file
  /load <path>        Load conversation from file

Tips:
  - Type normally to send messages
  - Corrections are shown in green
  - Original text is shown in dim gray when corrected

> /autocorrect
Auto-correct disabled
> custmer servce
custmer servce
> /autocorrect
Auto-correct enabled
> custmer servce
  [original] custmer servce
[corrected] customer service

  custmer → customer (confidence: 67%)
  servce → service (confidence: 67%)
> /lang en-GB
Language set to: en-GB

Note the real messages: Auto-correct disabled/enabled (not off/on), and Language set to: en-GB (the tag, with no parenthetical language name). /clear clears the screen; use /clearhistory to reset the conversation.

1.2 History, Save, and Load

/history shows recorded turns (with their corrections); /save and /load use JSON. The path is echoed in Rust debug form (quoted):

> adress and phnoe
  [original] adress and phnoe
[corrected] address and phone

  adress → address (confidence: 67%)
  phnoe → phone (confidence: 67%)
> /history

[you] adress and phnoe → address and phone

> /save session.json
Saved to "session.json"
> /clearhistory
Conversation history cleared.
> /load session.json
Loaded from "session.json"
> /history

[you] adress and phnoe → address and phone

> /exit
Goodbye!

2. Agent Mode

Styled as a support agent, but local — there is no customer on the other end. Input is tagged Assistant, the conversation is seeded with a system prompt, and each corrected line is echoed after [you].

$ RUST_LOG=off llammer repl --mode agent
llammer - Agent Mode REPL
Language: en-US
Type /help for commands, /exit to quit

Customer connected to chat session

agent> custmer servce is our priority
  [original] custmer servce is our priority
[corrected] customer service is our priority

  custmer → customer (confidence: 67%)
  servce → service (confidence: 67%)
[you] customer service is our priority
agent> /help

Commands:
  /help, /h, /?       Show this help message
  ...

Agent-specific commands:
  Messages from customers are shown with [customer] prefix
  Your responses will be spell-checked before sending
agent> /exit

Customer disconnected from chat session

The Customer connected / disconnected lines are static banners printed at start-up and on /exit; no connection occurs. (Leaving with Ctrl-D instead prints the role's EOF message, Ending session....)


3. Customer Mode

The mirror image, also local. Prompt you> , input tagged User, [you] echo.

$ RUST_LOG=off llammer repl --mode customer
llammer - Customer Chat
Language: en-US
Type /help for commands, /exit to quit

Connected to support agent
Your messages will be spell-checked automatically

you> thier problm
  [original] thier problm
[corrected] their problem

  thier → their (confidence: 67%)
  problm → problem (confidence: 67%)
[you] their problem
you> /exit

Chat session ended

There is no agent to receive [you] their problem; the echo is a local display. /history in this mode labels User turns [you] and Assistant turns [agent].


4. RAG Mode (Placeholder)

--mode rag corrects the query but does not search — it is an explicit demo.

$ RUST_LOG=off llammer repl --mode rag --index ./index
llammer - RAG Query REPL
Language: en-US, Top-k: 10
Type /help for commands, /exit to quit

query> custmer servce
  [original query] custmer servce
[corrected query] customer service

Searching for: "customer service" (top 10)

No results (index not implemented in demo)
query> /topk 5
Top-k set to 5
query> /exit
Goodbye!

For real retrieval use the non-interactive llammer rag query command — see the RAG Workflow. Wiring this REPL mode to a live index is a roadmap item.


5. A Realistic Multi-Step Workflow

These modes compose into a simple authoring loop. Each step is a separate, independent process; nothing is networked.

1. Build a retrieval index (needs the ModernBERT embedder; representative):

$ llammer rag init --documents ./corpus --output ./index
[1/3] Initializing RAG index from ./corpus
[2/3] Saving index to ./index
[3/3] Done!

2. Search it for source material:

$ llammer rag query "customer onboarding" --index ./index --top-k 5

3. Draft prose in the standalone REPL, fixing typos as you go:

$ RUST_LOG=off llammer repl
llammer - Grammatical Correction REPL
Language: en-US
Type /help for commands, /exit to quit

> wrok on the projcet
  [original] wrok on the projcet
[corrected] work on the project

  wrok → work (confidence: 67%)
  projcet → project (confidence: 67%)
> /save draft.json
Saved to "draft.json"
> /exit
Goodbye!

Note. agent and customer modes are not two ends of a connection — running llammer repl --mode agent in one terminal and llammer repl --mode customer in another gives two independent local REPLs that cannot see each other. A networked agent/customer protocol is defined in src/repl/protocol.rs but not wired in; see the Roadmap.


See Also