Class: CrewAI::Client
- Inherits:
-
Object
- Object
- CrewAI::Client
- Defined in:
- lib/crewai/client.rb
Instance Method Summary collapse
-
#initialize(access_token: nil, uri_base: nil, configuration: nil) ⇒ Client
constructor
A new instance of Client.
- #inputs ⇒ Object
- #kickoff(inputs:, meta: nil, task_webhook_url: nil, step_webhook_url: nil, crew_webhook_url: nil) ⇒ Object
- #resume(execution_id:, task_id:, human_feedback:, is_approve:, task_webhook_url: nil, step_webhook_url: nil, crew_webhook_url: nil) ⇒ Object
- #status(kickoff_id) ⇒ Object
Constructor Details
#initialize(access_token: nil, uri_base: nil, configuration: nil) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 |
# File 'lib/crewai/client.rb', line 5 def initialize(access_token: nil, uri_base: nil, configuration: nil) @configuration = configuration || CrewAI.configuration.dup @configuration.access_token = access_token if access_token @configuration.uri_base = uri_base if uri_base @http = HTTP.new(configuration: @configuration) end |
Instance Method Details
#inputs ⇒ Object
12 13 14 |
# File 'lib/crewai/client.rb', line 12 def inputs parse(@http.get("/inputs")) end |
#kickoff(inputs:, meta: nil, task_webhook_url: nil, step_webhook_url: nil, crew_webhook_url: nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/crewai/client.rb', line 16 def kickoff(inputs:, meta: nil, task_webhook_url: nil, step_webhook_url: nil, crew_webhook_url: nil) body = { "inputs" => stringify_keys(inputs) } body["meta"] = stringify_keys() if body["taskWebhookUrl"] = task_webhook_url if task_webhook_url body["stepWebhookUrl"] = step_webhook_url if step_webhook_url body["crewWebhookUrl"] = crew_webhook_url if crew_webhook_url parse(@http.post("/kickoff", body)) end |
#resume(execution_id:, task_id:, human_feedback:, is_approve:, task_webhook_url: nil, step_webhook_url: nil, crew_webhook_url: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/crewai/client.rb', line 29 def resume(execution_id:, task_id:, human_feedback:, is_approve:, task_webhook_url: nil, step_webhook_url: nil, crew_webhook_url: nil) body = { "execution_id" => execution_id, "task_id" => task_id, "human_feedback" => human_feedback, "is_approve" => is_approve } body["taskWebhookUrl"] = task_webhook_url if task_webhook_url body["stepWebhookUrl"] = step_webhook_url if step_webhook_url body["crewWebhookUrl"] = crew_webhook_url if crew_webhook_url parse(@http.post("/resume", body)) end |
#status(kickoff_id) ⇒ Object
25 26 27 |
# File 'lib/crewai/client.rb', line 25 def status(kickoff_id) parse(@http.get("/#{kickoff_id}/status")) end |