Class: Bugsage::CursorClient
- Inherits:
-
Object
- Object
- Bugsage::CursorClient
- Defined in:
- lib/bugsage/cursor_client.rb
Constant Summary collapse
- TERMINAL_STATUSES =
%w[FINISHED ERROR CANCELLED EXPIRED].freeze
Instance Method Summary collapse
- #chat(system_prompt:, messages:) ⇒ Object
- #complete(system_prompt:, user_prompt:) ⇒ Object
-
#initialize(config: Bugsage.configuration) ⇒ CursorClient
constructor
A new instance of CursorClient.
Constructor Details
#initialize(config: Bugsage.configuration) ⇒ CursorClient
Returns a new instance of CursorClient.
11 12 13 |
# File 'lib/bugsage/cursor_client.rb', line 11 def initialize(config: Bugsage.configuration) @config = config end |
Instance Method Details
#chat(system_prompt:, messages:) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/bugsage/cursor_client.rb', line 24 def chat(system_prompt:, messages:) prompt = .map { |entry| "#{entry[:role].to_s.capitalize}: #{entry[:content]}" }.join("\n\n") agent_id = nil agent_id, run_id = create_agent(system_prompt, prompt, json_only: false) result = poll_run(agent_id, run_id) extract_text_content(result) ensure delete_agent(agent_id) if agent_id end |
#complete(system_prompt:, user_prompt:) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/bugsage/cursor_client.rb', line 15 def complete(system_prompt:, user_prompt:) agent_id = nil agent_id, run_id = create_agent(system_prompt, user_prompt, json_only: true) result = poll_run(agent_id, run_id) extract_json_content(result) ensure delete_agent(agent_id) if agent_id end |