pycsamt.agents.metrics#

pycsamt.agents.metrics#

MetricsAgent — answer conversational questions about computed values of a survey line (or all lines), inline, without a modal or a figure.

Where ToolAgent opens a parameter modal and returns a table + figure, the metrics agent turns a question like “what’s the strike of L22PLT?” or “azimuth of all lines?” into a short, friendly text answer with the actual number(s).

Supported value kinds (see METRIC_KINDS):

  • strike — regional geoelectric strike (consensus, ±90°),

  • azimuth — profile bearing from station geometry (PCA, 0–180°N),

  • dimensionality— dominant 1-D / 2-D / 3-D class and the distribution,

  • skew — mean phase-tensor skew |β|,

  • stations — station count (and names),

  • periods — period range (s),

  • frequencies — frequency range (Hz),

  • coordinates — lat/lon bounding box and approximate profile length,

  • quality — mean QC score, flagged stations, tipper presence,

  • summary — a one-paragraph digest combining the above.

The agent never calls an LLM. parse_metric_request() and looks_like_metric_query() are shared, testable helpers the chat router uses to detect a value question and pull out which kinds / scope were asked.

Functions

looks_like_metric_query(text)

Heuristic: does text ask for a computed value of a line?

parse_metric_request(text)

Return (kinds, all_lines) parsed from text.

Classes

MetricsAgent(**_)

Compute and phrase per-line survey values as inline chat answers.

class pycsamt.agents.metrics.MetricsAgent(**_)[source]#

Bases: object

Compute and phrase per-line survey values as inline chat answers.

Parameters:

_ (Any)

execute(input_data)[source]#
Parameters:

input_data (dict[str, Any])

Return type:

AgentResult

pycsamt.agents.metrics.parse_metric_request(text)[source]#

Return (kinds, all_lines) parsed from text.

kinds is the ordered, de-duplicated list of metric kinds the user asked about; all_lines is True when the request spans every line.

Examples

>>> parse_metric_request("what is the strike of L22PLT?")
(['strike'], False)
>>> parse_metric_request("give me the azimuth for all lines")
(['azimuth'], True)
>>> parse_metric_request("tell me about this line")
(['summary'], False)
Parameters:

text (str)

Return type:

tuple[list[str], bool]

pycsamt.agents.metrics.looks_like_metric_query(text)[source]#

Heuristic: does text ask for a computed value of a line?

True when the message names a value (strike, azimuth, …) and is phrased as a question / scoped to a line, and is not a plot/workflow request.

Examples

>>> looks_like_metric_query("what's the strike of L22PLT?")
True
>>> looks_like_metric_query("plot the strike rose")
False
>>> looks_like_metric_query("run phase tensor analysis")
False
Parameters:

text (str)

Return type:

bool