Class: Raix::CompletionContext
- Inherits:
-
Object
- Object
- Raix::CompletionContext
- Defined in:
- lib/raix/completion_context.rb
Overview
Context object passed to before_completion hooks. Provides access to the chat completion instance, messages, and request parameters. Messages can be mutated for content filtering, PII redaction, etc.
Instance Attribute Summary collapse
-
#chat_completion ⇒ Object
readonly
Returns the value of attribute chat_completion.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#chat_completion_class ⇒ Object
Get the class that includes ChatCompletion.
-
#configuration ⇒ Object
Get the current configuration.
-
#current_model ⇒ Object
Get the currently configured model.
-
#initialize(chat_completion:, messages:, params:) ⇒ CompletionContext
constructor
A new instance of CompletionContext.
-
#transcript ⇒ Object
Convenience accessor for the transcript.
Constructor Details
#initialize(chat_completion:, messages:, params:) ⇒ CompletionContext
Returns a new instance of CompletionContext.
10 11 12 13 14 |
# File 'lib/raix/completion_context.rb', line 10 def initialize(chat_completion:, messages:, params:) @chat_completion = chat_completion @messages = # mutable - hooks can modify for filtering, redaction, etc. @params = params # mutable - hooks can modify parameters end |
Instance Attribute Details
#chat_completion ⇒ Object (readonly)
Returns the value of attribute chat_completion.
8 9 10 |
# File 'lib/raix/completion_context.rb', line 8 def chat_completion @chat_completion end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
8 9 10 |
# File 'lib/raix/completion_context.rb', line 8 def @messages end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/raix/completion_context.rb', line 8 def params @params end |
Instance Method Details
#chat_completion_class ⇒ Object
Get the class that includes ChatCompletion
27 28 29 |
# File 'lib/raix/completion_context.rb', line 27 def chat_completion_class chat_completion.class end |
#configuration ⇒ Object
Get the current configuration
32 33 34 |
# File 'lib/raix/completion_context.rb', line 32 def configuration chat_completion.configuration end |
#current_model ⇒ Object
Get the currently configured model
22 23 24 |
# File 'lib/raix/completion_context.rb', line 22 def current_model chat_completion.model || chat_completion.configuration.model end |
#transcript ⇒ Object
Convenience accessor for the transcript
17 18 19 |
# File 'lib/raix/completion_context.rb', line 17 def transcript chat_completion.transcript end |