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 ⇒ Hash
readonly
Prompt configuration.
-
#labels ⇒ Array<String>
readonly
Labels assigned to this prompt.
-
#name ⇒ String
readonly
Prompt name.
-
#prompt ⇒ String
readonly
Raw prompt template string.
-
#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) ⇒ TextPromptClient
constructor
Initialize a new text prompt client.
Constructor Details
#initialize(prompt_data) ⇒ TextPromptClient
Initialize a new text prompt client
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/langfuse/text_prompt_client.rb', line 45 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 ⇒ Hash (readonly)
Returns Prompt configuration.
36 37 38 |
# File 'lib/langfuse/text_prompt_client.rb', line 36 def config @config 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 |
#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
64 65 66 67 68 |
# File 'lib/langfuse/text_prompt_client.rb', line 64 def compile(**kwargs) return prompt if kwargs.empty? Mustache.render(prompt, kwargs) end |