Class: LanggraphPlatform::Resources::Runs

Inherits:
BaseResource show all
Defined in:
lib/langgraph_platform/resources/runs.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from LanggraphPlatform::Resources::BaseResource

Instance Method Details

#cancel(thread_id, run_id, **params) ⇒ Object



34
35
36
37
38
39
# File 'lib/langgraph_platform/resources/runs.rb', line 34

def cancel(thread_id, run_id, **params)
  params[:wait] ||= false
  params[:action] ||= 'interrupt'
  body = compact_params(params)
  @client.post("/threads/#{thread_id}/runs/#{run_id}/cancel", body)
end

#cancel_multiple(**params) ⇒ Object



77
78
79
80
81
# File 'lib/langgraph_platform/resources/runs.rb', line 77

def cancel_multiple(**params)
  params[:action] ||= 'interrupt'
  body = compact_params(params)
  @client.post('/runs/cancel', body)
end

#create(thread_id, **params) ⇒ Object



4
5
6
7
8
# File 'lib/langgraph_platform/resources/runs.rb', line 4

def create(thread_id, **params)
  body = compact_params(params)
  response = @client.post("/threads/#{thread_id}/runs", body)
  Models::Run.new(response)
end

#create_batch(runs) ⇒ Object



73
74
75
# File 'lib/langgraph_platform/resources/runs.rb', line 73

def create_batch(runs)
  @client.post('/runs/batch', runs)
end

#create_stateless(**params) ⇒ Object

Stateless runs



57
58
59
60
# File 'lib/langgraph_platform/resources/runs.rb', line 57

def create_stateless(**params)
  body = compact_params(params)
  @client.post('/runs', body)
end

#delete(thread_id, run_id) ⇒ Object

rubocop:disable Naming/PredicateMethod



51
52
53
54
# File 'lib/langgraph_platform/resources/runs.rb', line 51

def delete(thread_id, run_id) # rubocop:disable Naming/PredicateMethod
  @client.delete("/threads/#{thread_id}/runs/#{run_id}")
  true
end

#find(thread_id, run_id) ⇒ Object



21
22
23
24
# File 'lib/langgraph_platform/resources/runs.rb', line 21

def find(thread_id, run_id)
  response = @client.get("/threads/#{thread_id}/runs/#{run_id}")
  Models::Run.new(response)
end

#join(thread_id, run_id, **params) ⇒ Object



41
42
43
44
45
# File 'lib/langgraph_platform/resources/runs.rb', line 41

def join(thread_id, run_id, **params)
  params[:cancel_on_disconnect] ||= false
  query_params = compact_params(params)
  @client.get("/threads/#{thread_id}/runs/#{run_id}/join", query_params)
end

#join_stream(thread_id, run_id, &block) ⇒ Object



47
48
49
# File 'lib/langgraph_platform/resources/runs.rb', line 47

def join_stream(thread_id, run_id, &block)
  @client.stream("/threads/#{thread_id}/runs/#{run_id}/stream", &block)
end

#list(thread_id, **params) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/langgraph_platform/resources/runs.rb', line 26

def list(thread_id, **params)
  params[:limit] ||= 10
  params[:offset] ||= 0
  query_params = compact_params(params)
  response = @client.get("/threads/#{thread_id}/runs", query_params)
  response.map { |run_data| Models::Run.new(run_data) }
end

#stream(thread_id, **params, &block) ⇒ Object



10
11
12
13
14
# File 'lib/langgraph_platform/resources/runs.rb', line 10

def stream(thread_id, **params, &block)
  params[:stream_mode] = Array(params[:stream_mode] || ['values'])
  body = compact_params(params)
  @client.stream("/threads/#{thread_id}/runs/stream", body, &block)
end

#stream_stateless(**params, &block) ⇒ Object



62
63
64
65
66
# File 'lib/langgraph_platform/resources/runs.rb', line 62

def stream_stateless(**params, &block)
  params[:stream_mode] = Array(params[:stream_mode] || ['values'])
  body = compact_params(params)
  @client.stream('/runs/stream', body, &block)
end

#wait(thread_id, **params) ⇒ Object



16
17
18
19
# File 'lib/langgraph_platform/resources/runs.rb', line 16

def wait(thread_id, **params)
  body = compact_params(params)
  @client.post("/threads/#{thread_id}/runs/wait", body)
end

#wait_stateless(**params) ⇒ Object



68
69
70
71
# File 'lib/langgraph_platform/resources/runs.rb', line 68

def wait_stateless(**params)
  body = compact_params(params)
  @client.post('/runs/wait', body)
end