← 返回 Skills 市场
gyanesh-m

Galileo python sdk

作者 Gyanesh Malhotra · GitHub ↗ · v1.2.1 · MIT-0
cross-platform ⚠ suspicious
85
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install galileo-python-sdk
功能描述
Complete reference for the Galileo AI platform Python SDK for evaluating, observing, and protecting GenAI applications. Use when building Python applications...
使用说明 (SKILL.md)

Galileo Python SDK

The Galileo Python SDK (galileo) provides a unified interface for the Galileo AI platform — enabling evaluation, observability, and runtime guardrails for GenAI applications. It supports automatic tracing of LLM calls, custom span logging, evaluation experiments, and production-grade guardrails.

SDK Version Detection

Check installed versions before writing any code to pick the right reference:

import importlib.metadata, importlib.util

galileo_ver = importlib.metadata.version("galileo")        # e.g. "2.1.1"
pq_installed = importlib.util.find_spec("promptquality") is not None
pq_ver = importlib.metadata.version("promptquality") if pq_installed else None
print(f"galileo={galileo_ver}, promptquality={pq_ver}")
Installed stack Use
galileo >= 2.0 (with or without promptquality 0.x) This skill — GalileoLogger, @log, galileo_context
galileo \x3C 2.0 + promptquality >= 1.0 Promptquality 1.x Reference

Note: promptquality >= 1.0 and galileo >= 2.0 are mutually incompatible — they require different major versions of galileo-core. Installing both will cause dependency conflicts.

Additional references:

Installation

pip install galileo

For evaluation features with the legacy prompt engineering interface:

pip install promptquality

For runtime guardrails:

pip install galileo-protect

Quick Start

import os
from galileo import galileo_context
from galileo.openai import openai

galileo_context.init(project="my-project", log_stream="my-log-stream")

client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))

response = client.chat.completions.create(
    messages=[{"role": "user", "content": "Explain quantum computing in one sentence."}],
    model="gpt-4o",
)

print(response.choices[0].message.content)

galileo_context.flush()

Authentication

Set the following environment variables:

# .env file or shell environment
GALILEO_API_KEY="your-api-key"            # Required — from Galileo console
GALILEO_CONSOLE_URL="https://app.galileo.ai"  # Console URL (or self-hosted URL)
GALILEO_PROJECT="my-project"              # Optional — default project
GALILEO_LOG_STREAM="my-log-stream"        # Optional — default log stream
GALILEO_LOGGING_DISABLED="false"          # Optional — disable logging

For the legacy promptquality package, authenticate programmatically:

import promptquality as pq
pq.login("https://app.galileo.ai")

Observability and Tracing

Initializing the Galileo Context

from galileo import galileo_context

galileo_context.init(project="my-project", log_stream="my-log-stream")

Wrapped OpenAI Client (Auto-Logging)

Import the Galileo-wrapped OpenAI client to automatically trace all calls:

from galileo.openai import openai

client = openai.OpenAI()
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "Hello"}],
    model="gpt-4o",
)

The @log Decorator

Use @log to create spans for your functions. Supported span types: workflow, llm, retriever, tool.

from galileo import log

@log
def my_workflow():
    result = call_openai()
    return result

@log(span_type="retriever")
def retrieve_documents(query: str):
    docs = vector_store.search(query)
    return docs

@log(span_type="tool")
def search_web(query: str):
    return web_api.search(query)

Nested Workflows

from galileo import log

@log
def agent_pipeline(user_input: str):
    context = retrieve_documents(user_input)
    tool_result = search_web(user_input)
    response = generate_response(user_input, context, tool_result)
    return response

@log(span_type="retriever")
def retrieve_documents(query: str):
    return ["doc1", "doc2"]

@log(span_type="tool")
def search_web(query: str):
    return "search result"

@log
def generate_response(query: str, context: list, tool_result: str):
    client = openai.OpenAI()
    return client.chat.completions.create(
        messages=[{"role": "user", "content": query}],
        model="gpt-4o",
    )

Context Manager

Scope logging to a specific block and auto-flush on exit:

from galileo import galileo_context

with galileo_context(project="my-project", log_stream="my-log-stream"):
    result = my_workflow()
    print(result)

Flushing Traces

Upload captured traces to Galileo:

galileo_context.flush()

Evaluation

Running Experiments with promptquality

import promptquality as pq

