Class: Langfuse::Prompt
- Inherits:
-
Object
- Object
- Langfuse::Prompt
- Defined in:
- lib/langfuse/prompt.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#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.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #compile(variables = {}) ⇒ Object
- #get_langchain_prompt ⇒ Object
-
#initialize(data) ⇒ Prompt
constructor
A new instance of Prompt.
- #to_dict ⇒ Object
Constructor Details
#initialize(data) ⇒ Prompt
Returns a new instance of Prompt.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/langfuse/prompt.rb', line 5 def initialize(data) @data = data.is_a?(Hash) ? Utils.deep_symbolize_keys(data) : data @id = @data[:id] @name = @data[:name] @version = @data[:version] @prompt = @data[:prompt] @config = @data[:config] || {} @labels = @data[:labels] || [] @tags = @data[:tags] || [] @type = @data[:type] @created_at = @data[:created_at] @updated_at = @data[:updated_at] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def config @config end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def id @id end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def labels @labels end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def name @name end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def prompt @prompt end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def type @type end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def updated_at @updated_at end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/langfuse/prompt.rb', line 3 def version @version end |
Instance Method Details
#compile(variables = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/langfuse/prompt.rb', line 32 def compile(variables = {}) # Compile prompt with variables case @type when 'text' compile_text_prompt(variables) when 'chat' compile_chat_prompt(variables) else raise ValidationError, "Unsupported prompt type: #{@type}" end end |
#get_langchain_prompt ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/langfuse/prompt.rb', line 20 def get_langchain_prompt # Convert Langfuse prompt format to LangChain format case @type when 'text' text_to_langchain_prompt when 'chat' chat_to_langchain_prompt else raise ValidationError, "Unsupported prompt type: #{@type}" end end |
#to_dict ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/langfuse/prompt.rb', line 44 def to_dict { id: @id, name: @name, version: @version, prompt: @prompt, config: @config, labels: @labels, tags: @tags, type: @type, created_at: @created_at, updated_at: @updated_at } end |