Module: Raix::FunctionDispatch
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/raix/function_dispatch.rb
Overview
Provides declarative function definition for ChatCompletion classes.
Example:
class MeaningOfLife
include Raix::ChatCompletion
include Raix::FunctionDispatch
function :ask_deep_thought do
wait 236_682_000_000_000
"The meaning of life is 42"
end
def initialize
transcript << { user: "What is the meaning of life?" }
chat_completion
end
end
Instance Method Summary collapse
- #chat_completion(**chat_completion_args) ⇒ Object
-
#stop_looping! ⇒ Object
Stops the looping of chat completion after function calls.
- #tools ⇒ Object
Instance Method Details
#chat_completion(**chat_completion_args) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/raix/function_dispatch.rb', line 92 def chat_completion(**chat_completion_args) raise "No functions defined" if self.class.functions.blank? self.chat_completion_args = chat_completion_args super end |
#stop_looping! ⇒ Object
Stops the looping of chat completion after function calls. Useful for manually halting processing in workflow components that do not require a final text response to an end user.
103 104 105 |
# File 'lib/raix/function_dispatch.rb', line 103 def stop_looping! self.loop = false end |
#tools ⇒ Object
107 108 109 |
# File 'lib/raix/function_dispatch.rb', line 107 def tools self.class.functions.map { |function| { type: "function", function: } } end |