Observers API Reference¶
This page provides detailed documentation for the observers in GUM.
Base Observer¶
gum.observers.Observer(name: Optional[str] = None)
¶
Bases: ABC
Base class for all observers in the GUM system.
This abstract base class defines the interface for all observers that monitor user behavior. Observers are responsible for collecting data about user interactions and sending updates through an asynchronous queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
A custom name for the observer. If not provided, the class name will be used. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
update_queue |
Queue
|
Queue for sending updates to the main GUM system. |
_name |
str
|
The name of the observer. |
_running |
bool
|
Flag indicating if the observer is currently running. |
_task |
Optional[Task]
|
Background task handle for the observer's worker. |
Source code in gum/observers/observer.py
Attributes¶
name: str
property
¶
Get the name of the observer.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The observer's name. |
update_queue = asyncio.Queue()
instance-attribute
¶
Functions¶
get_update()
async
¶
Get the next update from the queue if available.
Returns:
| Type | Description |
|---|---|
|
Optional[Update]: The next update from the queue, or None if the queue is empty. |
Source code in gum/observers/observer.py
set_session_factory(factory) -> None
¶
Provide an async session factory for observers that need direct DB access.
Default is a no-op; override in subclasses that persist raw events (e.g. FocusObserver writing to focus_events).
Source code in gum/observers/observer.py
stop() -> None
async
¶
Stop the observer and clean up resources.
This method cancels the worker task and drains the update queue.
Source code in gum/observers/observer.py
Screen Observer¶
gum.observers.Screen(model_name: str = 'gpt-4.1-mini', screenshots_dir: str = '~/.cache/gum/screenshots', skip_when_visible: Optional[str | list[str]] = None, transcription_prompt: Optional[str] = None, summary_prompt: Optional[str] = None, history_k: int = 10, debug: bool = False, api_key: str | None = None, api_base: str | None = None, inject_app_metadata: bool = True)
¶
Bases: Observer
Observer that captures and analyzes screen content around user interactions.
Captures screenshots before and after user interactions (mouse clicks and scrolls) and uses a vision LLM to analyze the content. Also injects the currently focused application name and window title into the prompt to prevent the LLM from misidentifying the active application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Vision model to use. Defaults to "gpt-4.1-mini". |
'gpt-4.1-mini'
|
screenshots_dir
|
str
|
Directory to store screenshots. |
'~/.cache/gum/screenshots'
|
skip_when_visible
|
Optional[str | list[str]]
|
App names to skip when visible. |
None
|
transcription_prompt
|
Optional[str]
|
Custom transcription prompt. |
None
|
summary_prompt
|
Optional[str]
|
Custom summary prompt. |
None
|
history_k
|
int
|
Number of recent screenshots to keep in history. |
10
|
debug
|
bool
|
Enable debug logging. |
False
|
api_key
|
str | None
|
API key override. |
None
|
api_base
|
str | None
|
API base URL override. |
None
|