Class: OpenAI::Client
- Inherits:
-
Object
show all
- Extended by:
- HTTP
- Defined in:
- lib/openai/client.rb
Instance Method Summary
collapse
Methods included from HTTP
delete, get, json_post, multipart_post
Constructor Details
#initialize(access_token: nil, organization_id: nil, uri_base: nil, request_timeout: nil) ⇒ Client
Returns a new instance of Client.
7
8
9
10
11
12
|
# File 'lib/openai/client.rb', line 7
def initialize(access_token: nil, organization_id: nil, uri_base: nil, request_timeout: nil)
OpenAI.configuration.access_token = access_token if access_token
OpenAI.configuration.organization_id = organization_id if organization_id
OpenAI.configuration.uri_base = uri_base if uri_base
OpenAI.configuration.request_timeout = request_timeout if request_timeout
end
|
Instance Method Details
#chat(parameters: {}) ⇒ Object
14
15
16
|
# File 'lib/openai/client.rb', line 14
def chat(parameters: {})
OpenAI::Client.json_post(path: "/chat/completions", parameters: parameters)
end
|
#completions(parameters: {}) ⇒ Object
32
33
34
|
# File 'lib/openai/client.rb', line 32
def completions(parameters: {})
OpenAI::Client.json_post(path: "/completions", parameters: parameters)
end
|
#edits(parameters: {}) ⇒ Object
36
37
38
|
# File 'lib/openai/client.rb', line 36
def edits(parameters: {})
OpenAI::Client.json_post(path: "/edits", parameters: parameters)
end
|
#embeddings(parameters: {}) ⇒ Object
40
41
42
|
# File 'lib/openai/client.rb', line 40
def embeddings(parameters: {})
OpenAI::Client.json_post(path: "/embeddings", parameters: parameters)
end
|
#files ⇒ Object
44
45
46
|
# File 'lib/openai/client.rb', line 44
def files
@files ||= OpenAI::Files.new
end
|
#finetunes ⇒ Object
48
49
50
|
# File 'lib/openai/client.rb', line 48
def finetunes
@finetunes ||= OpenAI::Finetunes.new
end
|
#images ⇒ Object
52
53
54
|
# File 'lib/openai/client.rb', line 52
def images
@images ||= OpenAI::Images.new
end
|
#models ⇒ Object
56
57
58
|
# File 'lib/openai/client.rb', line 56
def models
@models ||= OpenAI::Models.new
end
|
#moderations(parameters: {}) ⇒ Object
60
61
62
|
# File 'lib/openai/client.rb', line 60
def moderations(parameters: {})
OpenAI::Client.json_post(path: "/moderations", parameters: parameters)
end
|
#suggested_reply(model: nil, incoming_mail: "", reply_summary: "", situation: nil, other_request: nil, assistant: nil) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/openai/client.rb', line 18
def suggested_reply(model: nil, incoming_mail: "", reply_summary: "", situation: nil, other_request: nil, assistant: nil)
response = if !assistant.nil?
self.chat(parameters: assistant.parameters)
else
return if incoming_mail.empty? || reply_summary.empty?
self.chat(
OpenAI::Assistant::Replyer.new(model: model, incoming_mail: incoming_mail, reply_summary: reply_summary, situation: situation, other_request: other_request)
)
end
response
end
|
#transcribe(parameters: {}) ⇒ Object
64
65
66
|
# File 'lib/openai/client.rb', line 64
def transcribe(parameters: {})
OpenAI::Client.multipart_post(path: "/audio/transcriptions", parameters: parameters)
end
|
#translate(parameters: {}) ⇒ Object
68
69
70
|
# File 'lib/openai/client.rb', line 68
def translate(parameters: {})
OpenAI::Client.multipart_post(path: "/audio/translations", parameters: parameters)
end
|