Class: PullRequestAi::Client
- Inherits:
-
Object
- Object
- PullRequestAi::Client
- Defined in:
- lib/pull_request_ai/client.rb
Instance Method Summary collapse
- #ai_client ⇒ Object
- #ai_interpreter ⇒ Object
- #current_opened_pull_requests(base) ⇒ Object
- #destination_branches ⇒ Object
- #flatten_current_changes(to_branch) ⇒ Object
-
#initialize(openai_api_key: nil, openai_api_endpoint: nil, github_api_endpoint: nil, github_access_token: nil, bitbucket_api_endpoint: nil, bitbucket_app_password: nil, bitbucket_username: nil, api_version: nil, model: nil, temperature: nil) ⇒ Client
constructor
A new instance of Client.
- #open_pull_request(to_base, title, description) ⇒ Object
- #repo_client ⇒ Object
- #repo_reader ⇒ Object
- #suggested_description(type, summary, changes) ⇒ Object
- #update_pull_request(number, base, title, description) ⇒ Object
Constructor Details
#initialize(openai_api_key: nil, openai_api_endpoint: nil, github_api_endpoint: nil, github_access_token: nil, bitbucket_api_endpoint: nil, bitbucket_app_password: nil, bitbucket_username: nil, api_version: nil, model: nil, temperature: nil) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pull_request_ai/client.rb', line 5 def initialize( openai_api_key: nil, openai_api_endpoint: nil, github_api_endpoint: nil, github_access_token: nil, bitbucket_api_endpoint: nil, bitbucket_app_password: nil, bitbucket_username: nil, api_version: nil, model: nil, temperature: nil ) PullRequestAi.configuration.openai_api_key = openai_api_key if openai_api_key PullRequestAi.configuration.openai_api_endpoint = openai_api_endpoint if openai_api_endpoint PullRequestAi.configuration.github_api_endpoint = github_api_endpoint if github_api_endpoint PullRequestAi.configuration.github_access_token = github_access_token if github_access_token PullRequestAi.configuration.bitbucket_api_endpoint = bitbucket_api_endpoint if bitbucket_api_endpoint PullRequestAi.configuration.bitbucket_app_password = bitbucket_app_password if bitbucket_app_password PullRequestAi.configuration.bitbucket_username = bitbucket_username if bitbucket_username PullRequestAi.configuration.api_version = api_version if api_version PullRequestAi.configuration.model = model if model PullRequestAi.configuration.temperature = temperature if temperature end |
Instance Method Details
#ai_client ⇒ Object
37 38 39 |
# File 'lib/pull_request_ai/client.rb', line 37 def ai_client @ai_client ||= PullRequestAi::OpenAi::Client.new end |
#ai_interpreter ⇒ Object
41 42 43 |
# File 'lib/pull_request_ai/client.rb', line 41 def ai_interpreter @ai_interpreter ||= PullRequestAi::OpenAi::Interpreter.new end |
#current_opened_pull_requests(base) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/pull_request_ai/client.rb', line 45 def current_opened_pull_requests(base) repo_reader.repository_slug.bind do |slug| repo_reader.current_branch.bind do |branch| repo_client.opened_pull_requests(slug, branch, base) end end end |
#destination_branches ⇒ Object
53 54 55 |
# File 'lib/pull_request_ai/client.rb', line 53 def destination_branches repo_reader.destination_branches end |
#flatten_current_changes(to_branch) ⇒ Object
71 72 73 |
# File 'lib/pull_request_ai/client.rb', line 71 def flatten_current_changes(to_branch) repo_reader.flatten_current_changes(to_branch) end |
#open_pull_request(to_base, title, description) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/pull_request_ai/client.rb', line 57 def open_pull_request(to_base, title, description) repo_reader.repository_slug.bind do |slug| repo_reader.current_branch.bind do |branch| repo_client.open_pull_request(slug, branch, to_base, title, description) end end end |
#repo_client ⇒ Object
33 34 35 |
# File 'lib/pull_request_ai/client.rb', line 33 def repo_client @repo_client ||= PullRequestAi::Repo::Client.client_from_host(repo_reader.repository_host) end |
#repo_reader ⇒ Object
29 30 31 |
# File 'lib/pull_request_ai/client.rb', line 29 def repo_reader @repo_reader ||= PullRequestAi::Repo::Reader.new end |
#suggested_description(type, summary, changes) ⇒ Object
75 76 77 78 |
# File 'lib/pull_request_ai/client.rb', line 75 def suggested_description(type, summary, changes) = ai_interpreter.(type, summary, changes) ai_client.predicted_completions() end |
#update_pull_request(number, base, title, description) ⇒ Object
65 66 67 68 69 |
# File 'lib/pull_request_ai/client.rb', line 65 def update_pull_request(number, base, title, description) repo_reader.repository_slug.bind do |slug| repo_client.update_pull_request(slug, number, base, title, description) end end |