Class: MockServer::LLM::StreamingPhysics
- Inherits:
-
Object
- Object
- MockServer::LLM::StreamingPhysics
- Defined in:
- lib/mockserver/llm.rb
Overview
StreamingPhysics
timeToFirstToken serialises as a Delay: { timeUnit, value }
Instance Method Summary collapse
-
#initialize ⇒ StreamingPhysics
constructor
A new instance of StreamingPhysics.
- #to_h ⇒ Hash
- #with_jitter(jitter) ⇒ self
- #with_seed(seed) ⇒ self
-
#with_time_to_first_token(value, time_unit = 'MILLISECONDS') ⇒ self
Accepts a Delay-shaped Hash (+{ ‘timeUnit’ => .., ‘value’ => .. }+) or a (value, time_unit) pair.
- #with_tokens_per_second(tokens_per_second) ⇒ self
Constructor Details
#initialize ⇒ StreamingPhysics
Returns a new instance of StreamingPhysics.
160 161 162 163 164 165 |
# File 'lib/mockserver/llm.rb', line 160 def initialize @time_to_first_token = nil @tokens_per_second = nil @jitter = nil @seed = nil end |
Instance Method Details
#to_h ⇒ Hash
208 209 210 211 212 213 214 215 |
# File 'lib/mockserver/llm.rb', line 208 def to_h LLM.omit_nil( 'timeToFirstToken' => @time_to_first_token, 'tokensPerSecond' => @tokens_per_second, 'jitter' => @jitter, 'seed' => @seed ) end |
#with_jitter(jitter) ⇒ self
192 193 194 195 196 197 198 199 |
# File 'lib/mockserver/llm.rb', line 192 def with_jitter(jitter) if !jitter.nil? && (jitter < 0.0 || jitter > 1.0) raise ArgumentError, 'jitter must be between 0.0 and 1.0' end @jitter = jitter self end |
#with_seed(seed) ⇒ self
202 203 204 205 |
# File 'lib/mockserver/llm.rb', line 202 def with_seed(seed) @seed = seed self end |
#with_time_to_first_token(value, time_unit = 'MILLISECONDS') ⇒ self
Accepts a Delay-shaped Hash (+{ ‘timeUnit’ => .., ‘value’ => .. }+) or a (value, time_unit) pair.
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/mockserver/llm.rb', line 170 def with_time_to_first_token(value, time_unit = 'MILLISECONDS') @time_to_first_token = if value.is_a?(Hash) { 'timeUnit' => value['timeUnit'] || value[:timeUnit], 'value' => value['value'] || value[:value] } else { 'timeUnit' => time_unit, 'value' => value } end self end |
#with_tokens_per_second(tokens_per_second) ⇒ self
182 183 184 185 186 187 188 189 |
# File 'lib/mockserver/llm.rb', line 182 def with_tokens_per_second(tokens_per_second) if !tokens_per_second.nil? && (tokens_per_second < 1 || tokens_per_second > 10_000) raise ArgumentError, 'tokensPerSecond must be between 1 and 10000' end @tokens_per_second = tokens_per_second self end |