Class: AlephAlpha::Client

Inherits:
Object
  • Object
show all
Extended by:
HTTP
Defined in:
lib/aleph-alpha/client.rb

Instance Method Summary collapse

Methods included from HTTP

delete, get, json_patch, json_post

Constructor Details

#initialize(access_token: nil, uri_base: nil, request_timeout: nil) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
# File 'lib/aleph-alpha/client.rb', line 5

def initialize(access_token: nil, uri_base: nil, request_timeout: nil)
  AlephAlpha.configuration.access_token = access_token if access_token
  AlephAlpha.configuration.uri_base = uri_base if uri_base
  AlephAlpha.configuration.request_timeout = request_timeout if request_timeout
end

Instance Method Details

#completions(parameters: {}, nice: false) ⇒ Object



27
28
29
# File 'lib/aleph-alpha/client.rb', line 27

def completions(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/complete?nice=#{nice}", parameters: parameters)
end

#detokenize(parameters: {}) ⇒ Object



51
52
53
# File 'lib/aleph-alpha/client.rb', line 51

def detokenize(parameters: {})
  AlephAlpha::Client.json_post(path: "/detokenize", parameters: parameters)
end

#embeddings(parameters: {}, nice: false) ⇒ Object



31
32
33
# File 'lib/aleph-alpha/client.rb', line 31

def embeddings(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/embed?nice=#{nice}", parameters: parameters)
end

#evaluate(parameters: {}, nice: false) ⇒ Object



39
40
41
# File 'lib/aleph-alpha/client.rb', line 39

def evaluate(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/evaluate?nice=#{nice}", parameters: parameters)
end

#explain(parameters: {}, nice: false) ⇒ Object



43
44
45
# File 'lib/aleph-alpha/client.rb', line 43

def explain(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/explain?nice=#{nice}", parameters: parameters)
end

#modelsObject



19
20
21
# File 'lib/aleph-alpha/client.rb', line 19

def models
  @models ||= AlephAlpha::Models.new
end

#permissions(parameters: []) ⇒ Object



63
64
65
# File 'lib/aleph-alpha/client.rb', line 63

def permissions(parameters: [])
  AlephAlpha::Client.json_post(path: "/check_privileges", parameters: parameters)
end

#qa(parameters: {}, nice: false) ⇒ Object



55
56
57
# File 'lib/aleph-alpha/client.rb', line 55

def qa(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/qa?nice=#{nice}", parameters: parameters)
end

#semantic_embeddings(parameters: {}, nice: false) ⇒ Object



35
36
37
# File 'lib/aleph-alpha/client.rb', line 35

def semantic_embeddings(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/semantic_embed?nice=#{nice}", parameters: parameters)
end

#summarize(parameters: {}, nice: false) ⇒ Object



59
60
61
# File 'lib/aleph-alpha/client.rb', line 59

def summarize(parameters: {}, nice: false)
  AlephAlpha::Client.json_post(path: "/summarize?nice=#{nice}", parameters: parameters)
end

#tokenize(parameters: {}) ⇒ Object



47
48
49
# File 'lib/aleph-alpha/client.rb', line 47

def tokenize(parameters: {})
  AlephAlpha::Client.json_post(path: "/tokenize", parameters: parameters)
end

#tokensObject



15
16
17
# File 'lib/aleph-alpha/client.rb', line 15

def tokens
  @tokens ||= AlephAlpha::Tokens.new
end

#usersObject



23
24
25
# File 'lib/aleph-alpha/client.rb', line 23

def users
  @users ||= AlephAlpha::Users.new
end

#versionObject



11
12
13
# File 'lib/aleph-alpha/client.rb', line 11

def version
  AlephAlpha::Client.get(path: "/version")
end