rbs_goose 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -2
- data/.ruby-version +1 -1
- data/Gemfile +20 -13
- data/Gemfile.lock +69 -38
- data/README-ja.md +88 -0
- data/README.md +25 -22
- data/Rakefile +53 -8
- data/Steepfile +1 -3
- data/evaluations/01_rbs_goose/claude_haiku.log +1494 -0
- data/evaluations/01_rbs_goose/claude_opus.log +1439 -0
- data/evaluations/01_rbs_goose/claude_sonnet.log +1437 -0
- data/evaluations/01_rbs_goose/gpt-3-5-turbo.log +1241 -0
- data/evaluations/01_rbs_goose/gpt-4-turbo.log +1304 -0
- data/examples/fix_errors/Steepfile +6 -0
- data/examples/fix_errors/error_messages.txt +26 -0
- data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/refined/sig/email.rbs +1 -1
- data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/refined/sig/person.rbs +2 -2
- data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/refined/sig/phone.rbs +1 -1
- data/examples/fix_errors/sig/email.rbs +11 -0
- data/examples/fix_errors/sig/person.rbs +15 -0
- data/examples/fix_errors/sig/phone.rbs +15 -0
- data/examples/rbs_samples/lib/email.rb +16 -0
- data/examples/rbs_samples/lib/person.rb +23 -0
- data/examples/rbs_samples/lib/phone.rb +22 -0
- data/examples/rbs_samples/refined/sig/email.rbs +11 -0
- data/examples/rbs_samples/refined/sig/person.rbs +15 -0
- data/examples/rbs_samples/refined/sig/phone.rbs +15 -0
- data/examples/rbs_syntax/Steepfile +6 -0
- data/examples/rbs_syntax/lib/a.rb +53 -0
- data/examples/rbs_syntax/lib/list.rb +9 -0
- data/examples/rbs_syntax/lib/main.rb +17 -0
- data/examples/rbs_syntax/refined/sig/a.rbs +47 -0
- data/examples/rbs_syntax/refined/sig/list.rbs +7 -0
- data/examples/rbs_syntax/refined/sig/main.rbs +26 -0
- data/examples/rbs_syntax/sig/a.rbs +47 -0
- data/examples/rbs_syntax/sig/list.rbs +7 -0
- data/examples/rbs_syntax/sig/main.rbs +26 -0
- data/lib/rbs_goose/configuration.rb +93 -23
- data/lib/rbs_goose/io/example.rb +2 -2
- data/lib/rbs_goose/io/example_group.rb +16 -7
- data/lib/rbs_goose/io/target_group.rb +1 -1
- data/lib/rbs_goose/io/typed_ruby.rb +3 -3
- data/lib/rbs_goose/orthoses/fix_error.rb +26 -0
- data/lib/rbs_goose/orthoses/infer.rb +26 -0
- data/lib/rbs_goose/orthoses.rb +9 -0
- data/lib/rbs_goose/templates/base.rb +77 -0
- data/lib/rbs_goose/templates/fix_error_template.rb +43 -0
- data/lib/rbs_goose/templates/infer_template.rb +30 -0
- data/lib/rbs_goose/templates.rb +3 -1
- data/lib/rbs_goose/type_inferrer.rb +85 -2
- data/lib/rbs_goose/version.rb +1 -1
- data/lib/rbs_goose.rb +24 -4
- data/rbs_collection.lock.yaml +63 -47
- data/renovate.json +5 -0
- data/sig/rbs_goose/configuration.rbs +20 -12
- data/sig/rbs_goose/io/example.rbs +7 -7
- data/sig/rbs_goose/io/example_group.rbs +9 -7
- data/sig/rbs_goose/io/file.rbs +10 -10
- data/sig/rbs_goose/io/target_group.rbs +2 -2
- data/sig/rbs_goose/io/typed_ruby.rbs +7 -7
- data/sig/rbs_goose/io.rbs +1 -1
- data/sig/rbs_goose/orthoses/fix_error.rbs +11 -0
- data/sig/rbs_goose/orthoses/infer.rbs +11 -0
- data/sig/rbs_goose/orthoses.rbs +2 -0
- data/sig/rbs_goose/templates/base.rbs +18 -0
- data/sig/rbs_goose/templates/fix_error_template.rbs +6 -0
- data/sig/rbs_goose/templates/infer_template.rbs +6 -0
- data/sig/rbs_goose/templates.rbs +1 -1
- data/sig/rbs_goose/type_inferrer.rbs +9 -1
- data/sig/rbs_goose.rbs +18 -9
- metadata +137 -21
- data/README-EN-US.md +0 -85
- data/lib/rbs_goose/templates/default_template.rb +0 -49
- data/sig/rbs_goose/templates/default_template.rbs +0 -10
- /data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/lib/email.rb +0 -0
- /data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/lib/person.rb +0 -0
- /data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/lib/phone.rb +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/Steepfile +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/sig/email.rbs +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/sig/person.rbs +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/sig/phone.rbs +0 -0
@@ -1,14 +1,22 @@
|
|
1
1
|
class RbsGoose::Configuration
|
2
|
-
@llm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
@llm: LLMConfig
|
3
|
+
extend Forwardable
|
4
|
+
class LLMConfig
|
5
|
+
end
|
6
|
+
class TemplateConfig
|
7
|
+
def build_template: () -> Templates::Base
|
8
|
+
end
|
9
|
+
def initialize: () ?{ () -> void } -> void
|
10
|
+
attr_accessor llm: LLMConfig
|
11
|
+
attr_accessor infer_template: TemplateConfig
|
12
|
+
attr_accessor fix_error_template: TemplateConfig
|
13
|
+
def use_open_ai: (String open_ai_access_token, ?model_name: String, ?mode: Symbol, ?llm_options: Hash[Symbol, untyped], ?default_options: Hash[Symbol, untyped]) -> void
|
14
|
+
def use_anthropic: (String access_token, ?model_name: String, ?mode: Symbol, ?default_options: Hash[Symbol, untyped]) -> void
|
15
|
+
def use_ollama: (?url: String, ?model_name: String, ?mode: Symbol, ?default_options: Hash[Symbol, untyped]) -> void
|
16
|
+
private def default_infer_template: () -> TemplateConfig
|
17
|
+
private def default_fix_error_template: () -> TemplateConfig
|
18
|
+
private def default_infer_instruction: () -> String
|
19
|
+
private def default_infer_example_groups: () -> Array[RbsGoose::IO::ExampleGroup]
|
20
|
+
private def default_fix_error_instruction: () -> String
|
21
|
+
private def default_fix_error_example_groups: () -> Array[RbsGoose::IO::ExampleGroup]
|
14
22
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class RbsGoose::IO::Example
|
2
|
-
@typed_ruby:
|
3
|
-
@refined_rbs:
|
4
|
-
def self.from_path: (ruby_path: String, rbs_path: String, refined_rbs_dir: String, base_path:
|
5
|
-
def initialize: (typed_ruby:
|
6
|
-
def to_h: () -> { typed_ruby:
|
7
|
-
attr_reader typed_ruby:
|
8
|
-
attr_reader refined_rbs:
|
2
|
+
@typed_ruby: TypedRuby
|
3
|
+
@refined_rbs: File
|
4
|
+
def self.from_path: (ruby_path: String, rbs_path: String, refined_rbs_dir: String, base_path: String) -> Example
|
5
|
+
def initialize: (typed_ruby: TypedRuby, refined_rbs: File) -> void
|
6
|
+
def to_h: () -> { typed_ruby: TypedRuby, refined_rbs: File }
|
7
|
+
attr_reader typed_ruby: TypedRuby
|
8
|
+
attr_reader refined_rbs: File
|
9
9
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
class RbsGoose::IO::ExampleGroup < ::Array[
|
2
|
-
self.@default_examples: Hash[Symbol,
|
3
|
-
|
4
|
-
def self.
|
5
|
-
|
6
|
-
def
|
7
|
-
def
|
1
|
+
class RbsGoose::IO::ExampleGroup < ::Array[Example]
|
2
|
+
self.@default_examples: Hash[Symbol, ExampleGroup]
|
3
|
+
attr_accessor error_messages: String?
|
4
|
+
def self.load_from: (String base_path, ?code_dir: String, ?sig_dir: String, ?refined_dir: String) -> ExampleGroup
|
5
|
+
def self.default_examples: () -> Hash[Symbol, ExampleGroup]
|
6
|
+
private def self.load_example: (String base_path, String code_dir, String path, String refined_dir, String sig_dir) -> Example
|
7
|
+
private def self.to_rbs_path: (String path, String sig_dir) -> String
|
8
|
+
def to_target_group: () -> TargetGroup
|
9
|
+
def to_refined_rbs_list: () -> Array[File]
|
8
10
|
end
|
data/sig/rbs_goose/io/file.rbs
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
class RbsGoose::IO::File
|
2
2
|
@path: String
|
3
|
-
@base_path:
|
3
|
+
@base_path: String?
|
4
4
|
@content: String
|
5
|
-
@type:
|
6
|
-
MARKDOWN_REGEXP:
|
7
|
-
def self.from_markdown: (String) ->
|
8
|
-
def initialize: (path: String, ?content: String
|
5
|
+
@type: Symbol
|
6
|
+
MARKDOWN_REGEXP: Regexp
|
7
|
+
def self.from_markdown: (String markdown) -> File
|
8
|
+
def initialize: (path: String, ?content: String?, ?base_path: String?) -> void
|
9
9
|
def load_content: () -> String
|
10
10
|
def absolute_path: () -> String
|
11
|
-
def type: () ->
|
11
|
+
def type: () -> Symbol
|
12
12
|
def to_s: () -> String
|
13
|
-
def content=: (String) -> String
|
14
|
-
def write: () ->
|
15
|
-
def ==: (
|
13
|
+
def content=: (String content) -> String
|
14
|
+
def write: () -> void
|
15
|
+
def ==: (Object other) -> bool
|
16
16
|
attr_reader path: String
|
17
17
|
attr_reader content: String
|
18
|
-
attr_reader base_path:
|
18
|
+
attr_reader base_path: String?
|
19
19
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class RbsGoose::IO::TargetGroup < ::Array[
|
2
|
-
def self.load_from: (
|
1
|
+
class RbsGoose::IO::TargetGroup < ::Array[TypedRuby]
|
2
|
+
def self.load_from: (String base_path, ?code_dir: String, ?sig_dir: String) -> TargetGroup
|
3
3
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class RbsGoose::IO::TypedRuby
|
2
|
-
@ruby:
|
3
|
-
@rbs:
|
4
|
-
def self.from_path: (ruby_path: String, rbs_path: String, base_path:
|
5
|
-
def initialize: (ruby:
|
6
|
-
def to_s: () ->
|
7
|
-
attr_reader ruby:
|
8
|
-
attr_reader rbs:
|
2
|
+
@ruby: File
|
3
|
+
@rbs: File?
|
4
|
+
def self.from_path: (ruby_path: String, rbs_path: String, base_path: String) -> TypedRuby
|
5
|
+
def initialize: (ruby: File, rbs: File?) -> void
|
6
|
+
def to_s: () -> String
|
7
|
+
attr_reader ruby: File
|
8
|
+
attr_reader rbs: File?
|
9
9
|
end
|
data/sig/rbs_goose/io.rbs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
module RbsGoose::IO
|
2
|
-
end
|
2
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Call RbsGoose::TypeInferrer to fix steep type errors.
|
2
|
+
# use TbsGoose::Orthoses::FixError, code_dir: 'lib', sig_dir: 'sig' do |config|
|
3
|
+
# config.use_open_ai('open_ai_access_token')
|
4
|
+
# end
|
5
|
+
class RbsGoose::Orthoses::FixError
|
6
|
+
@loader: Proc
|
7
|
+
@code_dir: String
|
8
|
+
@sig_dir: String
|
9
|
+
def initialize: (loader: Proc, ?code_dir: String, ?sig_dir: String) ?{ () -> void } -> void
|
10
|
+
def call: () -> untyped
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Call RbsGoose::TypeInferrer to infer RBS type signatures.
|
2
|
+
# use TbsGoose::Orthoses::Infer, code_dir: 'lib', sig_dir: 'sig' do |config|
|
3
|
+
# config.use_open_ai('open_ai_access_token')
|
4
|
+
# end
|
5
|
+
class RbsGoose::Orthoses::Infer
|
6
|
+
@loader: Proc
|
7
|
+
@code_dir: String
|
8
|
+
@sig_dir: String
|
9
|
+
def initialize: (loader: Proc, ?code_dir: String, ?sig_dir: String) ?{ () -> void } -> void
|
10
|
+
def call: () -> untyped
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class RbsGoose::Templates::Base
|
2
|
+
@instruction: String
|
3
|
+
@example_groups: Array[RbsGoose::IO::ExampleGroup]
|
4
|
+
def initialize: (instruction: String, example_groups: Array[RbsGoose::IO::ExampleGroup]) -> void
|
5
|
+
def format: (**untyped args) -> String
|
6
|
+
def format_system_prompt: () -> String
|
7
|
+
def format_user_prompt: (**untyped args) -> String
|
8
|
+
def parse_result: (String result) -> Array[RbsGoose::IO::File]
|
9
|
+
private def input_template_string: () -> String
|
10
|
+
private def input_variables: () -> Array[String]
|
11
|
+
private def transform_example_group: (RbsGoose::IO::ExampleGroup example_group) -> Hash[String, String]
|
12
|
+
private def format_args: (untyped args) -> Hash[String, String]
|
13
|
+
private def prefix: () -> String
|
14
|
+
private def suffix: () -> String
|
15
|
+
private def example_prompt: () -> Langchain::Prompt::PromptTemplate
|
16
|
+
private attr_reader instruction: String
|
17
|
+
private attr_reader example_groups: Array[RbsGoose::IO::ExampleGroup]
|
18
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class RbsGoose::Templates::FixErrorTemplate < ::RbsGoose::Templates::Base
|
2
|
+
private def input_variables: () -> Array["typed_ruby_list", "error_messages"]
|
3
|
+
private def input_template_string: () -> String
|
4
|
+
private def format_args: (untyped args) -> { typed_ruby_list: String, error_messages: String }
|
5
|
+
private def transform_example_group: (RbsGoose::IO::ExampleGroup example_group) -> { typed_ruby_list: String, error_messages: String?, refined_rbs_list: String }
|
6
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class RbsGoose::Templates::InferTemplate < ::RbsGoose::Templates::Base
|
2
|
+
private def input_variables: () -> Array["typed_ruby_list"]
|
3
|
+
private def input_template_string: () -> String
|
4
|
+
private def format_args: (untyped args) -> { typed_ruby_list: String }
|
5
|
+
private def transform_example_group: (RbsGoose::IO::ExampleGroup example_group) -> { typed_ruby_list: String, refined_rbs_list: String }
|
6
|
+
end
|
data/sig/rbs_goose/templates.rbs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
module RbsGoose::Templates
|
2
|
-
end
|
2
|
+
end
|
@@ -1,3 +1,11 @@
|
|
1
1
|
class RbsGoose::TypeInferrer
|
2
|
-
def infer: (
|
2
|
+
def infer: (RbsGoose::IO::TargetGroup target_group) -> Array[RbsGoose::IO::File]
|
3
|
+
def fix_error: (RbsGoose::IO::TargetGroup target_group) -> Array[RbsGoose::IO::File]
|
4
|
+
private def call_llm: (RbsGoose::Templates::Base template, Hash[String, untyped] format_args) -> Array[RbsGoose::IO::File]
|
5
|
+
private def call_llm_complete: (Hash[String, untyped] format_args, RbsGoose::Templates::Base template) -> String
|
6
|
+
private def call_llm_chat: (Hash[String, untyped] format_args, RbsGoose::Templates::Base template) -> String
|
7
|
+
private def llm_debug: (String prompt) { () -> Langchain::LLM::Result } -> Langchain::LLM::Result
|
8
|
+
private def steep_check: () -> String
|
9
|
+
private def io_stubs: () -> Array[StringIO]
|
10
|
+
private def disable_rainbow: () { () -> void } -> void
|
3
11
|
end
|
data/sig/rbs_goose.rbs
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
module RbsGoose
|
2
|
-
VERSION:
|
3
|
-
|
2
|
+
VERSION: String
|
3
|
+
|
4
|
+
self.@configuration: Configuration?
|
5
|
+
|
4
6
|
extend Forwardable
|
5
|
-
|
6
|
-
def self.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.
|
11
|
-
|
7
|
+
|
8
|
+
def self.configure: () { () -> void } -> Configuration
|
9
|
+
|
10
|
+
def self.reset_configuration: () -> nil
|
11
|
+
|
12
|
+
def self.run: (?code_dir: String, ?sig_dir: String, ?base_path: String) -> void
|
13
|
+
|
14
|
+
def self.fix_error: (?code_dir: String, ?sig_dir: String, ?base_path: String) -> void
|
15
|
+
|
16
|
+
def self.infer_template: () -> RbsGoose::Templates::InferTemplate
|
17
|
+
|
18
|
+
def self.fix_error_template: () -> RbsGoose::Templates::FixErrorTemplate
|
19
|
+
|
20
|
+
attr_reader self.configuration: Configuration?
|
12
21
|
end
|
metadata
CHANGED
@@ -1,22 +1,82 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_goose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kokuyouwind
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.9.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.9.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: langchainrb
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
16
36
|
requirements:
|
17
37
|
- - ">="
|
18
38
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
39
|
+
version: 0.12.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.12.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: steep
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.6.0
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.0.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.6.0
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.0.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: anthropic
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.2.0
|
20
80
|
- - "<"
|
21
81
|
- !ruby/object:Gem::Version
|
22
82
|
version: 1.0.0
|
@@ -26,10 +86,30 @@ dependencies:
|
|
26
86
|
requirements:
|
27
87
|
- - ">="
|
28
88
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
89
|
+
version: 0.2.0
|
30
90
|
- - "<"
|
31
91
|
- !ruby/object:Gem::Version
|
32
92
|
version: 1.0.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: orthoses
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.13.0
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.0.0
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.13.0
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.0.0
|
33
113
|
- !ruby/object:Gem::Dependency
|
34
114
|
name: ruby-openai
|
35
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +119,7 @@ dependencies:
|
|
39
119
|
version: 6.1.0
|
40
120
|
- - "<"
|
41
121
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
122
|
+
version: 8.0.0
|
43
123
|
type: :runtime
|
44
124
|
prerelease: false
|
45
125
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +129,7 @@ dependencies:
|
|
49
129
|
version: 6.1.0
|
50
130
|
- - "<"
|
51
131
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
132
|
+
version: 8.0.0
|
53
133
|
description: RBS type inferrer with LLM
|
54
134
|
email:
|
55
135
|
- kokuyouwind@gmail.com
|
@@ -66,31 +146,62 @@ files:
|
|
66
146
|
- Gemfile
|
67
147
|
- Gemfile.lock
|
68
148
|
- LICENSE.txt
|
69
|
-
- README-
|
149
|
+
- README-ja.md
|
70
150
|
- README.md
|
71
151
|
- Rakefile
|
72
152
|
- Steepfile
|
73
153
|
- assets/logo.svg
|
154
|
+
- evaluations/01_rbs_goose/claude_haiku.log
|
155
|
+
- evaluations/01_rbs_goose/claude_opus.log
|
156
|
+
- evaluations/01_rbs_goose/claude_sonnet.log
|
157
|
+
- evaluations/01_rbs_goose/gpt-3-5-turbo.log
|
158
|
+
- evaluations/01_rbs_goose/gpt-4-turbo.log
|
159
|
+
- examples/fix_errors/Steepfile
|
160
|
+
- examples/fix_errors/error_messages.txt
|
161
|
+
- examples/fix_errors/lib/email.rb
|
162
|
+
- examples/fix_errors/lib/person.rb
|
163
|
+
- examples/fix_errors/lib/phone.rb
|
164
|
+
- examples/fix_errors/refined/sig/email.rbs
|
165
|
+
- examples/fix_errors/refined/sig/person.rbs
|
166
|
+
- examples/fix_errors/refined/sig/phone.rbs
|
167
|
+
- examples/fix_errors/sig/email.rbs
|
168
|
+
- examples/fix_errors/sig/person.rbs
|
169
|
+
- examples/fix_errors/sig/phone.rbs
|
170
|
+
- examples/rbs_samples/Steepfile
|
171
|
+
- examples/rbs_samples/lib/email.rb
|
172
|
+
- examples/rbs_samples/lib/person.rb
|
173
|
+
- examples/rbs_samples/lib/phone.rb
|
174
|
+
- examples/rbs_samples/refined/sig/email.rbs
|
175
|
+
- examples/rbs_samples/refined/sig/person.rbs
|
176
|
+
- examples/rbs_samples/refined/sig/phone.rbs
|
177
|
+
- examples/rbs_samples/sig/email.rbs
|
178
|
+
- examples/rbs_samples/sig/person.rbs
|
179
|
+
- examples/rbs_samples/sig/phone.rbs
|
180
|
+
- examples/rbs_syntax/Steepfile
|
181
|
+
- examples/rbs_syntax/lib/a.rb
|
182
|
+
- examples/rbs_syntax/lib/list.rb
|
183
|
+
- examples/rbs_syntax/lib/main.rb
|
184
|
+
- examples/rbs_syntax/refined/sig/a.rbs
|
185
|
+
- examples/rbs_syntax/refined/sig/list.rbs
|
186
|
+
- examples/rbs_syntax/refined/sig/main.rbs
|
187
|
+
- examples/rbs_syntax/sig/a.rbs
|
188
|
+
- examples/rbs_syntax/sig/list.rbs
|
189
|
+
- examples/rbs_syntax/sig/main.rbs
|
74
190
|
- lib/rbs_goose.rb
|
75
191
|
- lib/rbs_goose/configuration.rb
|
76
|
-
- lib/rbs_goose/examples/rbs_samples/Steepfile
|
77
|
-
- lib/rbs_goose/examples/rbs_samples/lib/email.rb
|
78
|
-
- lib/rbs_goose/examples/rbs_samples/lib/person.rb
|
79
|
-
- lib/rbs_goose/examples/rbs_samples/lib/phone.rb
|
80
|
-
- lib/rbs_goose/examples/rbs_samples/refined/sig/email.rbs
|
81
|
-
- lib/rbs_goose/examples/rbs_samples/refined/sig/person.rbs
|
82
|
-
- lib/rbs_goose/examples/rbs_samples/refined/sig/phone.rbs
|
83
|
-
- lib/rbs_goose/examples/rbs_samples/sig/email.rbs
|
84
|
-
- lib/rbs_goose/examples/rbs_samples/sig/person.rbs
|
85
|
-
- lib/rbs_goose/examples/rbs_samples/sig/phone.rbs
|
86
192
|
- lib/rbs_goose/io.rb
|
87
193
|
- lib/rbs_goose/io/example.rb
|
88
194
|
- lib/rbs_goose/io/example_group.rb
|
89
195
|
- lib/rbs_goose/io/file.rb
|
90
196
|
- lib/rbs_goose/io/target_group.rb
|
91
197
|
- lib/rbs_goose/io/typed_ruby.rb
|
198
|
+
- lib/rbs_goose/orthoses.rb
|
199
|
+
- lib/rbs_goose/orthoses/fix_error.rb
|
200
|
+
- lib/rbs_goose/orthoses/infer.rb
|
92
201
|
- lib/rbs_goose/templates.rb
|
93
|
-
- lib/rbs_goose/templates/
|
202
|
+
- lib/rbs_goose/templates/base.rb
|
203
|
+
- lib/rbs_goose/templates/fix_error_template.rb
|
204
|
+
- lib/rbs_goose/templates/infer_template.rb
|
94
205
|
- lib/rbs_goose/type_inferrer.rb
|
95
206
|
- lib/rbs_goose/version.rb
|
96
207
|
- rbs_collection.lock.yaml
|
@@ -105,8 +216,13 @@ files:
|
|
105
216
|
- sig/rbs_goose/io/file.rbs
|
106
217
|
- sig/rbs_goose/io/target_group.rbs
|
107
218
|
- sig/rbs_goose/io/typed_ruby.rbs
|
219
|
+
- sig/rbs_goose/orthoses.rbs
|
220
|
+
- sig/rbs_goose/orthoses/fix_error.rbs
|
221
|
+
- sig/rbs_goose/orthoses/infer.rbs
|
108
222
|
- sig/rbs_goose/templates.rbs
|
109
|
-
- sig/rbs_goose/templates/
|
223
|
+
- sig/rbs_goose/templates/base.rbs
|
224
|
+
- sig/rbs_goose/templates/fix_error_template.rbs
|
225
|
+
- sig/rbs_goose/templates/infer_template.rbs
|
110
226
|
- sig/rbs_goose/type_inferrer.rbs
|
111
227
|
- sig_ext/class.rbs
|
112
228
|
- sig_ext/langchain/llm.rbs
|
@@ -126,14 +242,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
242
|
requirements:
|
127
243
|
- - ">="
|
128
244
|
- !ruby/object:Gem::Version
|
129
|
-
version: 3.
|
245
|
+
version: 3.3.0
|
130
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
247
|
requirements:
|
132
248
|
- - ">="
|
133
249
|
- !ruby/object:Gem::Version
|
134
250
|
version: '0'
|
135
251
|
requirements: []
|
136
|
-
rubygems_version: 3.5.
|
252
|
+
rubygems_version: 3.5.9
|
137
253
|
signing_key:
|
138
254
|
specification_version: 4
|
139
255
|
summary: RBS type inferrer with LLM
|
data/README-EN-US.md
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
<p align="center">
|
2
|
-
<img src="https://raw.githubusercontent.com/kokuyouwind/rbs_goose/main/assets/logo.svg" alt="RuboCop Logo"/>
|
3
|
-
</p>
|
4
|
-
|
5
|
-
[![en-US README](https://img.shields.io/badge/Multilingual_README-en--US-blue.svg)](/README-EN-US.md)
|
6
|
-
[![en-JP README](https://img.shields.io/badge/Multilingual_README-ja--JP-orangered.svg)](/README.md)
|
7
|
-
|
8
|
-
[![Ruby](https://github.com/kokuyouwind/rbs_goose/actions/workflows/main.yml/badge.svg)](https://github.com/kokuyouwind/rbs_goose/actions/workflows/main.yml)
|
9
|
-
|
10
|
-
RBS Goose is a tool that uses ChatGPT and other large language models to infer the RBS signature of Ruby code.
|
11
|
-
|
12
|
-
> [!CAUTION]
|
13
|
-
> Currently undergoing technical validation, so you may get little or no output of the appropriate types.
|
14
|
-
> Also, the tool uses ChatGPT API and other tools to infer RBS signatures, so depending on the size of your code, the usage fee may be expensive.
|
15
|
-
|
16
|
-
## Installation
|
17
|
-
|
18
|
-
```bash
|
19
|
-
$ gem install rbs_goose
|
20
|
-
## Depending on the LangChain LLM you are using, install the corresponding gem
|
21
|
-
$ gem install ruby-openai
|
22
|
-
```
|
23
|
-
|
24
|
-
If you use `bundler`, add the following to your `Gemfile` instead.
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
gem 'rbs_goose'.
|
28
|
-
# Depending on your LangChain LLM, install the corresponding gem
|
29
|
-
gem 'ruby-openai'
|
30
|
-
```
|
31
|
-
|
32
|
-
## Usage
|
33
|
-
|
34
|
-
Currently, command line tools are not yet available, so please call `RbsGoose.run` directly from `Rakefile` or other sources.
|
35
|
-
|
36
|
-
If you use [OpenAI API](https://openai.com/blog/openai-api), do the following.
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
require 'rbs_goose'
|
40
|
-
require 'openai'
|
41
|
-
|
42
|
-
desc 'refine RBS files in sig directory' ```ruby require 'rbs_goose' require 'openai'
|
43
|
-
task :refine do
|
44
|
-
RbsGoose.configure do |c|
|
45
|
-
c.use_open_ai(ENV.fetch('OPENAI_ACCESS_TOKEN'))
|
46
|
-
end
|
47
|
-
RbsGoose.run
|
48
|
-
end
|
49
|
-
```
|
50
|
-
|
51
|
-
Running this task will reference the Ruby code under `lib` and the RBS signature under `sig` and override the guessed signature.
|
52
|
-
|
53
|
-
To change the target directory, specify the following arguments to `RbsGoose.run`.
|
54
|
-
|
55
|
-
```ruby
|
56
|
-
RbsGoose.run(code_dir: 'app', sig_dir: 'types', base_path: Rails.root)
|
57
|
-
```
|
58
|
-
|
59
|
-
[Langchain.rb](https://github.com/andreibondarev/langchainrb) is used to invoke the large language model.
|
60
|
-
|
61
|
-
To use other large-scale language models, set `llm` directly as follows.
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
RbsGoose.configure do |c|
|
65
|
-
c.llm = Langchain::LLM::GooglePalm.new(api_key: ENV["GOOGLE_PALM_API_KEY"])
|
66
|
-
end
|
67
|
-
```
|
68
|
-
|
69
|
-
## Development
|
70
|
-
|
71
|
-
After checking out the repository, run bin/setup to install the dependencies. Next, run `rake spec` to run the tests. You can also try running `bin/console` as an interactive prompt.
|
72
|
-
|
73
|
-
To install the gem on your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb` and run `bundle exec rake release`. This will create a Git tag for the version, push the Git commit and the created tag, and push the .gem file to rubygems.org.
|
74
|
-
|
75
|
-
## Contributing
|
76
|
-
|
77
|
-
Bug reports and pull requests are accepted on GitHub at https://github.com/kokuyouwind/rbs_goose. The project aims to be a safe and welcoming space for collaborative work, and contributors are expected to follow the [CODE OF CONDUCT](/CODE_OF_CONDUCT.md).
|
78
|
-
|
79
|
-
## License
|
80
|
-
|
81
|
-
This gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
82
|
-
|
83
|
-
## Code of Conduct
|
84
|
-
|
85
|
-
Everyone involved with the RbsGoose project codebase, issue tracker, chat room, and mailing lists is expected to follow the [CODE OF CONDUCT](/CODE_OF_CONDUCT.md).
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'langchain'
|
4
|
-
|
5
|
-
module RbsGoose
|
6
|
-
module Templates
|
7
|
-
class DefaultTemplate
|
8
|
-
def initialize(instruction:, example_groups:)
|
9
|
-
@template = Langchain::Prompt::FewShotPromptTemplate.new(
|
10
|
-
prefix: instruction,
|
11
|
-
suffix: "#{input_template_string}\n",
|
12
|
-
example_prompt: example_prompt,
|
13
|
-
examples: example_groups.map { transform_example_group(_1) },
|
14
|
-
input_variables: %w[typed_ruby_list]
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
def format(typed_ruby_list)
|
19
|
-
template.format(typed_ruby_list: typed_ruby_list.join("\n"))
|
20
|
-
end
|
21
|
-
|
22
|
-
def parse_result(result)
|
23
|
-
result.scan(/```.+?```/m).map { IO::File.from_markdown(_1) }
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :template
|
29
|
-
|
30
|
-
def example_prompt
|
31
|
-
Langchain::Prompt::PromptTemplate.new(
|
32
|
-
template: "#{input_template_string}\n{refined_rbs_list}",
|
33
|
-
input_variables: %w[typed_ruby_list refined_rbs_list]
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
def input_template_string
|
38
|
-
"========Input========\n{typed_ruby_list}\n\n========Output========"
|
39
|
-
end
|
40
|
-
|
41
|
-
def transform_example_group(example_group)
|
42
|
-
{
|
43
|
-
typed_ruby_list: example_group.map(&:typed_ruby).join("\n"),
|
44
|
-
refined_rbs_list: example_group.map(&:refined_rbs).join("\n")
|
45
|
-
}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class RbsGoose::Templates::DefaultTemplate
|
2
|
-
@template: Langchain::Prompt::FewShotPromptTemplate
|
3
|
-
def initialize: (instruction: String, example_groups: Array[untyped]) -> void
|
4
|
-
def format: (Array[untyped]) -> untyped
|
5
|
-
def parse_result: (untyped) -> untyped
|
6
|
-
private attr_reader template: Langchain::Prompt::FewShotPromptTemplate
|
7
|
-
private def example_prompt: () -> Langchain::Prompt::PromptTemplate
|
8
|
-
private def input_template_string: () -> String
|
9
|
-
private def transform_example_group: (untyped) -> { typed_ruby_list: untyped, refined_rbs_list: untyped }
|
10
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|