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
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#compile(**kwargs) ⇒ String
Compile the prompt with variable substitution.
-
#initialize(prompt_data) ⇒ TextPromptClient
constructor
Initialize a new text prompt client.
Constructor Details
#initialize(prompt_data) ⇒ TextPromptClient
Initialize a new text prompt client
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/langfuse/text_prompt_client.rb', line 29 def initialize(prompt_data) 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"] || {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
23 24 25 |
# File 'lib/langfuse/text_prompt_client.rb', line 23 def config @config end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
23 24 25 |
# File 'lib/langfuse/text_prompt_client.rb', line 23 def labels @labels end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/langfuse/text_prompt_client.rb', line 23 def name @name end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
23 24 25 |
# File 'lib/langfuse/text_prompt_client.rb', line 23 def prompt @prompt end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
23 24 25 |
# File 'lib/langfuse/text_prompt_client.rb', line 23 def @tags end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
23 24 25 |
# File 'lib/langfuse/text_prompt_client.rb', line 23 def version @version end |
Instance Method Details
#compile(**kwargs) ⇒ String
Compile the prompt with variable substitution
48 49 50 51 52 |
# File 'lib/langfuse/text_prompt_client.rb', line 48 def compile(**kwargs) return prompt if kwargs.empty? Mustache.render(prompt, kwargs) end |