pipeworks_mud_mapper.callbacks.ollama_generation_callbacks

Callbacks for Ollama generation and response application.

This module contains the callbacks that: - generate descriptions via /api/chat - apply generated text to room descriptions - provide clipboard and prompt population helpers

Functions

generate_description(n_clicks, server_url, model, ...)

Generate a room description using Ollama.

send_to_description(n_clicks, response_text, ...)

Send the generated response to the room description field.

handle_clipboard_copy(n_clicks, response_text)

Show feedback when clipboard copy happens.

populate_prompt_from_description(n_clicks, ...)

Populate the user prompt with the current room description.

copy_system_prompt(n_clicks, system_prompt)

Copy the system prompt to clipboard and show feedback.

render_ollama_status(*payloads)

Render the latest Ollama status payload from any source.

Module Contents

pipeworks_mud_mapper.callbacks.ollama_generation_callbacks.generate_description(n_clicks, server_url, model, system_prompt, user_prompt, seed, temperature, top_k, top_p, num_ctx, num_predict, template_id, target_words)[source]

Generate a room description using Ollama.

Sends a request to the Ollama /api/chat endpoint with proper message roles (system/user) for better prompt handling by the LLM.

The running callback parameter provides real-time feedback:

  • Button shows “Generating…” with spinner

  • Previous response is cleared

Metadata Output

On successful generation, this callback outputs metadata to the ollama-last-generation-info store. This metadata is a dict matching the OllamaGenerationInfo model fields.

pipeworks_mud_mapper.callbacks.ollama_generation_callbacks.send_to_description(n_clicks, response_text, selected_room, zone_data, generation_info, validation_info)[source]

Send the generated response to the room description field.

Also updates the zone data directly so the change is immediately reflected in the save state. When generation metadata is available, it is stored in the room’s llm_generation field for provenance.

pipeworks_mud_mapper.callbacks.ollama_generation_callbacks.handle_clipboard_copy(n_clicks, response_text)[source]

Show feedback when clipboard copy happens.

pipeworks_mud_mapper.callbacks.ollama_generation_callbacks.populate_prompt_from_description(n_clicks, room_description, room_name)[source]

Populate the user prompt with the current room description.

pipeworks_mud_mapper.callbacks.ollama_generation_callbacks.copy_system_prompt(n_clicks, system_prompt)[source]

Copy the system prompt to clipboard and show feedback.

pipeworks_mud_mapper.callbacks.ollama_generation_callbacks.render_ollama_status(*payloads)[source]

Render the latest Ollama status payload from any source.