Session & host state
Read conversation history, read pipeline state, list installed plugins, locate plugin directories / runtimes by id, write logs.
Session and history
host.get_recent_conversation(max_turns: int = 5) -> list[dict]
host.get_history_as_text(query: str = "") -> strEach get_recent_conversation item:
{
"id": int,
"speaker": "peer" | "self",
"speaker_label": str, # display name, already localised with the UI language
"transcript": str, # raw ASR transcript
"translation": str,
"time": str,
}- Only valid sentences are included (transcript or translation non-empty).
max_turnsis clamped to[1, 50].- Compatible alias:
getRecentConversation.
When feeding an LLM (e.g. an assistant plugin), use
transcriptonly: machine translation adds a second layer of distortion.
get_history_as_text(query) returns the history rendered as text (query, when non-empty, filters by keyword first); it is ready to be spliced straight into a prompt.
Pipeline and host state
host.get_pipeline_state() -> dict
host.get_active_provider(plugin_type: str) -> str
host.list_installed_plugins(type_filter: str = "") -> list[dict]
host.get_app_version() -> str
host.get_locale() -> str
host.log(level: str, message: str, **fields: Any) -> Noneget_pipeline_state():
{
"running": bool,
"loading": bool,
"scene": str,
"source_lang": str,
"target_lang": str,
"outbound_source_lang": str,
"outbound_target_lang": str,
"show_source": bool,
"show_translation": bool,
"enable_translation": bool,
"mic_muted": bool,
"interpretation_mode": bool,
"interpretation_streaming": bool,
"providers": {
"asr": str, "mt": str, "tts": str,
"interpretation": str, "theme": str,
},
}get_active_provider("asr" | "mt" | "tts" | "theme" | "interpretation")→ plugin id or"none".- Each
list_installed_plugins(type_filter)item containsid/name/type/enabled/version/source_path(same source as the Workshop list). Passing""or"all"totype_filtermeans everything;"other"means uncategorised. get_locale()returns the current UI language (e.g.zh-CN/en-US).log(level, message, **fields):level∈debug|info|warning|error, written to the host's plugin log channel, and may carry arbitrary JSON fields (host.log("info", "加载完成", ms=1200)). This is your only troubleshooting outlet — it is the first thing we see when a user sends logs.
Locating plugins and runtimes by id
host.plugin_dir(plugin_id: str) -> str # install directory; "" when not installed
host.has_plugin(plugin_id: str) -> bool # installed (enabled not required)
host.list_installed_plugins() -> list[dict] # each item carries source_path
host.runtime_dir(runtime_id: str) -> str # runtime directory; "" when not downloaded
host.has_runtime(runtime_id: str) -> bool # whether the runtime is readyNever hard-code a sibling plugin's directory name — a Workshop install names the folder after the plugin id (<data dir>/workshop/workshop.amd_llama), while one you drop into extensions/ yourself may use underscores. Looking it up by id is correct for both:
from pathlib import Path
dep = self.host.plugin_dir("workshop.common_llama")
exe = Path(dep) / "llama" / "llama-server.exe" if dep else NoneThe matching dependency declaration and host gate are in Prerequisite plugins and Host runtimes.
Recommendations
- When you need to know "is it running right now" rather than "read the state once", subscribe to the
pipeline.stateevent instead of pollingget_pipeline_state()(see Event bus). - When deciding availability in
check_ready(), useplugin_dir()/runtime_dir()/inspect_model_artifact()to make a file-level decision instead of starting a service (see Capabilities & read-only contract).
Related
- Event bus
- Prerequisite plugins / Host runtimes
- Model artifacts
- assistant — pack context with
get_recent_conversation
