Class: AnswerLayer::SemanticResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/answerlayer/resources/semantic.rb

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from AnswerLayer::Resource

Instance Method Details

#cancel_job(job_id:) ⇒ Object



53
54
55
# File 'lib/answerlayer/resources/semantic.rb', line 53

def cancel_job(job_id:)
  to_api_response(request(method: :post, path: "/semantic/jobs/#{job_id}/cancel"))
end

#components(component:, connection_id:) ⇒ Object



5
6
7
# File 'lib/answerlayer/resources/semantic.rb', line 5

def components(component:, connection_id:)
  to_api_response(request(method: :get, path: "/semantic/#{component}", params: { connection_id: connection_id }))
end

#create_component(component:, attributes:) ⇒ Object



13
14
15
# File 'lib/answerlayer/resources/semantic.rb', line 13

def create_component(component:, attributes:)
  to_api_response(request(method: :post, path: "/semantic/#{component}", body: attributes))
end

#create_job(connection_id:, component_type:, prompt: nil) ⇒ Object



33
34
35
# File 'lib/answerlayer/resources/semantic.rb', line 33

def create_job(connection_id:, component_type:, prompt: nil)
  to_api_response(request(method: :post, path: "/semantic/jobs", body: compact(connection_id: connection_id, component_type: component_type, prompt: prompt)))
end

#delete_component(component:, id:) ⇒ Object



25
26
27
# File 'lib/answerlayer/resources/semantic.rb', line 25

def delete_component(component:, id:)
  request(method: :delete, path: "/semantic/#{component}/#{id}")
end

#generate_stream(component:, connection_id:, prompt: nil) ⇒ Object



29
30
31
# File 'lib/answerlayer/resources/semantic.rb', line 29

def generate_stream(component:, connection_id:, prompt: nil)
  request(method: :post, path: "/semantic/#{component}/generate/stream", body: compact(connection_id: connection_id, prompt: prompt))
end

#get_component(component:, id:) ⇒ Object



17
18
19
# File 'lib/answerlayer/resources/semantic.rb', line 17

def get_component(component:, id:)
  to_api_response(request(method: :get, path: "/semantic/#{component}/#{id}"))
end

#job_questions(job_id:) ⇒ Object



41
42
43
# File 'lib/answerlayer/resources/semantic.rb', line 41

def job_questions(job_id:)
  to_api_response(request(method: :get, path: "/semantic/jobs/#{job_id}/questions"))
end

#job_status(job_id:) ⇒ Object



49
50
51
# File 'lib/answerlayer/resources/semantic.rb', line 49

def job_status(job_id:)
  to_api_response(request(method: :get, path: "/semantic/jobs/#{job_id}/status"))
end

#job_stream(job_id:) ⇒ Object



37
38
39
# File 'lib/answerlayer/resources/semantic.rb', line 37

def job_stream(job_id:)
  request(method: :get, path: "/semantic/jobs/#{job_id}/stream")
end

#jobsObject



9
10
11
# File 'lib/answerlayer/resources/semantic.rb', line 9

def jobs
  to_api_response(request(method: :get, path: "/semantic/jobs"))
end

#submit_guidance(job_id:, responses:) ⇒ Object



45
46
47
# File 'lib/answerlayer/resources/semantic.rb', line 45

def submit_guidance(job_id:, responses:)
  to_api_response(request(method: :post, path: "/semantic/jobs/#{job_id}/guidance", body: { responses: responses }))
end

#update_component(component:, id:, attributes:) ⇒ Object



21
22
23
# File 'lib/answerlayer/resources/semantic.rb', line 21

def update_component(component:, id:, attributes:)
  to_api_response(request(method: :put, path: "/semantic/#{component}/#{id}", body: attributes))
end