Sha256: 00c42e32eac408584c84dd0fca5b9db2bb562ed5b09507cf6d4e8e2578bc5af9
Contents?: true
Size: 766 Bytes
Versions: 4
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true module GenAI class Result attr_reader :raw, :provider, :model, :values def initialize(provider:, model:, raw:, values:) @raw = raw @provider = provider @model = model @values = values end def value values.first end def prompt_tokens usage['prompt_tokens'] end def completion_tokens if usage['completion_tokens'] || (total_tokens && prompt_tokens) total_tokens.to_i - prompt_tokens.to_i end end def total_tokens usage['total_tokens'] end private def usage raw['usage'] || { 'prompt_tokens' => nil, 'completion_tokens' => nil, 'total_tokens' => nil } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gen-ai-0.2.3 | lib/gen_ai/result.rb |
gen-ai-0.2.2 | lib/gen_ai/result.rb |
gen-ai-0.2.1 | lib/gen_ai/result.rb |
gen-ai-0.2.0 | lib/gen_ai/result.rb |