Class: Langfuse::ChatPromptClient
- Inherits:
-
Object
- Object
- Langfuse::ChatPromptClient
- Defined in:
- lib/langfuse/chat_prompt_client.rb
Overview
Chat prompt client for compiling chat prompts with variable substitution
Handles chat-based prompts from Langfuse, providing Mustache templating for variable substitution in role-based messages.
Instance Attribute Summary collapse
-
#config ⇒ Hash
readonly
Prompt configuration.
-
#labels ⇒ Array<String>
readonly
Labels assigned to this prompt.
-
#name ⇒ String
readonly
Prompt name.
-
#prompt ⇒ Array<Hash>
readonly
Array of message hashes with role and content.
-
#tags ⇒ Array<String>
readonly
Tags assigned to this prompt.
-
#version ⇒ Integer
readonly
Prompt version number.
Instance Method Summary collapse
-
#compile(**kwargs) ⇒ Array<Hash>
Compile the chat prompt with variable substitution.
-
#initialize(prompt_data) ⇒ ChatPromptClient
constructor
Initialize a new chat prompt client.
Constructor Details
#initialize(prompt_data) ⇒ ChatPromptClient
Initialize a new chat prompt client
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/langfuse/chat_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/chat_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/chat_prompt_client.rb', line 30 def labels @labels end |
#name ⇒ String (readonly)
Returns Prompt name.
24 25 26 |
# File 'lib/langfuse/chat_prompt_client.rb', line 24 def name @name end |
#prompt ⇒ Array<Hash> (readonly)
Returns Array of message hashes with role and content.
39 40 41 |
# File 'lib/langfuse/chat_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/chat_prompt_client.rb', line 33 def @tags end |
#version ⇒ Integer (readonly)
Returns Prompt version number.
27 28 29 |
# File 'lib/langfuse/chat_prompt_client.rb', line 27 def version @version end |
Instance Method Details
#compile(**kwargs) ⇒ Array<Hash>
Compile the chat prompt with variable substitution
Returns an array of message hashes with roles and compiled content. Each message in the prompt will have its content compiled with the provided variables using Mustache templating.
71 72 73 74 75 |
# File 'lib/langfuse/chat_prompt_client.rb', line 71 def compile(**kwargs) prompt.map do || (, kwargs) end end |