Commit e68ef4c
Changed files (1)
lib
net
llm
lib/net/llm/openai.rb
@@ -13,29 +13,23 @@ module Net
end
def chat(messages, tools)
- response = http.post(
+ handle_response(http.post(
"#{base_url}/chat/completions",
headers: headers,
body: { model: model, messages: messages, tools: tools, tool_choice: "auto" }
- )
- handle_response(response)
+ ))
end
def models
- response = http.get(
- "#{base_url}/models",
- headers: headers
- )
- handle_response(response)
+ handle_response(http.get("#{base_url}/models", headers: headers))
end
def embeddings(input, model: "text-embedding-ada-002")
- response = http.post(
+ handle_response(http.post(
"#{base_url}/embeddings",
headers: headers,
- body: { model: model, input: input }
- )
- handle_response(response)
+ body: { model: model, input: input },
+ ))
end
private