Class: LanggraphPlatform::Resources::Assistants

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/langgraph_platform/resources/assistants.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

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

Instance Method Details

#create(**params) ⇒ Object



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

def create(**params)
  params[:config] ||= {}
  params[:metadata] ||= {}
  body = compact_params(params)
  response = @client.post('/assistants', body)
  Models::Assistant.new(response)
end

#delete(assistant_id) ⇒ Object

rubocop:disable Naming/PredicateMethod



23
24
25
26
# File 'lib/langgraph_platform/resources/assistants.rb', line 23

def delete(assistant_id) # rubocop:disable Naming/PredicateMethod
  @client.delete("/assistants/#{assistant_id}")
  true
end

#find(assistant_id) ⇒ Object



12
13
14
15
# File 'lib/langgraph_platform/resources/assistants.rb', line 12

def find(assistant_id)
  response = @client.get("/assistants/#{assistant_id}")
  Models::Assistant.new(response)
end

#graph(assistant_id, **params) ⇒ Object



37
38
39
40
41
# File 'lib/langgraph_platform/resources/assistants.rb', line 37

def graph(assistant_id, **params)
  params[:xray] ||= false
  query_params = compact_params(params)
  @client.get("/assistants/#{assistant_id}/graph", query_params)
end

#schemas(assistant_id) ⇒ Object



49
50
51
# File 'lib/langgraph_platform/resources/assistants.rb', line 49

def schemas(assistant_id)
  @client.get("/assistants/#{assistant_id}/schemas")
end

#search(**params) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/langgraph_platform/resources/assistants.rb', line 28

def search(**params)
  params[:metadata] ||= {}
  params[:limit] ||= 10
  params[:offset] ||= 0
  body = compact_params(params)
  response = @client.post('/assistants/search', body)
  response.map { |assistant_data| Models::Assistant.new(assistant_data) }
end

#set_latest_version(assistant_id, **params) ⇒ Object



58
59
60
61
62
# File 'lib/langgraph_platform/resources/assistants.rb', line 58

def set_latest_version(assistant_id, **params)
  body = compact_params(params)
  response = @client.post("/assistants/#{assistant_id}/latest", body)
  Models::Assistant.new(response)
end

#subgraphs(assistant_id, **params) ⇒ Object



43
44
45
46
47
# File 'lib/langgraph_platform/resources/assistants.rb', line 43

def subgraphs(assistant_id, **params)
  params[:recurse] ||= false
  query_params = compact_params(params)
  @client.get("/assistants/#{assistant_id}/subgraphs", query_params)
end

#update(assistant_id, **params) ⇒ Object



17
18
19
20
21
# File 'lib/langgraph_platform/resources/assistants.rb', line 17

def update(assistant_id, **params)
  body = compact_params(params)
  response = @client.patch("/assistants/#{assistant_id}", body)
  Models::Assistant.new(response)
end

#versions(assistant_id) ⇒ Object



53
54
55
56
# File 'lib/langgraph_platform/resources/assistants.rb', line 53

def versions(assistant_id)
  response = @client.post("/assistants/#{assistant_id}/versions")
  response.map { |assistant_data| Models::Assistant.new(assistant_data) }
end