이 모듈은 Weave 추적 서버에서 사용하는 스키마와 인터페이스를 정의합니다.

CallSchema

Weave에서 Call 객체의 스키마입니다.
class CallSchema:
    id: str                          # Unique identifier for the call
    project_id: Optional[str]        # Associated project identifier
    op_name: str                     # Name of the operation
    display_name: Optional[str]      # User-friendly display name
    trace_id: str                    # Trace this call belongs to
    parent_id: Optional[str]         # Parent call ID (for nested calls)
    started_at: datetime             # When the call started
    ended_at: Optional[datetime]     # When the call ended
    exception: Optional[str]         # Exception message if failed
    attributes: Dict[str, Any]       # Custom attributes
    inputs: Dict[str, Any]          # Input parameters
    output: Optional[Any]           # Return value
    summary: Optional[Dict[str, Any]] # Summary metrics
    wb_user_id: Optional[str]       # W&B user ID
    wb_run_id: Optional[str]        # W&B run ID
    deleted_at: Optional[datetime]   # Soft deletion timestamp

필드 설명

핵심 필드

  • id: 이 호출을 고유하게 식별하는 UUID
  • project_id: 이 호출이 속한 W&B 프로젝트 (형식: “entity/project”)
  • op_name: 호출되는 작업의 이름 (참조일 수 있음)
  • display_name: 호출에 대한 선택적 사람이 읽을 수 있는 이름

추적 계층 구조

  • trace_id: 관련 호출을 단일 추적으로 그룹화
  • parent_id: 자식 호출을 부모에 연결하여 트리 구조 형성

타이밍

  • started_at: 실행이 시작된 ISO 8601 타임스탬프
  • ended_at: 실행이 완료된 ISO 8601 타임스탬프
  • deleted_at: 설정된 경우 호출이 소프트 삭제되었음을 나타냄

데이터

  • inputs: 함수에 전달된 입력 매개변수 사전
  • output: 함수의 반환 값 (성공한 경우)
  • exception: 호출이 실패한 경우 오류 메시지
  • attributes: 사용자 정의 메타데이터 (실행 중 읽기 전용)
  • summary: 실행 후 메트릭 및 계산된 값

통합

  • wb_user_id: 호출을 시작한 W&B 사용자에 연결
  • wb_run_id: 실험 추적을 위한 W&B 실행에 연결

CallsFilter

호출 쿼리를 위한 필터 기준.
class CallsFilter:
    op_names: Optional[List[str]]      # Filter by operation names
    input_refs: Optional[List[str]]    # Filter by input references
    output_refs: Optional[List[str]]   # Filter by output references
    parent_ids: Optional[List[str]]    # Filter by parent call IDs
    trace_ids: Optional[List[str]]     # Filter by trace IDs
    call_ids: Optional[List[str]]      # Filter by specific call IDs
    trace_roots_only: Optional[bool]   # Only return root calls
    wb_user_ids: Optional[List[str]]   # Filter by W&B user IDs
    wb_run_ids: Optional[List[str]]    # Filter by W&B run IDs

사용 예시

from weave import WeaveClient

client = WeaveClient("my-entity/my-project")

# Find all calls to a specific operation
filter = CallsFilter(
    op_names=["process_document"],
    trace_roots_only=True
)

calls = client.get_calls(filter=filter)

쿼리 표현식

쿼리 표현식을 사용한 고급 필터링:
# Find calls with specific input values
calls = client.get_calls(
    filter=CallsFilter(),
    query={
        "$expr": {
            "$and": [
                {"$eq": [{"$getField": "inputs.model"}, "gpt-4"]},
                {"$gt": [{"$getField": "summary.total_tokens"}, 1000]}
            ]
        }
    }
)

계산된 필드

다음 필드는 서버에서 계산됩니다:

상태

다음의 존재 여부에서 파생됨 exceptionended_at:
  • "running": 호출이 시작되었지만 종료되지 않음
  • "success": 예외 없이 호출 종료됨
  • "error": 예외와 함께 호출 종료됨

지속 시간

다음 사이의 차이로 계산됨 ended_atstarted_at (초 단위).

비용

비용 추적 호출에서 집계됨. 다음을 포함:
  • 토큰 사용량
  • API 비용
  • 커스텀 비용 메트릭
추적 서버 인터페이스는 유연하고 확장 가능하도록 설계되었습니다. 스키마 변경 없이 다음에 사용자 정의 필드를 추가할 수 있습니다 attributessummary.