Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ <h1>commons</h1>

<pre><code>pip install commons</code></pre>

<p>The Python package is currently in a pre-release beta stage, but you can install and play around with it today, with more features arriving over the next few weeks.</p>

<section class="content-section">
<h2>Design philosophy</h2>

Expand Down
6 changes: 4 additions & 2 deletions pkg-py/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

`commons` is a constructor for trustworthy data agents. It gives an LLM data, semantic, and context layers to work with, tools for querying them, and A/B/C provenance tags so every answer carries a classification as to its trustworthiness.

**Status: beta.** The agent, the three layers (data, semantics, and context), and the chat UI are implemented: `commons.ui.server()` wires an agent to a chat element in a py-shiny app, and outside one, answers come back as text and server-rendered HTML. Python 3.11 or later is required.
The agent, the three layers (data, semantics, and context), and the chat UI are implemented: `commons.ui.server()` wires an agent to a chat element in a py-shiny app, and outside one, answers come back as text and server-rendered HTML. Python 3.11 or later is required.

## Optional extras

The core dependencies will allow you to build and query an agent. Installing the `shiny` group (via `pip install commons[shiny]`) will additionally install everything `commons.ui` needs to serve a full chat UI; importing `commons.ui` without it raises an `ImportError` that names the missing packages and the install command. The `tracing` group installs what `log=True` needs to write trace files locally.
The core dependencies will allow you to build and query an agent. Installing the `shiny` group (via `pip install commons[shiny]`) will additionally install everything `commons.ui` needs to serve a full chat UI; importing `commons.ui` without it raises an `ImportError` that names the missing packages and the install command. The `tracing` group installs the OpenTelemetry packages that `log=True` uses to write trace files locally; when running locally or deploying your app somewhere other than Posit Connect, logging also needs a tracer provider, as [Logging conversations](https://posit-dev.github.io/commons/py/user-guide/get-started.html#logging-conversations) describes.

To install the complete package with all extras, run `pip install "commons[shiny,tracing]"`.

## Get started

Expand Down
2 changes: 1 addition & 1 deletion pkg-py/docs/02-governance.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ Conversation logging is off by default. With `Commons(log=True)`, `commons` turn

Capture is controlled for the whole process by the `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` environment variable, and the agent's `log` argument only sets it when nothing else has. Once the variable is on, whether `log=True` or the environment turned it on, chatlas records the conversations of every agent in a traced process, including agents built with `log=False`. The variable is on when it is `true` or `1`, in any case. Any other non-empty value turns capture off, and `log=True` leaves that value alone. An empty value counts as unset.

On Posit Connect, both the server administrator and the application author must opt in before any conversation is recorded. The administrator must enable OpenTelemetry and allow content instrumentation. The author opts in by passing `log=True`, or by setting the capture variable. With `log=True`, `commons` also turns on [Content Observability](https://docs.posit.co/connect/user/content-settings/#content-observability) for the content item when the process started without tracing. Recording then begins after the content process restarts. A process that already has tracing records from the first conversation, unless content capture is turned off. Off Connect, nothing is recorded unless the application installs a tracer provider, and the spans then go wherever that provider exports them. See [Logging conversations](01-get-started.qmd#logging-conversations) for the setup.
On Posit Connect, both the server administrator and the application author must opt in before any conversation is recorded. The administrator must enable OpenTelemetry and allow content instrumentation. The author opts in by passing `log=True`, or by setting the capture variable. With `log=True`, `commons` also turns on [Content Observability](https://docs.posit.co/connect/user/content-settings/#content-observability) for the content item when the process started without tracing. Recording then begins after the content process restarts. A process that already has tracing records from the first conversation, unless content capture is turned off. When running locally or deploying your app somewhere other than Posit Connect, nothing is recorded unless the application installs a tracer provider, and the spans then go wherever that provider exports them. See [Logging conversations](01-get-started.qmd#logging-conversations) for the setup.

Content owners and collaborators can read the traces on Connect, for example with `commons.trajectory_read()` (see [Reading logged conversations](01-get-started.qmd#reading-logged-conversations)). `share_with` adds the named users as collaborators, which gives them more than access to the traces. Store any exported transcripts and review notes only in an appropriately protected location, and review traces only in an environment trusted to handle internal user data, such as [Posit Workbench](https://posit.co/products/enterprise/workbench). Connect or the configured exporter decides retention and access for the OpenTelemetry data, not `commons`.
71 changes: 3 additions & 68 deletions pkg-py/great-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,74 +120,14 @@ include_in_header:
})();
</script>

# Selected by class and meta-name substrings on purpose: great-docs drops
# every include_in_header entry whose text contains its own "gd-announcement"
# marker, so naming either in full removes this script silently.
#
# The banner is built client-side and its url is used verbatim, so Quarto
# never rewrites it per page depth and a relative link resolved against the
# current page's directory: from user-guide/ the banner asked for
# user-guide/user-guide/. The prefix comes from Quarto's offset meta, which is
# how great-docs' own version selector and sidebar scripts find the site root,
# and it stays correct in a pull request preview and inside a /v/ copy.
#
# The raw path is read back from the meta, not from the link: assigning to
# a.href reflects the *resolved* absolute URL into the attribute, so reading
# the link would only ever see the already-wrong absolute path.
- text: |
<script>
(function () {
var tries = 0;
function fix() {
var link = document.querySelector('[class*="announcement-banner"] a');
if (!link) {
if (tries++ < 100) return window.setTimeout(fix, 50);
return;
}
if (link.dataset.commonsOffsetApplied) return;
var ann = document.querySelector('meta[name$="announcement"]');
var raw = ann ? ann.getAttribute("data-url") || "" : "";
if (!raw || /^([a-z][a-z0-9+.-]*:|\/\/|\/|#)/i.test(raw)) return;
var off = document.querySelector('meta[name="quarto:offset"]');
var prefix = (off ? off.getAttribute("content") || "./" : "./");
var fixed = prefix.replace(/\/?$/, "/") + raw;
link.setAttribute("href", fixed);
// Quarto stashes the pre-rewrite href here and its external-link
// pass restores it, which would undo the line above. That pass
// treats this link as external whenever the served prefix differs
// from site_url, which is the case in every pull request preview,
// so both the opt-out class and the stashed value are set.
link.classList.add("no-external");
link.dataset.originalHref = fixed;
link.dataset.commonsOffsetApplied = "1";
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", fix);
} else {
fix();
}
})();
</script>

versions:
- label: "0.2.0 (dev)"
tag: dev
version: "0.2.0"
prerelease: true
# A beta, but the newest published release, so it holds the latest slot and
# is what /py/ serves: that matches what `pip install commons` resolves to.
# `latest` has to be set explicitly, because a prerelease is excluded from
# latest auto-detection and every entry here is one. The beta warning is
# carried by the announcement banner rather than by a selector badge.
- label: "0.1.0b2"
tag: "0.1.0b2"
version: "0.1.0b2"
prerelease: true
latest: true
# - label: "0.1.0b1"
# tag: "0.1.0b1"
# version: "0.1.0b1"
# prerelease: true
- label: "0.1.0"
tag: "0.1.0"
version: "0.1.0"

version_selector:
enabled: true
Expand All @@ -199,8 +139,3 @@ version_aliases:
stable: true
dev: true

announcement:
content: "Heads up! `commons` for Python is *still in beta* and is not yet equal to the R package in functionality. Click here to see specific feature parity."
type: info
url: user-guide/feature-parity.html
dismissable: true
9 changes: 9 additions & 0 deletions pkg-py/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ If you want the chat UI, install the `shiny` extra, as well:
uv pip install "commons[shiny]"
```

To log conversations with `log=True`, install the `tracing` extra; when running locally or deploying your app somewhere other than Posit Connect, logging also needs a tracer provider, as [Logging conversations](user-guide/get-started.qmd#logging-conversations) describes. To install the complete package with all extras, run:

```bash
uv pip install "commons[shiny,tracing]"
```

Or, for the development version:

```bash
Expand All @@ -31,6 +37,9 @@ uv pip install "commons @ git+https://github.com/posit-dev/commons#subdirectory=

# with the shiny UI dependencies:
uv pip install "commons[shiny] @ git+https://github.com/posit-dev/commons#subdirectory=pkg-py"

# the complete package with all extras:
uv pip install "commons[shiny,tracing] @ git+https://github.com/posit-dev/commons#subdirectory=pkg-py"
```

## Get started
Expand Down
2 changes: 1 addition & 1 deletion pkg-py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "commons"
version = "0.1.0b2"
version = "0.1.0"
description = "AI Agents for Data Analysis"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
12 changes: 7 additions & 5 deletions pkg-py/src/commons/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ def enable_trajectory_tracing(
``True`` only when ``log`` is set, the SDK is installed, a tracer
provider is configured, and message content capture is on. A missing SDK
warns. On Connect, an unsupported server warns, and a missing provider
turns on Content Observability and warns. A missing provider off Connect,
or a capture opt-out, returns ``False`` silently. ``share_with`` grants
turns on Content Observability and warns. A capture opt-out returns
``False`` silently, as does a missing provider when the process runs
locally or somewhere other than Posit Connect. ``share_with`` grants
those Connect users access once logging is live. commons configures no
exporter: where the spans go is the caller's OpenTelemetry setup. Capture
is checked last, so a process with no tracing keeps its environment
Expand Down Expand Up @@ -310,7 +311,8 @@ def warn_if_connect_tracing_unsupported(
The server must be at least ``MINIMUM_TRACING_VERSION`` and must allow
content instrumentation. The version is checked first. The settings
endpoint is internal, so a failed request or a missing field means
unknown and warns about nothing. Does nothing off Connect.
unknown and warns about nothing. Does nothing unless the process runs
on Posit Connect.
"""
if not is_connect_runtime():
return
Expand Down Expand Up @@ -348,8 +350,8 @@ def enable_content_observability(
process stays untraced and the warning says when logging begins. The
setting is editable with the ephemeral owner-scoped ``CONNECT_API_KEY``
that Connect gives running content. Attempted once per process, since an
agent is typically built per session. Does nothing off Connect. A Connect
failure warns and never raises.
agent is typically built per session. Does nothing unless the process
runs on Posit Connect. A Connect failure warns and never raises.
"""
global _OBSERVABILITY_ATTEMPTED
if not is_connect_runtime() or _OBSERVABILITY_ATTEMPTED:
Expand Down
5 changes: 3 additions & 2 deletions pkg-py/src/commons/_trajectory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def trajectory_read(
"""Read the conversations an agent logged with `log=True`.

`source` is where to read from. With none, this content's own traces are
read when it runs on Posit Connect. Off Connect, the deployed content's
traces are read when the project has a deployment record, written by
read when it runs on Posit Connect. When it runs locally or somewhere
other than Posit Connect, the deployed content's traces are read when
the project has a deployment record, written by
rsconnect-python under `rsconnect-python/` or by the R package rsconnect
under `rsconnect/`. With several records, the most recently modified
one that may be used (see below) is read, and a warning names it. An
Expand Down
2 changes: 1 addition & 1 deletion pkg-py/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading