Class: DebugAgent::DebugEngine
- Inherits:
-
Object
- Object
- DebugAgent::DebugEngine
- Defined in:
- lib/debug_agent/engine.rb
Instance Attribute Summary collapse
-
#system_prompt ⇒ Object
readonly
Returns the value of attribute system_prompt.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
- #chat(message, session_id = 'default', callback = nil) ⇒ Object
- #clear_session(session_id = 'default') ⇒ Object
-
#initialize(config = nil) ⇒ DebugEngine
constructor
A new instance of DebugEngine.
Constructor Details
#initialize(config = nil) ⇒ DebugEngine
Returns a new instance of DebugEngine.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/debug_agent/engine.rb', line 35 def initialize(config = nil) @config = config || Config.from_env @llm = LLMClient.new(@config.llm) @tools = REGISTRY @prompt_builder = SystemPromptBuilder.new(@tools) @system_prompt = @prompt_builder.build @context_compressor = ContextCompressor.new( @llm, @config.llm.model, @config.llm.temperature, @config.llm.context_window_tokens ) @sessions = {} @mutex = Mutex.new end |
Instance Attribute Details
#system_prompt ⇒ Object (readonly)
Returns the value of attribute system_prompt.
33 34 35 |
# File 'lib/debug_agent/engine.rb', line 33 def system_prompt @system_prompt end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
33 34 35 |
# File 'lib/debug_agent/engine.rb', line 33 def tools @tools end |
Instance Method Details
#chat(message, session_id = 'default', callback = nil) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/debug_agent/engine.rb', line 51 def chat(, session_id = 'default', callback = nil) callback ||= ChatCallback.new session = get_or_create_session(session_id) session.({ 'role' => 'user', 'content' => }) run_tool_loop(session, callback) end |
#clear_session(session_id = 'default') ⇒ Object
60 61 62 63 64 65 |
# File 'lib/debug_agent/engine.rb', line 60 def clear_session(session_id = 'default') @mutex.synchronize do session = @sessions[session_id] session&.clear end end |