Skip to main content

Python SDK for Show Holdings AgentOps monitoring

Project description

showholdings-agentmon

showholdings-agentmon 是 Show Holdings AgentOps 的 Python SDK。

它讓你可以在自己的 Python 程式中,用最小改動接入 run-level 與 step-level monitoring。

安裝

pip install showholdings-agentmon

最小使用範例

from showholdings_agentmon import Monitor

monitor = Monitor(
    api_key="YOUR_API_KEY",
    base_url="https://agentops.showholdings.com",
    project_name="my-agent",
)

with monitor.run(agent_name="general-agent", session_id="session-123"):
    result = run_my_agent()

標準版(含步驟監測)

from showholdings_agentmon import Monitor

monitor = Monitor(
    api_key="YOUR_API_KEY",
    base_url="https://agentops.showholdings.com",
    project_name="my-agent"
)

with monitor.run(agent_name="填入你的 agent 名稱", session_id="填入你自訂的 session 編號"):
    # 記錄步驟 1
    with monitor.step("填入步驟 1 的名稱", step_type="例如:資料處理 / 模型呼叫 / 輸出結果"):
        result_1 = code_of_step_1()

    # 記錄步驟 2
    with monitor.step("填入步驟 2 的名稱", step_type="例如:資料處理 / 模型呼叫 / 輸出結果"):
        result_2 = code_of_step_2()

SDK 行為說明

  • 進入 with monitor.run(...) 時,自動呼叫 POST /api/sdk/runs/start
  • 離開 context 時,自動呼叫 POST /api/sdk/runs/end
  • 進入 with monitor.step(...) 時,自動呼叫 POST /api/sdk/steps/start
  • 離開 step context 時,自動呼叫 POST /api/sdk/steps/end
  • 成功結束會送出 status=success
  • 區塊內拋出例外會送出 status=failed,並附帶:
    • failure_reason_type(例外類別名稱)
    • error_count=1
  • step 區塊內拋出例外會送出 status=failederror_message
  • SDK 對監控 API 採 best effort;監控 API 失敗不會中斷你的主要業務流程

本地開發

pip install -e .[dev]
pytest
python -m build

發布概要

本專案已提供 GitHub Actions:

  • ci.yml:在 push / pull_request 執行測試
  • publish.yml:以 PyPI Trusted Publishing 為目標的正式發布流程

你可先用 TestPyPI 驗證流程,再切換到正式 PyPI 發布。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

showholdings_agentmon-0.2.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

showholdings_agentmon-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file showholdings_agentmon-0.2.0.tar.gz.

File metadata

  • Download URL: showholdings_agentmon-0.2.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for showholdings_agentmon-0.2.0.tar.gz
Algorithm Hash digest
SHA256 edf696ca1bae203abc9b61a83c4a7ff252d5ccbc5b133ebf28d611a4cdee2077
MD5 2afdd52c9ece53833e368bd69e0c3dbf
BLAKE2b-256 50ffefd175fd5df37ed8c050d0ffb8f58cda6b5065bca14dcbe547fe714c4c3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for showholdings_agentmon-0.2.0.tar.gz:

Publisher: publish.yml on andy07s97/showholdings-agentmon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file showholdings_agentmon-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for showholdings_agentmon-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5d4b66488a13911103cd3d829b3958cb606b74abaaf2772ccd5a3613e647b37
MD5 a7c364f877588cdada637dd4d715da6a
BLAKE2b-256 7ee5a4f8953d68c491646664110ce8dee7da147a370c5a1cfc3bbb8151bbbb53

See more details on using hashes here.

Provenance

The following attestation bundles were made for showholdings_agentmon-0.2.0-py3-none-any.whl:

Publisher: publish.yml on andy07s97/showholdings-agentmon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page