Class: LanggraphPlatform::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/langgraph_platform/base_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ BaseClient

Returns a new instance of BaseClient.



3
4
5
6
# File 'lib/langgraph_platform/base_client.rb', line 3

def initialize(configuration)
  @configuration = configuration
  @http_client = build_http_client
end

Instance Method Details

#delete(path) ⇒ Object



24
25
26
# File 'lib/langgraph_platform/base_client.rb', line 24

def delete(path)
  request(:delete, path)
end

#get(path, params = {}) ⇒ Object



8
9
10
# File 'lib/langgraph_platform/base_client.rb', line 8

def get(path, params = {})
  request(:get, path, params: params)
end

#patch(path, body = {}) ⇒ Object



16
17
18
# File 'lib/langgraph_platform/base_client.rb', line 16

def patch(path, body = {})
  request(:patch, path, body: body)
end

#post(path, body = {}) ⇒ Object



12
13
14
# File 'lib/langgraph_platform/base_client.rb', line 12

def post(path, body = {})
  request(:post, path, body: body)
end

#put(path, body = {}) ⇒ Object



20
21
22
# File 'lib/langgraph_platform/base_client.rb', line 20

def put(path, body = {})
  request(:put, path, body: body)
end

#stream(path, body = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/langgraph_platform/base_client.rb', line 28

def stream(path, body = {}, &block)
  response = @http_client.headers(
    'Accept' => 'text/event-stream',
    'Cache-Control' => 'no-cache'
  ).timeout(@configuration.timeout).post("#{@configuration.base_url}#{path}", json: body)

  if block_given?
    stream_events(response, &block)
  else
    response
  end
rescue HTTP::Error => e
  raise Errors::APIError, "Stream request failed: #{e.message}"
end