senior 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +35 -3
- data/README.md +40 -8
- data/lib/senior/brains/open_ai.rb +57 -10
- data/lib/senior/configuration/main.rb +37 -0
- data/lib/senior/configuration/open_ai.rb +146 -0
- data/lib/senior/errors.rb +9 -0
- data/lib/senior/version.rb +1 -1
- data/lib/senior.rb +30 -0
- data/sig/senior/brains/open_ai.rbs +7 -1
- data/sig/senior/configuration/main.rbs +7 -0
- data/sig/senior/configuration/open_ai.rbs +26 -0
- data/sig/senior/errors.rbs +7 -0
- data/sig/senior.rbs +3 -4
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d973cd43135daeb4de71d71a43f52500fe6ab39f6ba507b032833eb65402977
|
4
|
+
data.tar.gz: 4bf83499dae649941e881453fd376603faad6399fa49970b1375a843af0a987f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6394a7b1b08fd32299b43febd26143128befb958f1af203106ce05c8e809ec07a3cdd7eec1cc16b0e1ddc369b2f94873b1e9addb91a9b8385231990dcd929f
|
7
|
+
data.tar.gz: 6655e71e4676e35cae26aedd96bce779202a33982d028a68f8cdb1ef257ae1fcae1b86755b8c11c70d6c70cfd7dff900da2fc74d4d9d6ba4e456209c84740228
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
- Ability to wrap a method invocation. For example, `Senior.suggest_fix { my_broken_method(2) }`
|
4
4
|
- Test generation `Senior.write_tests_for {}`
|
5
|
-
- Configure API keys for the OpenAI
|
6
|
-
- Use different OpenAI models
|
7
|
-
- Parametrize the calls to OpenAI
|
8
5
|
- See price per call
|
9
6
|
- Set API calling and pricing limits
|
10
7
|
- Use different AI APIs, not just OpenAI
|
@@ -13,6 +10,41 @@
|
|
13
10
|
- RBS Signatures
|
14
11
|
- Domain exceptions
|
15
12
|
|
13
|
+
## [0.3.0] - 2023-04-11
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Added support for OpenAI's Chat Completion API. Setting `Senior.configuration.open_ai.model`
|
17
|
+
to any value of `Senior::Brains::OpenAI::CHAT_MODELS` will cause API requests to be sent to `/chat/completions`.
|
18
|
+
Whereas setting `Senior.configuration.open_ai.model` to any value of `Senior::Brains::OpenAI::COMPLETION_MODELS`
|
19
|
+
will cause API requests to be sent to `/completions`.
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
- Updated the gem's summary and description to match the idea of the gem - A senior software engineer assistant.
|
23
|
+
- Updated the `bin/setup` script to copy the `.env.example` file to `.env`
|
24
|
+
|
25
|
+
## [0.2.0] - 2023-04-10
|
26
|
+
|
27
|
+
### Added
|
28
|
+
- Added the ability to configure the gem with a block:
|
29
|
+
```ruby
|
30
|
+
Senior.configure do |config|
|
31
|
+
config.open_ai.access_token = ENV.fetch('OPEN_AI_ACCESS_TOKEN')
|
32
|
+
config.open_ai.organization_id = ENV.fetch('OPEN_AI_ORGANIZATION_ID') # Optional
|
33
|
+
config.open_ai.api_version = 'v1'
|
34
|
+
config.open_ai.max_tokens = 1024
|
35
|
+
config.open_ai.model = 'text-davinci-003'
|
36
|
+
config.open_ai.n = 1
|
37
|
+
config.open_ai.request_timeout = 120
|
38
|
+
config.open_ai.temperature = 0.7
|
39
|
+
config.open_ai.uri_base = 'https://api.openai.com/'
|
40
|
+
end
|
41
|
+
```
|
42
|
+
These configurations are used as default values for the OpenAI API calls.
|
43
|
+
|
16
44
|
## [0.1.0] - 2023-04-10
|
17
45
|
|
18
46
|
- Initial release
|
47
|
+
|
48
|
+
[0.3.0]: https://github.com/wilsonsilva/senior/compare/v0.2.0...v0.3.0
|
49
|
+
[0.2.0]: https://github.com/wilsonsilva/senior/compare/v0.1.0...v0.2.0
|
50
|
+
[0.1.0]: https://github.com/wilsonsilva/senior/compare/eecec20...v0.1.0
|
data/README.md
CHANGED
@@ -2,9 +2,24 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/senior.svg)](https://badge.fury.io/rb/senior)
|
4
4
|
[![Tests](https://github.com/wilsonsilva/senior/actions/workflows/main.yml/badge.svg)](https://github.com/wilsonsilva/senior/actions/workflows/main.yml)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/87e6e2167d3283e3b79b/test_coverage)](https://codeclimate.com/github/wilsonsilva/senior/test_coverage)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/87e6e2167d3283e3b79b/maintainability)](https://codeclimate.com/github/wilsonsilva/senior/maintainability)
|
5
7
|
|
6
|
-
|
7
|
-
and
|
8
|
+
An AI-powered pair programmer. Provides a user-friendly interface for using AI API's to automatically repair broken code
|
9
|
+
and suggest improvements. Simply provide the faulty code as input, and the gem will generate a corrected version using
|
10
|
+
advanced machine learning techniques.
|
11
|
+
|
12
|
+
## Table of Contents
|
13
|
+
|
14
|
+
- [Installation](#installation)
|
15
|
+
- [Usage](#usage)
|
16
|
+
- [Auto-debugging a broken method](#auto-debugging-a-broken-method)
|
17
|
+
- [Suggesting a fix for a broken method](#suggesting-a-fix-for-a-broken-method)
|
18
|
+
- [Development](#development)
|
19
|
+
- [Type checking](#type-checking)
|
20
|
+
- [Contributing](#contributing)
|
21
|
+
- [License](#license)
|
22
|
+
- [Code of Conduct](#code-of-conduct)
|
8
23
|
|
9
24
|
## Installation
|
10
25
|
|
@@ -18,13 +33,27 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
18
33
|
|
19
34
|
## Usage
|
20
35
|
|
21
|
-
|
22
|
-
|
36
|
+
- Get your API key from https://platform.openai.com/account/api-keys
|
37
|
+
- (optional) If you belong to multiple organizations, you can get your Organization ID from https://platform.openai.com/account/org-settings
|
38
|
+
- Configure the library by passing your OpenAI API credentials:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Senior.configure do |config|
|
42
|
+
config.open_ai.access_token = ENV.fetch('OPEN_AI_ACCESS_TOKEN')
|
43
|
+
config.open_ai.organization_id = ENV.fetch('OPEN_AI_ORGANIZATION_ID') # Optional
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
Note that `OPEN_AI_ACCESS_TOKEN` and `OPEN_AI_ORGANIZATION_ID` are environment variables that should be set in your
|
48
|
+
environment. You should never hardcode your API credentials directly in your code, as this is a security risk.
|
49
|
+
Instead, store your API credentials securely, such as using environment variables or a separate configuration file that
|
50
|
+
is excluded from source control.
|
51
|
+
|
52
|
+
Once you have configured the gem, you can use the `Senior` module to interact with the OpenAI API.
|
23
53
|
|
24
54
|
### Auto-debugging a broken method
|
25
|
-
To debug a broken method, call Senior.auto_debug and pass in the broken method
|
26
|
-
|
27
|
-
longer raises exceptions.
|
55
|
+
To debug a broken method, call `Senior.auto_debug` and pass in the broken method and its arguments. The method will be
|
56
|
+
called repeatedly, with modifications made to its source code each time, until it no longer raises exceptions.
|
28
57
|
|
29
58
|
```ruby
|
30
59
|
def square(n) = n * y
|
@@ -34,7 +63,7 @@ puts result # => 4
|
|
34
63
|
```
|
35
64
|
|
36
65
|
### Suggesting a fix for a broken method
|
37
|
-
To suggest a fix for a broken method, call Senior.suggest_fix and pass in the broken method and its arguments.
|
66
|
+
To suggest a fix for a broken method, call `Senior.suggest_fix` and pass in the broken method and its arguments.
|
38
67
|
The method will be analyzed and a fix will be suggested in the form of modified source code.
|
39
68
|
|
40
69
|
```ruby
|
@@ -48,6 +77,9 @@ puts suggestion # => "def square(n) = n * n"
|
|
48
77
|
|
49
78
|
After checking out the repo, run `bin/setup` to install dependencies.
|
50
79
|
|
80
|
+
Set your OpenAI API credentials in the environment variables `OPEN_AI_ACCESS_TOKEN` and `OPEN_AI_ORGANIZATION_ID`.
|
81
|
+
Either in your machine's environment or in a `.env` file in the root of the project.
|
82
|
+
|
51
83
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
52
84
|
|
53
85
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -10,6 +10,11 @@ module Senior
|
|
10
10
|
# @api private
|
11
11
|
#
|
12
12
|
class OpenAI
|
13
|
+
CHAT_MODELS = %w[gpt-4 gpt-4-0314 gpt-4-32k gpt-4-32k-0314 gpt-3.5-turbo gpt-3.5-turbo-0301].freeze
|
14
|
+
COMPLETION_MODELS = %w[text-davinci-003 text-davinci-002 text-curie-001 text-babbage-001 text-ada-001
|
15
|
+
davinci curie babbage ada].freeze
|
16
|
+
CHAT_SYSTEM_PROMPT = "You're a Ruby dev. Only reply with plain code, no explanations."
|
17
|
+
|
13
18
|
# Suggests a fix for a broken method
|
14
19
|
#
|
15
20
|
# @api private
|
@@ -32,7 +37,13 @@ module Senior
|
|
32
37
|
## Updated source:
|
33
38
|
PROMPT
|
34
39
|
|
35
|
-
|
40
|
+
if CHAT_MODELS.include?(defaults.model)
|
41
|
+
request_chat_completion(prompt)
|
42
|
+
elsif COMPLETION_MODELS.include?(defaults.model)
|
43
|
+
request_completion(prompt)
|
44
|
+
else
|
45
|
+
raise "Unknown model '#{defaults.model}'. If this is a mistake, open a PR in github.com/wilsonsilva/senior"
|
46
|
+
end
|
36
47
|
end
|
37
48
|
|
38
49
|
private
|
@@ -45,8 +56,8 @@ module Senior
|
|
45
56
|
#
|
46
57
|
def open_ai_client
|
47
58
|
@open_ai_client ||= ::OpenAI::Client.new(
|
48
|
-
access_token:
|
49
|
-
organization_id:
|
59
|
+
access_token: Senior.configuration.open_ai.access_token,
|
60
|
+
organization_id: Senior.configuration.open_ai.organization_id
|
50
61
|
)
|
51
62
|
end
|
52
63
|
|
@@ -55,19 +66,18 @@ module Senior
|
|
55
66
|
# @api private
|
56
67
|
#
|
57
68
|
# @param prompt [String] The prompt for which to generate a completion
|
58
|
-
# @param max_tokens [Integer] The maximum number of tokens to generate in the completion. Default value is 1024
|
59
69
|
#
|
60
|
-
# @return [String] The
|
70
|
+
# @return [String] The created completion
|
61
71
|
#
|
62
|
-
def request_completion(prompt
|
72
|
+
def request_completion(prompt)
|
63
73
|
response = open_ai_client.completions(
|
64
74
|
parameters: {
|
65
|
-
model:
|
75
|
+
model: defaults.model,
|
66
76
|
prompt:,
|
67
|
-
max_tokens
|
68
|
-
n:
|
77
|
+
max_tokens: defaults.max_tokens,
|
78
|
+
n: defaults.n,
|
69
79
|
stop: nil,
|
70
|
-
temperature:
|
80
|
+
temperature: defaults.temperature
|
71
81
|
}
|
72
82
|
)
|
73
83
|
|
@@ -75,6 +85,43 @@ module Senior
|
|
75
85
|
|
76
86
|
response.dig('choices', 0, 'text').strip
|
77
87
|
end
|
88
|
+
|
89
|
+
# Creates a chat completion in OpenAI's API
|
90
|
+
#
|
91
|
+
# @api private
|
92
|
+
#
|
93
|
+
# @param prompt [String] The prompt for which to generate a chat completion
|
94
|
+
#
|
95
|
+
# @return [String] The created chat completion
|
96
|
+
#
|
97
|
+
def request_chat_completion(prompt)
|
98
|
+
response = open_ai_client.chat(
|
99
|
+
parameters: {
|
100
|
+
model: defaults.model,
|
101
|
+
max_tokens: defaults.max_tokens,
|
102
|
+
n: defaults.n,
|
103
|
+
temperature: defaults.temperature,
|
104
|
+
messages: [
|
105
|
+
{ role: 'system', content: CHAT_SYSTEM_PROMPT },
|
106
|
+
{ role: 'user', content: prompt }
|
107
|
+
]
|
108
|
+
}
|
109
|
+
)
|
110
|
+
|
111
|
+
raise 'No chat completion found' unless response['choices'].any?
|
112
|
+
|
113
|
+
response.dig('choices', 0, 'message', 'content').strip
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the default configuration object for the OpenAI brain
|
117
|
+
#
|
118
|
+
# @api private
|
119
|
+
#
|
120
|
+
# @return [Senior::Configuration::OpenAI] The default configuration object for the OpenAI brain.
|
121
|
+
#
|
122
|
+
def defaults
|
123
|
+
Senior.configuration.open_ai
|
124
|
+
end
|
78
125
|
end
|
79
126
|
end
|
80
127
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'senior/configuration/open_ai'
|
4
|
+
|
5
|
+
module Senior
|
6
|
+
module Configuration
|
7
|
+
# Index file for all configurations of the gem
|
8
|
+
#
|
9
|
+
# @api public
|
10
|
+
#
|
11
|
+
class Main
|
12
|
+
# The OpenAI configuration
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# configuration = Senior::Configuration::Main.new
|
19
|
+
# configuration.open_ai # => #<Configuration::OpenAI:0x00007fa2a61a63d8>
|
20
|
+
#
|
21
|
+
# @return [Configuration::OpenAI] The OpenAI configuration
|
22
|
+
#
|
23
|
+
attr_accessor :open_ai
|
24
|
+
|
25
|
+
# Initializes a new instance of the configuration for the Senior gem
|
26
|
+
#
|
27
|
+
# @api public
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# configuration = Senior::Configuration::Main.new
|
31
|
+
#
|
32
|
+
def initialize
|
33
|
+
@open_ai = Configuration::OpenAI.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Senior
|
4
|
+
module Configuration
|
5
|
+
# Encapsulates the OpenAI configuration
|
6
|
+
#
|
7
|
+
# @api public
|
8
|
+
class OpenAI
|
9
|
+
# The OpenAI access token
|
10
|
+
#
|
11
|
+
# @return [String, nil] The OpenAI access token, or nil if not set
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# configuration = Senior::Configuration::OpenAI.new
|
15
|
+
# configuration.access_token = 'your_openai_api_key'
|
16
|
+
attr_writer :access_token
|
17
|
+
|
18
|
+
# The OpenAI API version
|
19
|
+
#
|
20
|
+
# @return [String] The OpenAI API version
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# configuration = Senior::Configuration::OpenAI.new
|
24
|
+
# configuration.api_version = 'v1'
|
25
|
+
attr_accessor :api_version
|
26
|
+
|
27
|
+
# The maximum number of tokens to use in the OpenAI API request
|
28
|
+
#
|
29
|
+
# @return [Integer] The maximum number of tokens to use in the OpenAI API request
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# configuration = Senior::Configuration::OpenAI.new
|
33
|
+
# configuration.max_tokens = 1024
|
34
|
+
attr_accessor :max_tokens
|
35
|
+
|
36
|
+
# The OpenAI model to use
|
37
|
+
#
|
38
|
+
# @return [String] The OpenAI model to use
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# configuration = Senior::Configuration::OpenAI.new
|
42
|
+
# configuration.model = 'text-davinci-003'
|
43
|
+
attr_accessor :model
|
44
|
+
|
45
|
+
# The number of responses to generate
|
46
|
+
#
|
47
|
+
# @return [Integer] The number of responses to generate
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# configuration = Senior::Configuration::OpenAI.new
|
51
|
+
# configuration.n = 1
|
52
|
+
attr_accessor :n
|
53
|
+
|
54
|
+
# The OpenAI organization ID
|
55
|
+
#
|
56
|
+
# @return [String, nil] The OpenAI organization ID, or nil if not set
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
# configuration = Senior::Configuration::OpenAI.new
|
60
|
+
# configuration.organization_id = 'your_organization_id'
|
61
|
+
attr_accessor :organization_id
|
62
|
+
|
63
|
+
# The maximum amount of time to wait for an OpenAI API request to complete
|
64
|
+
#
|
65
|
+
# @return [Integer] The maximum amount of time to wait for an OpenAI API request to complete
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# configuration = Senior::Configuration::OpenAI.new
|
69
|
+
# configuration.request_timeout = 120
|
70
|
+
attr_accessor :request_timeout
|
71
|
+
|
72
|
+
# The temperature to use in the OpenAI API request
|
73
|
+
#
|
74
|
+
# @return [Float] The temperature to use in the OpenAI API request
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# configuration = Senior::Configuration::OpenAI.new
|
78
|
+
# configuration.temperature = 0.7
|
79
|
+
attr_accessor :temperature
|
80
|
+
|
81
|
+
# The OpenAI URI base
|
82
|
+
#
|
83
|
+
# @return [String] The OpenAI URI base
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
# configuration = Senior::Configuration::OpenAI.new
|
87
|
+
# configuration.uri_base = 'https://api.openai.com/'
|
88
|
+
attr_accessor :uri_base
|
89
|
+
|
90
|
+
# The default OpenAI API version
|
91
|
+
DEFAULT_API_VERSION = 'v1'
|
92
|
+
|
93
|
+
# The default maximum number of tokens to use in the OpenAI API request
|
94
|
+
DEFAULT_MAX_TOKENS = 1024
|
95
|
+
|
96
|
+
# The default OpenAI model to use
|
97
|
+
DEFAULT_MODEL = 'text-davinci-003'
|
98
|
+
|
99
|
+
# The default number of responses to generate
|
100
|
+
DEFAULT_N = 1
|
101
|
+
|
102
|
+
# The default maximum amount of time to wait for an OpenAI API request to complete
|
103
|
+
DEFAULT_REQUEST_TIMEOUT = 120
|
104
|
+
|
105
|
+
# The default temperature to use in the OpenAI API request
|
106
|
+
DEFAULT_TEMPERATURE = 0.7
|
107
|
+
|
108
|
+
# The default OpenAI URI base
|
109
|
+
DEFAULT_URI_BASE = 'https://api.openai.com/'
|
110
|
+
|
111
|
+
# Initializes a new instance of the OpenAI configuration for the Senior gem
|
112
|
+
#
|
113
|
+
# @example
|
114
|
+
# configuration = Senior::Configuration::OpenAI.new
|
115
|
+
#
|
116
|
+
def initialize
|
117
|
+
@access_token = nil
|
118
|
+
@api_version = DEFAULT_API_VERSION
|
119
|
+
@max_tokens = DEFAULT_MAX_TOKENS
|
120
|
+
@model = DEFAULT_MODEL
|
121
|
+
@n = DEFAULT_N
|
122
|
+
@organization_id = nil
|
123
|
+
@request_timeout = DEFAULT_REQUEST_TIMEOUT
|
124
|
+
@temperature = DEFAULT_TEMPERATURE
|
125
|
+
@uri_base = DEFAULT_URI_BASE
|
126
|
+
end
|
127
|
+
|
128
|
+
# Gets the OpenAI access token, raising an error if it is not set
|
129
|
+
#
|
130
|
+
# @raise [ConfigurationError] If the OpenAI access token is not set
|
131
|
+
#
|
132
|
+
# @return [String] The OpenAI access token.
|
133
|
+
#
|
134
|
+
# @example
|
135
|
+
# configuration = Senior::Configuration::OpenAI.new
|
136
|
+
# configuration.access_token # => raises ConfigurationError if access token is not set
|
137
|
+
#
|
138
|
+
def access_token
|
139
|
+
return @access_token if @access_token
|
140
|
+
|
141
|
+
error_text = 'OpenAI access token missing! See https://github.com/wilsonsilva/senior#usage'
|
142
|
+
raise ConfigurationError, error_text
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
data/lib/senior/version.rb
CHANGED
data/lib/senior.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'senior/errors'
|
4
|
+
require_relative 'senior/configuration/main'
|
3
5
|
require_relative 'senior/brains/open_ai'
|
4
6
|
require_relative 'senior/agent'
|
5
7
|
require_relative 'senior/version'
|
@@ -56,4 +58,32 @@ module Senior
|
|
56
58
|
def self.agent
|
57
59
|
@agent ||= Agent.new
|
58
60
|
end
|
61
|
+
|
62
|
+
# Returns the configuration object for the Senior gem
|
63
|
+
#
|
64
|
+
# @api private
|
65
|
+
#
|
66
|
+
# @return [Senior::Configuration::Main] The configuration object for the Senior gem
|
67
|
+
#
|
68
|
+
def self.configuration
|
69
|
+
@configuration ||= Configuration::Main.new
|
70
|
+
end
|
71
|
+
|
72
|
+
# Provides a way to configure the Senior gem
|
73
|
+
#
|
74
|
+
# @api public
|
75
|
+
#
|
76
|
+
# @yield [configuration] A block to configure the Senior gem
|
77
|
+
# @yieldparam configuration [Senior::Configuration::Main] The configuration object for the Senior gem
|
78
|
+
#
|
79
|
+
# @example Configuring the Senior gem
|
80
|
+
# Senior.configure do |config|
|
81
|
+
# config.open_ai.access_token = 'your_openai_api_key'
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
# @return [void]
|
85
|
+
#
|
86
|
+
def self.configure
|
87
|
+
yield(configuration)
|
88
|
+
end
|
59
89
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Senior
|
2
2
|
module Brains
|
3
3
|
class OpenAI
|
4
|
+
CHAT_MODELS: Array[String]
|
5
|
+
COMPLETION_MODELS: Array[String]
|
6
|
+
CHAT_SYSTEM_PROMPT: String
|
7
|
+
|
4
8
|
@open_ai_client: untyped
|
5
9
|
|
6
10
|
def suggest_fix: (erroneous_source: String, exception_backtrace: String) -> String
|
@@ -8,7 +12,9 @@ module Senior
|
|
8
12
|
private
|
9
13
|
|
10
14
|
def open_ai_client: -> untyped
|
11
|
-
def request_completion: (String prompt
|
15
|
+
def request_completion: (String prompt) -> String
|
16
|
+
def request_chat_completion: (String prompt) -> String
|
17
|
+
def defaults: -> Senior::Configuration::OpenAI
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Senior
|
2
|
+
module Configuration
|
3
|
+
class OpenAI
|
4
|
+
DEFAULT_API_VERSION: String
|
5
|
+
DEFAULT_MAX_TOKENS: Integer
|
6
|
+
DEFAULT_MODEL: String
|
7
|
+
DEFAULT_N: Integer
|
8
|
+
DEFAULT_REQUEST_TIMEOUT: Integer
|
9
|
+
DEFAULT_TEMPERATURE: Float
|
10
|
+
DEFAULT_URI_BASE: String
|
11
|
+
|
12
|
+
attr_writer access_token: String?|nil
|
13
|
+
attr_accessor api_version: String
|
14
|
+
attr_accessor max_tokens: Integer
|
15
|
+
attr_accessor model: String
|
16
|
+
attr_accessor n: Integer
|
17
|
+
attr_accessor organization_id: String?|nil
|
18
|
+
attr_accessor request_timeout: Integer
|
19
|
+
attr_accessor temperature: Float
|
20
|
+
attr_accessor uri_base: String
|
21
|
+
|
22
|
+
def initialize: -> void
|
23
|
+
def access_token: -> String?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/sig/senior.rbs
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
module Senior
|
2
2
|
VERSION: String
|
3
|
+
self.@configuration: Configuration::Main
|
3
4
|
self.@agent: Agent
|
4
5
|
|
5
6
|
def self.auto_debug: (Method broken_method, untyped args, String? | nil broken_method_source) -> untyped
|
6
|
-
|
7
7
|
def self.suggest_fix: (Method broken_method, untyped args) -> String
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def self.configuration: -> Configuration::Main
|
9
|
+
def self.configure: -> untyped
|
11
10
|
def self.agent: -> Agent
|
12
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: senior
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilson Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|
@@ -361,8 +361,9 @@ dependencies:
|
|
361
361
|
- !ruby/object:Gem::Version
|
362
362
|
version: '0.9'
|
363
363
|
description: |-
|
364
|
-
|
365
|
-
code
|
364
|
+
An AI-powered pair programmer. Provides a user-friendly interface for using AI API's to
|
365
|
+
automatically repair broken code and suggest improvements. Simply provide the faulty code as input, and the gem will
|
366
|
+
generate a corrected version using advanced machine learning techniques.
|
366
367
|
email:
|
367
368
|
- wilson.dsigns@gmail.com
|
368
369
|
executables: []
|
@@ -387,6 +388,9 @@ files:
|
|
387
388
|
- lib/senior.rb
|
388
389
|
- lib/senior/agent.rb
|
389
390
|
- lib/senior/brains/open_ai.rb
|
391
|
+
- lib/senior/configuration/main.rb
|
392
|
+
- lib/senior/configuration/open_ai.rb
|
393
|
+
- lib/senior/errors.rb
|
390
394
|
- lib/senior/version.rb
|
391
395
|
- sig/gems/method_source/method.rbs
|
392
396
|
- sig/gems/ruby-openai/client.rbs
|
@@ -394,6 +398,9 @@ files:
|
|
394
398
|
- sig/senior/agent.rbs
|
395
399
|
- sig/senior/brains/i_brain.rbs
|
396
400
|
- sig/senior/brains/open_ai.rbs
|
401
|
+
- sig/senior/configuration/main.rbs
|
402
|
+
- sig/senior/configuration/open_ai.rbs
|
403
|
+
- sig/senior/errors.rbs
|
397
404
|
homepage: https://github.com/wilsonsilva/senior
|
398
405
|
licenses:
|
399
406
|
- MIT
|
@@ -421,5 +428,5 @@ requirements: []
|
|
421
428
|
rubygems_version: 3.4.10
|
422
429
|
signing_key:
|
423
430
|
specification_version: 4
|
424
|
-
summary: AI
|
431
|
+
summary: An AI-powered pair programmer
|
425
432
|
test_files: []
|