PyHydroGeophysX.agents.assistants.geosage package#

Submodules#

PyHydroGeophysX.agents.assistants.geosage.tools module#

GeoSAGE’s tools: one per stage of the workflow, with what each needs and makes.

Each tool is offered to the controller only once what it requires exists, so the order below is a consequence of the data, not a script. The handlers are placeholders for the port from ZhengyangFang/GeoSAGE; each says what it has to do and what it must return. A handler takes the RunContext and returns (summary, outputs): one sentence a user can read, and a dict of the artifacts named in produces. ctx.config holds the configuration from workflow.configure(); ctx.get(key) reads an earlier tool’s artifact; ctx.output_dir is where files go; ctx.settings has the model access for the LLM-based agents (api_key, model, llm_provider).

The artifact keys are the contract between the stages:

field_data gridded gravity and magnetic data on the study area,

with bounds, fields and uncertainties (DataAgent)

geological_priors lithologic classes, physical-property ranges and

grouping rules, or None when none are available (PetrologyAgent)

property_models density and susceptibility on the inversion mesh,

with fit statistics and the mesh (InversionAgent)

geo_model unit and Geo-group labels per cell, their statistics,

and the figures (GeoAgent, PetrologyAgent)

draft_report the interpretation and target ranking (ReportAgent) report_files the reviewed report, {"report_markdown": path};

its existence is what lets the run finish (ReviewAgent)

PyHydroGeophysX.agents.assistants.geosage.workflow module#

GeoSAGE’s run: what “Auto to report” does when GeoSAGE is the assistant.

Follows PyHydroGeophysX.agents.assistants.WORKFLOW_CONTRACT. The loop, the step events the studio shows, step-by-step approval and questions to the user all come from PyHydroGeophysX.agents.runtime.entry.drive(); what is GeoSAGE’s own is the configuration (configure()), the tools (tools) and the decision prompt (CONTROLLER_PROMPT).

PyHydroGeophysX.agents.assistants.geosage.workflow.CONTROLLER_PROMPT = 'You are running GeoSAGE, a geological-interpretation workflow from joint gravity and magnetic inversion. Choose the single next action.\n\n{transcript}\n\nActions you can take now:\n{menu}\n\nReply with JSON only - no prose, no code fence. Give your reasoning first:\n{{"why": "<one or two sentences: what the run has shown so far, and so what to do next>", "tool": "<name from the list>"}}\nor, when the reviewed report exists:\n{{"why": "<one short sentence>", "done": true}}\n\nRules:\n- Choose only from the list above. A tool not listed cannot run yet, usually\n  because something it needs has not been produced.\n- Compile the geological priors before building the quasi-geological model when\n  the user supplied geological information; without priors the grouping falls\n  back to GMM/BIC, and the report must say so.\n- The report is final only once it has been reviewed.\n- If a step failed, do not repeat it unchanged; move on and let the report state\n  what is missing.\n'#

How the controller is told what kind of run this is. {transcript} and {menu} are filled in by the controller.

PyHydroGeophysX.agents.assistants.geosage.workflow.configure(payload: Dict[str, Any]) → Dict[str, Any][source]#

The run’s configuration from the request: GeoSAGE’s ContextAgent.

Placeholder for the port: today it only carries the request and the input files through. The ContextAgent turns the request into a complete executable configuration - data fields, inversion settings, grouping settings - on top of the defaults.

PyHydroGeophysX.agents.assistants.geosage.workflow.run(payload: Dict[str, Any], progress: Callable[[...], None], *, approve: Callable[[...], Any] | None = None, on_event: Callable[[Dict[str, Any]], None] | None = None, events: list | None = None, **_hooks: Any) → Dict[str, Any][source]#

Run GeoSAGE on payload and return the studio’s result.

Module contents#

GeoSAGE: geological reasoning from joint gravity and magnetic inversion.

Geological Semantic Analysis for Geophysical Exploration (Fang et al., in review; source at ZhengyangFang/GeoSAGE, MIT licence). A user states an exploration objective; GeoSAGE prepares the gravity and magnetic data, compiles geological and petrophysical priors, runs a deterministic joint inversion (SimPEG, cross-gradient coupled), turns the density and susceptibility volumes into a quasi-geological model (prior-guided units and Geo groups, or GMM/BIC when priors are thin), ranks targets, writes the interpretation and has it reviewed before it is final.

Status: being ported. This package is the scaffold the port fills in. The pipeline is laid out as tools in tools - one per stage of the paper’s Figure 1, with what each requires and produces - and workflow runs them on the same controller as AQUAH, so the studio’s chat, live timeline, step approval and report view work for GeoSAGE as soon as the tools do. Until then it is listed in the studio’s assistant menu but cannot be selected; set status="ready" below once the tools run.

The paper’s seven agents map onto this package as follows:

ContextAgent

workflow.configure() (request -> configuration)

DataAgent

prepare_data tool

PetrologyAgent

compile_priors tool, and unit/group naming inside build_quasi_geology

InversionAgent

run_joint_inversion tool (settings), SimPEG backend

GeoAgent

build_quasi_geology tool (grouping settings)

ReportAgent

write_report tool (draft, and revision on review)

ReviewAgent

review_report tool; its approval is the final report