Class: Langfuse::TextPromptClient
- Inherits:
-
Object
- Object
- Langfuse::TextPromptClient
- Defined in:
- lib/langfuse/text_prompt_client.rb
Overview
Text prompt client for compiling text prompts with variable substitution
Handles text-based prompts from Langfuse, providing Mustache templating for variable substitution.
Instance Attribute Summary collapse
-
#commit_message ⇒ String?
readonly
Optional commit message for this prompt version.
-
#config ⇒ Hash
readonly
Prompt configuration.
-
#is_fallback ⇒ Boolean
readonly
Whether this client uses caller-provided fallback content.
-
#labels ⇒ Array<String>
readonly
Labels assigned to this prompt.
-
#name ⇒ String
readonly
Prompt name.
-
#prompt ⇒ String
readonly
Raw prompt template string.
-
#resolution_graph ⇒ Hash?
readonly
Optional dependency resolution graph for composed prompts.
-
#tags ⇒ Array<String>
readonly
Tags assigned to this prompt.
-
#version ⇒ Integer
readonly
Prompt version number.
Instance Method Summary collapse
-
#compile(**kwargs) ⇒ String
Compile the prompt with variable substitution.
-
#initialize(prompt_data, is_fallback: false) ⇒ TextPromptClient
constructor
Initialize a new text prompt client.
-
#type ⇒ String
Prompt type (“text”).
Constructor Details
#initialize(prompt_data, is_fallback: false) ⇒ TextPromptClient
Initialize a new text prompt client
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/langfuse/text_prompt_client.rb', line 55 def initialize(prompt_data, is_fallback: false) validate_prompt_data!(prompt_data) @name = prompt_data["name"] @version = prompt_data["version"] @prompt = prompt_data["prompt"] @labels = prompt_data["labels"] || [] @tags = prompt_data["tags"] || [] @config = prompt_data["config"] || {} @commit_message = prompt_data["commitMessage"] @resolution_graph = prompt_data["resolutionGraph"] @is_fallback = is_fallback end |
Instance Attribute Details
#commit_message ⇒ String? (readonly)
Returns Optional commit message for this prompt version.
42 43 44 |
# File 'lib/langfuse/text_prompt_client.rb', line 42 def @commit_message end |
#config ⇒ Hash (readonly)
Returns Prompt configuration.
36 37 38 |
# File 'lib/langfuse/text_prompt_client.rb', line 36 def config @config end |
#is_fallback ⇒ Boolean (readonly)
Returns Whether this client uses caller-provided fallback content.
48 49 50 |
# File 'lib/langfuse/text_prompt_client.rb', line 48 def is_fallback @is_fallback end |
#labels ⇒ Array<String> (readonly)
Returns Labels assigned to this prompt.
30 31 32 |
# File 'lib/langfuse/text_prompt_client.rb', line 30 def labels @labels end |
#name ⇒ String (readonly)
Returns Prompt name.
24 25 26 |
# File 'lib/langfuse/text_prompt_client.rb', line 24 def name @name end |
#prompt ⇒ String (readonly)
Returns Raw prompt template string.
39 40 41 |
# File 'lib/langfuse/text_prompt_client.rb', line 39 def prompt @prompt end |
#resolution_graph ⇒ Hash? (readonly)
Returns Optional dependency resolution graph for composed prompts.
45 46 47 |
# File 'lib/langfuse/text_prompt_client.rb', line 45 def resolution_graph @resolution_graph end |
#tags ⇒ Array<String> (readonly)
Returns Tags assigned to this prompt.
33 34 35 |
# File 'lib/langfuse/text_prompt_client.rb', line 33 def @tags end |
#version ⇒ Integer (readonly)
Returns Prompt version number.
27 28 29 |
# File 'lib/langfuse/text_prompt_client.rb', line 27 def version @version end |
Instance Method Details
#compile(**kwargs) ⇒ String
Compile the prompt with variable substitution
82 83 84 85 86 |
# File 'lib/langfuse/text_prompt_client.rb', line 82 def compile(**kwargs) return prompt if kwargs.empty? PromptRenderer.render(prompt, kwargs) end |
#type ⇒ String
Returns Prompt type (“text”).
70 71 72 |
# File 'lib/langfuse/text_prompt_client.rb', line 70 def type "text" end |