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
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-4o-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)
¶
Bases: Observer
Observer that captures and analyzes screen content around user interactions.
This observer captures screenshots before and after user interactions (mouse movements, clicks, and scrolls) and uses GPT-4 Vision to analyze the content. It can also take periodic screenshots and skip captures when certain applications are visible.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
screenshots_dir
|
str
|
Directory to store screenshots. Defaults to "~/.cache/gum/screenshots". |
'~/.cache/gum/screenshots'
|
skip_when_visible
|
Optional[str | list[str]]
|
Application names to skip when visible. Defaults to None. |
None
|
transcription_prompt
|
Optional[str]
|
Custom prompt for transcribing screenshots. Defaults to None. |
None
|
summary_prompt
|
Optional[str]
|
Custom prompt for summarizing screenshots. Defaults to None. |
None
|
model_name
|
str
|
GPT model to use for vision analysis. Defaults to "gpt-4o-mini". |
'gpt-4o-mini'
|
history_k
|
int
|
Number of recent screenshots to keep in history. Defaults to 10. |
10
|
debug
|
bool
|
Enable debug logging. Defaults to False. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
_CAPTURE_FPS |
int
|
Frames per second for screen capture. |
_PERIODIC_SEC |
int
|
Seconds between periodic screenshots. |
_DEBOUNCE_SEC |
int
|
Seconds to wait before processing an interaction. |
_MON_START |
int
|
Index of first real display in mss. |
Initialize the Screen observer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
screenshots_dir
|
str
|
Directory to store screenshots. Defaults to "~/.cache/gum/screenshots". |
'~/.cache/gum/screenshots'
|
skip_when_visible
|
Optional[str | list[str]]
|
Application names to skip when visible. Defaults to None. |
None
|
transcription_prompt
|
Optional[str]
|
Custom prompt for transcribing screenshots. Defaults to None. |
None
|
summary_prompt
|
Optional[str]
|
Custom prompt for summarizing screenshots. Defaults to None. |
None
|
model_name
|
str
|
GPT model to use for vision analysis. Defaults to "gpt-4o-mini". |
'gpt-4o-mini'
|
history_k
|
int
|
Number of recent screenshots to keep in history. Defaults to 10. |
10
|
debug
|
bool
|
Enable debug logging. Defaults to False. |
False
|