Class: Legion::LLM::Pipeline::Request
- Inherits:
-
Data
- Object
- Data
- Legion::LLM::Pipeline::Request
- Defined in:
- lib/legion/llm/pipeline/request.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#billing ⇒ Object
readonly
Returns the value of attribute billing.
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#caller ⇒ Object
readonly
Returns the value of attribute caller.
-
#classification ⇒ Object
readonly
Returns the value of attribute classification.
-
#context_strategy ⇒ Object
readonly
Returns the value of attribute context_strategy.
-
#conversation_id ⇒ Object
readonly
Returns the value of attribute conversation_id.
-
#enrichments ⇒ Object
readonly
Returns the value of attribute enrichments.
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#fork ⇒ Object
readonly
Returns the value of attribute fork.
-
#generation ⇒ Object
readonly
Returns the value of attribute generation.
-
#hooks ⇒ Object
readonly
Returns the value of attribute hooks.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#idempotency_key ⇒ Object
readonly
Returns the value of attribute idempotency_key.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#modality ⇒ Object
readonly
Returns the value of attribute modality.
-
#predictions ⇒ Object
readonly
Returns the value of attribute predictions.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#response_format ⇒ Object
readonly
Returns the value of attribute response_format.
-
#routing ⇒ Object
readonly
Returns the value of attribute routing.
-
#schema_version ⇒ Object
readonly
Returns the value of attribute schema_version.
-
#stop ⇒ Object
readonly
Returns the value of attribute stop.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
-
#test ⇒ Object
readonly
Returns the value of attribute test.
-
#thinking ⇒ Object
readonly
Returns the value of attribute thinking.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
-
#tool_choice ⇒ Object
readonly
Returns the value of attribute tool_choice.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
-
#tracing ⇒ Object
readonly
Returns the value of attribute tracing.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Class Method Summary collapse
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def agent @agent end |
#billing ⇒ Object (readonly)
Returns the value of attribute billing
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def billing @billing end |
#cache ⇒ Object (readonly)
Returns the value of attribute cache
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def cache @cache end |
#caller ⇒ Object (readonly)
Returns the value of attribute caller
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def caller @caller end |
#classification ⇒ Object (readonly)
Returns the value of attribute classification
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def classification @classification end |
#context_strategy ⇒ Object (readonly)
Returns the value of attribute context_strategy
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def context_strategy @context_strategy end |
#conversation_id ⇒ Object (readonly)
Returns the value of attribute conversation_id
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def conversation_id @conversation_id end |
#enrichments ⇒ Object (readonly)
Returns the value of attribute enrichments
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def enrichments @enrichments end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def extra @extra end |
#fork ⇒ Object (readonly)
Returns the value of attribute fork
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def fork @fork end |
#generation ⇒ Object (readonly)
Returns the value of attribute generation
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def generation @generation end |
#hooks ⇒ Object (readonly)
Returns the value of attribute hooks
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def hooks @hooks end |
#id ⇒ Object (readonly)
Returns the value of attribute id
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def id @id end |
#idempotency_key ⇒ Object (readonly)
Returns the value of attribute idempotency_key
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def idempotency_key @idempotency_key end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def @messages end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def @metadata end |
#modality ⇒ Object (readonly)
Returns the value of attribute modality
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def modality @modality end |
#predictions ⇒ Object (readonly)
Returns the value of attribute predictions
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def predictions @predictions end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def priority @priority end |
#response_format ⇒ Object (readonly)
Returns the value of attribute response_format
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def response_format @response_format end |
#routing ⇒ Object (readonly)
Returns the value of attribute routing
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def routing @routing end |
#schema_version ⇒ Object (readonly)
Returns the value of attribute schema_version
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def schema_version @schema_version end |
#stop ⇒ Object (readonly)
Returns the value of attribute stop
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def stop @stop end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def stream @stream end |
#system ⇒ Object (readonly)
Returns the value of attribute system
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def system @system end |
#test ⇒ Object (readonly)
Returns the value of attribute test
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def test @test end |
#thinking ⇒ Object (readonly)
Returns the value of attribute thinking
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def thinking @thinking end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def tokens @tokens end |
#tool_choice ⇒ Object (readonly)
Returns the value of attribute tool_choice
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def tool_choice @tool_choice end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def tools @tools end |
#tracing ⇒ Object (readonly)
Returns the value of attribute tracing
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def tracing @tracing end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl
6 7 8 |
# File 'lib/legion/llm/pipeline/request.rb', line 6 def ttl @ttl end |
Class Method Details
.build(**kwargs) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/legion/llm/pipeline/request.rb', line 16 def self.build(**kwargs) new( id: kwargs[:id] || "req_#{SecureRandom.hex(12)}", conversation_id: kwargs[:conversation_id], idempotency_key: kwargs[:idempotency_key], schema_version: kwargs.fetch(:schema_version, '1.0.0'), system: kwargs[:system], messages: kwargs.fetch(:messages, []), tools: kwargs.key?(:tools) ? kwargs[:tools] : nil, tool_choice: kwargs.fetch(:tool_choice, { mode: :auto }), routing: kwargs.fetch(:routing, { provider: nil, model: nil }), tokens: kwargs.fetch(:tokens, { max: 4096 }), stop: kwargs.fetch(:stop, { sequences: [] }), generation: kwargs.fetch(:generation, {}), thinking: kwargs[:thinking], response_format: kwargs.fetch(:response_format, { type: :text }), stream: kwargs.fetch(:stream, false), fork: kwargs[:fork], context_strategy: kwargs.fetch(:context_strategy, :auto), cache: kwargs.fetch(:cache, { strategy: :default, cacheable: true }), priority: kwargs.fetch(:priority, :normal), ttl: kwargs[:ttl], extra: kwargs.fetch(:extra, {}), metadata: kwargs.fetch(:metadata, {}), enrichments: kwargs.fetch(:enrichments, {}), predictions: kwargs.fetch(:predictions, {}), tracing: kwargs[:tracing], classification: kwargs[:classification], caller: kwargs[:caller], agent: kwargs[:agent], billing: kwargs[:billing], test: kwargs[:test], modality: kwargs[:modality], hooks: kwargs[:hooks] ) end |
.from_chat_args(**kwargs) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/legion/llm/pipeline/request.rb', line 53 def self.from_chat_args(**kwargs) request_id = kwargs[:request_id] || kwargs[:id] = [] if kwargs[:messages] = kwargs[:messages] elsif kwargs[:message] msg = kwargs[:message] = msg.is_a?(Array) ? msg : [{ role: :user, content: msg }] end routing = { provider: kwargs[:provider], model: kwargs[:model] } extra = kwargs.except( :message, :messages, :model, :provider, :system, :tools, :tool_choice, :stream, :caller, :classification, :billing, :agent, :test, :tracing, :priority, :conversation_id, :request_id, :id, :generation, :thinking, :response_format, :context_strategy, :cache, :fork, :tokens, :stop, :modality, :hooks, :idempotency_key, :ttl, :metadata, :enrichments, :predictions ) build_args = { messages: , system: kwargs[:system], routing: routing, tools: kwargs.key?(:tools) ? kwargs[:tools] : nil, tool_choice: kwargs[:tool_choice] || { mode: :auto }, stream: kwargs.fetch(:stream, false), generation: kwargs[:generation] || {}, thinking: kwargs[:thinking], response_format: kwargs[:response_format] || { type: :text }, context_strategy: kwargs.fetch(:context_strategy, :auto), cache: kwargs[:cache] || { strategy: :default, cacheable: true }, fork: kwargs[:fork], tokens: kwargs[:tokens] || { max: 4096 }, stop: kwargs[:stop] || { sequences: [] }, modality: kwargs[:modality], hooks: kwargs[:hooks], caller: kwargs[:caller], classification: kwargs[:classification], billing: kwargs[:billing], agent: kwargs[:agent], test: kwargs[:test], tracing: kwargs[:tracing], priority: kwargs.fetch(:priority, :normal), conversation_id: kwargs[:conversation_id], idempotency_key: kwargs[:idempotency_key], ttl: kwargs[:ttl], metadata: kwargs[:metadata] || {}, enrichments: kwargs[:enrichments] || {}, predictions: kwargs[:predictions] || {}, extra: extra } build_args[:id] = request_id if request_id build(**build_args) end |