Class: Langfuse::PromptFetchResult

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

Overview

Public metadata returned by prompt fetch operations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prompt:, logical_key:, storage_key:, cache_status:, source:, name:, version: nil, label: nil) ⇒ PromptFetchResult

rubocop:disable Metrics/ParameterLists

Parameters:

  • prompt (Object)

    Prompt data or prompt client

  • logical_key (String)

    Stable logical cache identity

  • storage_key (String)

    Generated backend key

  • cache_status (Symbol)

    Cache status

  • source (Symbol)

    Prompt source

  • name (String)

    Prompt name

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

    Prompt version

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

    Prompt label



40
41
42
43
44
45
46
47
48
49
# File 'lib/langfuse/prompt_fetch_result.rb', line 40

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

Instance Attribute Details

#cache_statusSymbol (readonly)

Returns Cache status (:hit, :miss, :stale, :refresh, :bypass, :disabled).

Returns:

  • (Symbol)

    Cache status (:hit, :miss, :stale, :refresh, :bypass, :disabled)



16
17
18
# File 'lib/langfuse/prompt_fetch_result.rb', line 16

def cache_status
  @cache_status
end

#labelString? (readonly)

Returns Prompt label.

Returns:

  • (String, nil)

    Prompt label



28
29
30
# File 'lib/langfuse/prompt_fetch_result.rb', line 28

def label
  @label
end

#logical_keyString (readonly)

Returns Stable logical cache identity.

Returns:

  • (String)

    Stable logical cache identity



10
11
12
# File 'lib/langfuse/prompt_fetch_result.rb', line 10

def logical_key
  @logical_key
end

#nameString (readonly)

Returns Prompt name.

Returns:

  • (String)

    Prompt name



22
23
24
# File 'lib/langfuse/prompt_fetch_result.rb', line 22

def name
  @name
end

#promptObject (readonly)

Returns Prompt data or prompt client returned by the fetch.

Returns:

  • (Object)

    Prompt data or prompt client returned by the fetch



7
8
9
# File 'lib/langfuse/prompt_fetch_result.rb', line 7

def prompt
  @prompt
end

#sourceSymbol (readonly)

Returns Source of the returned prompt (:cache, :api, :fallback).

Returns:

  • (Symbol)

    Source of the returned prompt (:cache, :api, :fallback)



19
20
21
# File 'lib/langfuse/prompt_fetch_result.rb', line 19

def source
  @source
end

#storage_keyString (readonly)

Returns Generated backend key for the current cache generation.

Returns:

  • (String)

    Generated backend key for the current cache generation



13
14
15
# File 'lib/langfuse/prompt_fetch_result.rb', line 13

def storage_key
  @storage_key
end

#versionInteger? (readonly)

Returns Prompt version.

Returns:

  • (Integer, nil)

    Prompt version



25
26
27
# File 'lib/langfuse/prompt_fetch_result.rb', line 25

def version
  @version
end

Instance Method Details

#fallback?Boolean

Returns Whether this result used caller-provided fallback content.

Returns:

  • (Boolean)

    Whether this result used caller-provided fallback content



53
54
55
# File 'lib/langfuse/prompt_fetch_result.rb', line 53

def fallback?
  source == CacheSource::FALLBACK
end

#to_hHash

Returns Result metadata as a hash.

Returns:

  • (Hash)

    Result metadata as a hash



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/langfuse/prompt_fetch_result.rb', line 58

def to_h
  {
    logical_key: logical_key,
    storage_key: storage_key,
    cache_status: cache_status,
    source: source,
    name: name,
    version: version,
    label: label,
    fallback: fallback?
  }
end