diff --git a/CHANGELOG.md b/CHANGELOG.md index 8abd79b..90e3136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,3 +15,7 @@ ## [0.2.4] - 2024-12-12 - [Hotfix] prompts could not compile with variables having nested hashes with keys as symbols. + +## [0.2.5] - 2024-12-16 + +- Added metadata field to traces. diff --git a/Gemfile.lock b/Gemfile.lock index 3e8d51c..372ad1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - llm_eval_ruby (0.2.4) + llm_eval_ruby (0.2.5) httparty (~> 0.22.0) liquid (~> 5.5.0) diff --git a/lib/llm_eval_ruby/api_clients/langfuse.rb b/lib/llm_eval_ruby/api_clients/langfuse.rb index 570caf7..d0a2b8a 100644 --- a/lib/llm_eval_ruby/api_clients/langfuse.rb +++ b/lib/llm_eval_ruby/api_clients/langfuse.rb @@ -29,7 +29,8 @@ def create_trace(params = {}) name: params[:name], input: params[:input], sessionId: params[:session_id], - userId: params[:user_id] + userId: params[:user_id], + metadata: params[:metadata] || {} } create_event(type: "trace-create", body:) end @@ -39,7 +40,8 @@ def create_span(params = {}) id: params[:id], name: params[:name], input: params[:input], - traceId: params[:trace_id] + traceId: params[:trace_id], + metadata: params[:metadata] || {} } create_event(type: "span-create", body:) end @@ -48,7 +50,8 @@ def update_span(params = {}) body = { id: params[:id], output: params[:output], - endTime: params[:end_time] + endTime: params[:end_time], + metadata: params[:metadata] || {} } create_event(type: "span-update", body:) end @@ -75,7 +78,8 @@ def update_generation(params = {}) id: params[:id], output: params[:output], endTime: params[:end_time], - usage: convert_keys_to_camel_case(params[:usage]) + usage: convert_keys_to_camel_case(params[:usage]), + metadata: params[:metadata] || {} } create_event(type: "generation-update", body:) end @@ -86,7 +90,7 @@ def create_event(type:, body:) { id: SecureRandom.uuid, type:, - body:, + body: body.deep_stringify_keys, timestamp: Time.now.utc.iso8601, metadata: {} } diff --git a/lib/llm_eval_ruby/trace_adapters/langfuse.rb b/lib/llm_eval_ruby/trace_adapters/langfuse.rb index 0c1a719..ec45070 100644 --- a/lib/llm_eval_ruby/trace_adapters/langfuse.rb +++ b/lib/llm_eval_ruby/trace_adapters/langfuse.rb @@ -25,7 +25,7 @@ def span(**kwargs) return span unless block_given? - result = yield + result = yield span end_span(span, result) diff --git a/lib/llm_eval_ruby/trace_types.rb b/lib/llm_eval_ruby/trace_types.rb index c93cfb6..2c96a2c 100644 --- a/lib/llm_eval_ruby/trace_types.rb +++ b/lib/llm_eval_ruby/trace_types.rb @@ -2,9 +2,9 @@ module LlmEvalRuby module TraceTypes - Trace = Struct.new(:id, :name, :input, :output, :session_id, :user_id, keyword_init: true) + Trace = Struct.new(:id, :name, :input, :output, :session_id, :user_id, :metadata, keyword_init: true) - Span = Struct.new(:id, :name, :trace_id, :input, :output, :end_time, keyword_init: true) + Span = Struct.new(:id, :name, :trace_id, :input, :output, :end_time, :metadata, keyword_init: true) Generation = Struct.new(:tracer, :id, @@ -16,6 +16,7 @@ module TraceTypes :prompt_name, :prompt_version, :usage, + :metadata, keyword_init: true) do def end(output:, usage: nil) self.output = output diff --git a/lib/llm_eval_ruby/version.rb b/lib/llm_eval_ruby/version.rb index 612eb18..9268ebd 100644 --- a/lib/llm_eval_ruby/version.rb +++ b/lib/llm_eval_ruby/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module LlmEvalRuby - VERSION = "0.2.4" + VERSION = "0.2.5" end diff --git a/spec/llm_eval_ruby_spec.rb b/spec/llm_eval_ruby_spec.rb index 75601f6..be0b2f0 100644 --- a/spec/llm_eval_ruby_spec.rb +++ b/spec/llm_eval_ruby_spec.rb @@ -2,6 +2,6 @@ RSpec.describe LlmEvalRuby do it "has a version number" do - expect(LlmEvalRuby::VERSION).to be("0.2.4") + expect(LlmEvalRuby::VERSION).to be("0.2.5") end end