Wrap Interactions
To initiate and wrap a dialogue between a user and LLM-tutor locally, follow this tutorial.
Module for launching the Textual chat interface with an LM Studio-backed language model. It should be run from the command line.
This class configures the model, system prompt, and save path, and then starts an interactive, full-screen terminal chat
application using the textual
framework. The interface supports live message streaming, styled user and assistant blocks,
and automatic logging of chat history to JSON and CSV formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_url
|
str
|
URL of the LM Studio API endpoint used for inference. Defaults to "http://127.0.0.1:1234/v1/chat/completions". |
'http://127.0.0.1:1234/v1/chat/completions'
|
model_name
|
str
|
Name of the model to use in LM Studio (e.g., "llama-3.2-3b-instruct"). |
'llama-3.2-3b-instruct'
|
temperature
|
float
|
Sampling temperature for text generation. Controls randomness. Defaults to 0.7. |
0.7
|
system_prompt
|
str
|
Initial system message to prime the assistant’s behavior. Defaults to a helpful tutoring message. |
'You are a helpful tutor guiding a student. Answer short and concisely.'
|
save_dir
|
Path
|
Directory for saving logged conversations as |
Path('data/logged_dialogue_data')
|
Methods:
Name | Description |
---|---|
run |
Launches the Textual chat application and starts interaction with the model. |
Source code in src/educhateval/chat_ui.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
run()
Launches the Textual app.
Source code in src/educhateval/chat_ui.py
307 308 309 310 311 312 313 314 |
|
Example Usage from Terminal:
chat-ui \
--api_url http://127.0.0.1:1234/v1/chat/completions \
--model llama-3.2-3b-instruct \
--prompt "You are a helpful tutor guiding a student." \
--save_dir data/logged_dialogue_data