Class: Githuh::LLM::OpenAI
Constant Summary collapse
- ENDPOINT =
URI('https://api.openai.com/v1/chat/completions').freeze
- MODEL =
'gpt-4o-mini'- MAX_TOKENS =
800- BAR_COLOR =
:green
Constants inherited from Base
Base::PROMPT, Base::README_CHAR_LIMIT, Base::REQUEST_TIMEOUT
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Githuh::LLM::Base
Instance Method Details
#summarize(readme) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/githuh/llm/openai.rb', line 13 def summarize(readme) headers = { 'Authorization' => "Bearer #{api_key}" } body = { model: MODEL, max_tokens: MAX_TOKENS, messages: [{ role: 'user', content: prompt_for(readme) }] } payload = parse!(post_json(ENDPOINT, headers, body)) payload.dig('choices', 0, 'message', 'content').to_s.strip end |