Class: Langfuse::PromptCacheKey

Inherits:
Object
  • Object
show all
Defined in:
lib/langfuse/prompt_fetch_result.rb

Overview

Public key inspection result for prompt cache operations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, logical_key:, storage_key:, version: nil, label: nil) ⇒ PromptCacheKey

Parameters:

  • name (String)

    Prompt name

  • logical_key (String)

    Stable logical cache identity

  • storage_key (String)

    Generated backend key

  • version (Integer, nil) (defaults to: nil)

    Prompt version

  • label (String, nil) (defaults to: nil)

    Prompt label



95
96
97
98
99
100
101
# File 'lib/langfuse/prompt_fetch_result.rb', line 95

def initialize(name:, logical_key:, storage_key:, version: nil, label: nil)
  @name = name
  @version = version
  @label = label
  @logical_key = logical_key
  @storage_key = storage_key
end

Instance Attribute Details

#labelString? (readonly)

Returns Prompt label.

Returns:

  • (String, nil)

    Prompt label



81
82
83
# File 'lib/langfuse/prompt_fetch_result.rb', line 81

def label
  @label
end

#logical_keyString (readonly)

Returns Stable logical cache identity.

Returns:

  • (String)

    Stable logical cache identity



84
85
86
# File 'lib/langfuse/prompt_fetch_result.rb', line 84

def logical_key
  @logical_key
end

#nameString (readonly)

Returns Prompt name.

Returns:

  • (String)

    Prompt name



75
76
77
# File 'lib/langfuse/prompt_fetch_result.rb', line 75

def name
  @name
end

#storage_keyString (readonly)

Returns Generated backend key for the current cache generation.

Returns:

  • (String)

    Generated backend key for the current cache generation



87
88
89
# File 'lib/langfuse/prompt_fetch_result.rb', line 87

def storage_key
  @storage_key
end

#versionInteger? (readonly)

Returns Prompt version.

Returns:

  • (Integer, nil)

    Prompt version



78
79
80
# File 'lib/langfuse/prompt_fetch_result.rb', line 78

def version
  @version
end

Instance Method Details

#resolved_labelString?

Resolve the effective label, defaulting to “production” when neither an explicit label nor a version was specified.

Returns:

  • (String, nil)

    Effective label



107
108
109
# File 'lib/langfuse/prompt_fetch_result.rb', line 107

def resolved_label
  label || (version ? nil : "production")
end

#to_hHash

Returns Cache key data as a hash.

Returns:

  • (Hash)

    Cache key data as a hash



112
113
114
115
116
117
118
119
120
# File 'lib/langfuse/prompt_fetch_result.rb', line 112

def to_h
  {
    name: name,
    version: version,
    label: label,
    logical_key: logical_key,
    storage_key: storage_key
  }
end