pq.login("https://app.galileo.ai")

template = "Explain {{topic}} to me like I'm a 5 year old"
data = {"topic": ["Quantum Physics", "Politics", "Large Language Models"]}

pq.run(
    project_name="my-first-project",
    template=template,
    dataset=data,
    settings=pq.Settings(
        model_alias="ChatGPT (16K context)",
        temperature=0.8,
        max_tokens=400,
    ),
)

Evaluation Runs with Custom Workflows (galileo 2.x)

Use GalileoLogger to log traces for evaluation:

from galileo import GalileoLogger

logger = GalileoLogger(project="my_project", log_stream="my_run")

eval_set = ["What are hallucinations?", "What are intrinsic hallucinations?"]
for input_text in eval_set:
    output = llm.call(input_text)
    logger.add_single_llm_span_trace(
        input=input_text,
        output=output,
        model="gpt-4o",
    )

logger.flush()

For the galileo \x3C 2.0 + promptquality >= 1.0 stack, use EvaluateRun — see Promptquality 1.x Reference.

See Advanced Evaluation Patterns for more.

Guardrails / Protect

Creating a Protection Stage

from galileo import GalileoMetrics
from galileo.stages import create_protect_stage
from galileo_core.schemas.protect.rule import Rule, RuleOperator
from galileo_core.schemas.protect.ruleset import Ruleset
from galileo_core.schemas.protect.stage import StageType

rule = Rule(
    metric=GalileoMetrics.input_toxicity,
    operator=RuleOperator.gt,
    target_value=0.1,
)

ruleset = Ruleset(rules=[rule])

stage = create_protect_stage(
    name="toxicity-guard",
    stage_type=StageType.central,
    prioritized_rulesets=[ruleset],
    description="Block toxic input.",
)

Invoking Runtime Protection

from galileo.protect import invoke_protect, ainvoke_protect
from galileo_core.schemas.protect.payload import Payload

payload = Payload(input="User message to check.")

response = invoke_protect(payload=payload, stage_name="toxicity-guard")

# Async variant
response = await ainvoke_protect(payload=payload, stage_name="toxicity-guard")

Stage Types

  • Central stages — Created and managed by governance teams; rulesets defined at creation time
  • Local stages — Created without rulesets; rulesets supplied at runtime by application teams

See Guardrail Metrics Reference for all available metrics.

Common Patterns

Multi-Turn Conversations

from galileo import log
from galileo.openai import openai

client = openai.OpenAI()

@log
def chat(messages: list):
    response = client.chat.completions.create(
        messages=messages,
        model="gpt-4o",
    )
    return response.choices[0].message.content

messages = []
messages.append({"role": "user", "content": "What is RAG?"})
reply = chat(messages)
messages.append({"role": "assistant", "content": reply})
messages.append({"role": "user", "content": "How do I implement it?"})
reply = chat(messages)

RAG Pipeline with Retriever Spans

from galileo import log
from galileo.openai import openai

client = openai.OpenAI()

@log(span_type="retriever")
def retrieve(query: str):
    results = vector_db.similarity_search(query, k=5)
    return [doc.page_content for doc in results]

@log
def rag_pipeline(question: str):
    context = retrieve(question)
    prompt = f"Context: {context}\
\
Question: {question}"
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": prompt}],
        model="gpt-4o",
    )
    return response.choices[0].message.content

Agent Tool Calling

from galileo import log

@log(span_type="tool")
def math_operation(a: float, b: float, op: str) -> str:
    if op == "add":
        return str(a + b)
    elif op == "multiply":
        return str(a * b)
    raise ValueError(f"Unknown op: {op}")

@log(span_type="tool")
def web_search(query: str):
    return search_api.query(query)

@log
def agent(user_input: str):
    plan = plan_actions(user_input)
    results = []
    for action in plan:
        if action.tool == "math_operation":
            results.append(math_operation(action.input))
        elif action.tool == "web_search":
            results.append(web_search(action.input))
    return synthesize(results)

