Class: RubyCanUseLLM::Providers::OpenAI
- Inherits:
-
Base
- Object
- Base
- RubyCanUseLLM::Providers::OpenAI
show all
- Defined in:
- lib/rubycanusellm/providers/openai.rb
Constant Summary
collapse
- API_URL =
"https://api.openai.com/v1/chat/completions"
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#chat(messages, **options, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/rubycanusellm/providers/openai.rb', line 12
def chat(messages, **options, &block)
if options[:stream] && block
body = build_body(messages, options.except(:stream)).merge(stream: true)
stream_request(body, &block)
else
body = build_body(messages, options)
response = request(body)
parse_response(response)
end
end
|
#embed(text, **options) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/rubycanusellm/providers/openai.rb', line 23
def embed(text, **options)
body = {
model: options[:model] || "text-embedding-3-small",
input: text
}
response = embedding_request(body)
parse_embedding(response)
end
|