API Reference

Gemini Web UI

A simple Streamlit-powered web interface for gemini-cli.

This package provides a web-based graphical user interface for the gemini-cli tool, allowing users to interact with Google’s Gemini models in a chat-like environment. It supports session management, file uploads for context, and image pasting.

Metadata

copyright:
  1. 2025 Riccardo Finotello

license:

MIT, see LICENSE for more details.

gwebui.cli() Any[source]

Entry point for the Gemini CLI Web Interface.

This function locates the app.py script and executes it using the Streamlit CLI. Any command-line arguments passed to this script are forwarded to Streamlit.

Returns:

The exit code of the Streamlit process or other result.

Return type:

Any

Gemini Web UI Application Logic

This module contains the core logic for the Gemini Web UI Streamlit application. It provides a web-based interface for interacting with the gemini-cli tool.

Features

  • Chat Interface: A chat-like interface for sending prompts to Gemini.

  • Session Management: Create, switch, and delete conversation sessions.

  • Context Management: Upload files and paste images to be used as context.

  • History Tracking: Maintains a local history of conversations within the session state.

Authors

gwebui.app.handle_chat_input(upload_dir: Path) None[source]

Process user input, run Gemini CLI, and stream the response.

gwebui.app.init_session_state() None[source]

Initialize Streamlit session state variables.

gwebui.app.inject_custom_css(bg_color: str, sidebar_color: str, text_color: str, sidebar_text_color: str, font_size: int, sidebar_font_size: int) None[source]

Inject custom CSS for theme and typography.

gwebui.app.main() None[source]

Run the Streamlit web interface for the Gemini CLI.

gwebui.app.render_chat_history() None[source]

Render the conversation history in the main chat area.

gwebui.app.render_sidebar(upload_dir: Path, available_sessions: list[SessionInfo], sidebar_color: str) None[source]

Render the sidebar with session management, model selection, and context.

Gemini Web UI Entry Point

This module serves as the entry point for the Gemini Web UI application. It is responsible for bootstrapping the Streamlit server and launching the main application logic defined in app.py.

Authors

gwebui.main.cli() Any[source]

Entry point for the Gemini CLI Web Interface.

This function locates the app.py script and executes it using the Streamlit CLI. Any command-line arguments passed to this script are forwarded to Streamlit.

Returns:

The exit code of the Streamlit process or other result.

Return type:

Any

Gemini Web UI Tools

This module contains reusable utility functions and core logic for the Gemini Web UI.

gwebui.tools.adjust_color_nuance(hex_color: str, saturation_factor: float = 0.5, lightness_factor: float = 0.1) str[source]

Adjust the nuance of a colour by reducing saturation and shifting lightness.

gwebui.tools.build_gemini_command(prompt: str, upload_dir: Path, session_id: str | None, allowed_tools: list[str], model: str | None = None, stream: bool = False) list[str][source]

Construct the Gemini CLI command.

gwebui.tools.delete_session(session_id: str) bool[source]

Delete a session file from disk.

gwebui.tools.get_file_emoji(path: Path) str[source]

Return an emoji based on the file type or extension.

gwebui.tools.get_project_hash(project_path: Path | None = None) str[source]

Compute the SHA256 hash of the project path for gemini-cli storage.

gwebui.tools.get_session_dir() Path[source]

Locate the gemini-cli session storage directory for the current project.

gwebui.tools.get_text_color(hex_color: str) str[source]

Determine the best text colour (black or white) for a given background.

gwebui.tools.get_upload_dir() Path[source]

Get the directory for storing uploaded files.

gwebui.tools.iter_visible_children(root: Path, include_hidden: bool = False) list[Path][source]

List visible children of a directory sorted with folders first.

gwebui.tools.list_available_sessions() list[SessionInfo][source]

List all sessions available in the gemini-cli storage.

gwebui.tools.load_session_from_disk(session_id: str) list[ChatMessage][source]

Load a session’s message history from disk.

gwebui.tools.node_key(path: Path) str[source]

Create a key-safe identifier from a filesystem path.

gwebui.tools.open_in_browser(path: Path) None[source]

Open a file in the default web browser using its local URI.

gwebui.tools.parse_chat_submission(chat_submission: Any) tuple[str, list[UploadedFile]][source]

Parse Streamlit chat input submission.

gwebui.tools.read_uploaded_file_bytes(uploaded_file: UploadedFile) bytes[source]

Read bytes from a Streamlit UploadedFile.

gwebui.tools.render_file_tree(root: Path, *, container: DeltaGenerator, allow_delete: bool = False, include_hidden: bool = False, key_prefix: str, level: int = 0) None[source]

Render a recursive file tree using nested expanders and buttons.

gwebui.tools.resize_image_if_needed(file_bytes: bytes, filename: str) bytes[source]

Resize image to max 512px dimension if it is an image file.

gwebui.tools.run_gemini_cli_stream(cmd: list[str]) Generator[StreamEvent, None, None][source]

Execute the Gemini CLI command and yield streaming events.

gwebui.tools.safe_upload_filename(original_name: str | None, mime_type: str | None) str[source]

Derive a filesystem-safe filename from a browser-supplied name.

gwebui.tools.save_uploaded_files(attached_files: list[UploadedFile], upload_dir: Path) list[str][source]

Save uploaded files to the specified directory.