Best Practices

  1. Always set environment variables for GALILEO_API_KEY and GALILEO_CONSOLE_URL rather than hardcoding credentials.
  2. Organize projects and log streams by application, environment, or team to keep traces manageable.
  3. Call galileo_context.flush() at the end of each request or batch to ensure traces are uploaded. In web servers, flush at the end of each request handler.
  4. Use the context manager (with galileo_context(...)) for scoped logging that auto-flushes on exit.
  5. Use specific span types (retriever, tool, llm, workflow) to get the most out of Galileo's trace visualization.
  6. Handle errors gracefully — wrap flush() calls in try/except to prevent logging failures from crashing your application.
  7. Use the wrapped OpenAI client (from galileo.openai import openai) for zero-config automatic tracing of all OpenAI calls.
  8. Leverage guardrail metrics in production to catch hallucinations, toxic content, and PII before they reach end users.

Resources

安全使用建议
This appears to be legitimate Galileo SDK documentation, but there are two issues you should consider before using it: (1) the skill metadata does not declare the environment variables that the instructions actually use—GALILEO_API_KEY (and examples using OPENAI_API_KEY) are required for the SDK to send traces to Galileo; (2) the SDK’s instrumentation will capture and transmit LLM inputs, outputs, and other runtime data to https://app.galileo.ai (or a self-hosted console URL), which may include sensitive or regulated data. Actions to take before installing/using: verify the skill source (confirm the GitHub repo and official documentation), only set GALILEO_API_KEY from a trusted vendor-provided key, avoid enabling automatic instrumentation in environments with sensitive data, prefer a self-hosted console URL if your organization requires it, limit which frameworks/components are instrumented, and test in an isolated environment while monitoring network traffic. Also ask the publisher to correct the skill manifest to list required env vars and a homepage so the credential usage is explicit.
功能分析
Type: OpenClaw Skill Name: galileo-python-sdk Version: 1.2.1 The skill bundle provides a comprehensive and legitimate reference for the Galileo AI Python SDK, covering observability, evaluation, and guardrails. The code snippets and instructions in SKILL.md and the reference files (EVALUATION.md, INTEGRATIONS.md, etc.) align with the stated purpose of the SDK, using standard practices for authentication via environment variables and data export to official Galileo endpoints (e.g., app.galileo.ai).
能力评估
Purpose & Capability
The name and description match the SKILL.md content: this is a reference for the Galileo Python SDK (evaluation, observability, guardrails). The capabilities described (tracing, metrics, guardrails, integrations) align with the stated purpose.
Instruction Scope
The runtime instructions direct the agent/developer to instrument many frameworks and to auto-log/traces LLM calls, then upload traces via HTTP to https://app.galileo.ai/api/otel/v1/traces and other Galileo endpoints. That behavior is consistent with an observability SDK, but it means prompts, inputs, outputs, and possibly PII will be captured and transmitted. The SKILL.md also demonstrates using OPENAI_API_KEY and GALILEO_API_KEY from the environment even though the skill metadata declared no required env vars—this is an important scope mismatch.
Install Mechanism
This is an instruction-only skill with no install spec or code files in the registry bundle. The doc recommends pip install commands (galileo, promptquality, galileo-protect), which is expected for a Python SDK reference and represents normal, low-risk guidance.
Credentials
The SKILL.md clearly requires secrets/environment variables (GALILEO_API_KEY, GALILEO_CONSOLE_URL, optional GALILEO_PROJECT, GALILEO_LOG_STREAM, and examples referencing OPENAI_API_KEY) but registry metadata lists no required env vars or primary credential. Requesting GALILEO_API_KEY is proportionate to the SDK’s function, but the manifest omission is a mismatch that could mislead users about what credentials will be accessed or required.
Persistence & Privilege
The skill does not request always:true, does not install or persist code via an install spec, and does not claim to modify other skills or system-wide settings. Autonomous invocation is allowed (default) but not combined with other elevated privileges here.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install galileo-python-sdk
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /galileo-python-sdk 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.2.1
Add galileo python sdk skill
元数据
Slug galileo-python-sdk
版本 1.2.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Galileo python sdk 是什么?

Complete reference for the Galileo AI platform Python SDK for evaluating, observing, and protecting GenAI applications. Use when building Python applications... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 85 次。

如何安装 Galileo python sdk?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install galileo-python-sdk」即可一键安装,无需额外配置。

Galileo python sdk 是免费的吗?

是的,Galileo python sdk 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Galileo python sdk 支持哪些平台?

Galileo python sdk 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Galileo python sdk?

由 Gyanesh Malhotra(@gyanesh-m)开发并维护,当前版本 v1.2.1。

💬 留言讨论