Class: Kreator::RPCServer
- Inherits:
-
Object
- Object
- Kreator::RPCServer
- Defined in:
- lib/kreator/rpc_server.rb
Defined Under Namespace
Classes: Config
Constant Summary collapse
- RPC_COMMANDS =
{ "prompt" => :handle_prompt, "abort" => :handle_abort_command, "get_state" => :handle_get_state_command, "get_messages" => :handle_get_messages_command, "search_sessions" => :handle_search_sessions_command, "label_session" => :handle_label_session_command, "export_session" => :handle_export_session_command, "cleanup_sessions" => :handle_cleanup_sessions_command, "get_resources" => :handle_get_resources_command, "plugin_list" => :handle_plugin_list_command, "plugin_validate" => :handle_plugin_validate_command, "plugin_install" => :handle_plugin_install_command, "plugin_update" => :handle_plugin_update_command, "plugin_remove" => :handle_plugin_remove_command, "list_branches" => :handle_list_branches_command, "fork_session" => :handle_fork_session_command, "new_session" => :handle_new_session_command, "set_model" => :handle_set_model_command }.freeze
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#provider_builder ⇒ Object
readonly
Returns the value of attribute provider_builder.
-
#provider_name ⇒ Object
readonly
Returns the value of attribute provider_name.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#session_manager ⇒ Object
readonly
Returns the value of attribute session_manager.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ RPCServer
constructor
A new instance of RPCServer.
- #run ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ RPCServer
Returns a new instance of RPCServer.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kreator/rpc_server.rb', line 44 def initialize(config = nil, **) config ||= Config.new(**) @provider_builder = config.provider_builder @provider_name = config.provider_name @model = config.model @tools = config.tools @context = config.context @session_manager = config.session_manager @session = config.session @stdin = config.stdin @stdout = config.stdout @resources = config.resources || Resources.new @compact_threshold = config.compact_threshold @messages = session&. || [] end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def context @context end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def model @model end |
#provider_builder ⇒ Object (readonly)
Returns the value of attribute provider_builder.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def provider_builder @provider_builder end |
#provider_name ⇒ Object (readonly)
Returns the value of attribute provider_name.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def provider_name @provider_name end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def resources @resources end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def session @session end |
#session_manager ⇒ Object (readonly)
Returns the value of attribute session_manager.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def session_manager @session_manager end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
7 8 9 |
# File 'lib/kreator/rpc_server.rb', line 7 def tools @tools end |
Instance Method Details
#run ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/kreator/rpc_server.rb', line 60 def run @stdin.each_line do |line| line = line.strip next if line.empty? handle_line(line) end 0 end |