walkthrough_awanllm 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3c1e05c3e3013841ca0a693e12a5804d1cbb486b873c8e599fc7e755b3f8ae7
4
- data.tar.gz: f9e78e480b2acceb61a8090b5eb6565f7bc6c652f8452f60ae02d62f172ec4a5
3
+ metadata.gz: 0446edc0b2acf9d1e05995bd32dbc4c41fd84e34cefcc6effb76b650f85027a1
4
+ data.tar.gz: 7a8afe1355ff43f1047929b1badfb5fc2caedf439282daefac6d86191c0f863b
5
5
  SHA512:
6
- metadata.gz: cc1ffa46f7e4300107dedfb38e44848774f56669b1181a5dd341c76e2e4c40fe18d6681ef30a4c52afffef1e854de2d6dfe2f9e383017bcaca865ff46d5f0e7a
7
- data.tar.gz: 296d11ff0351651aa5214660ebf3a6374ef83abc21b6e12ab39b5886979ddfaf41628ca3ee9eae97e22da8db18891a5489e93c4fe3b3211aebc8abb7ab215f5f
6
+ metadata.gz: '09567b3cf0edd6e7e902f0e6f7f566c51a6ceaff197b0dfaef72b7a87f3e86b495f12c4f8d9c3817df5ee38b1cd78f55a2f28088940d05056121b7720b7a2223'
7
+ data.tar.gz: 23475f22d8c98560308d2080bbd0c8c274597bb8fd9873d1a477b3b83fe20480a8102db1b7dde363a74aa1211e1372c90241754afb5e75ddcb8ae1a527d42e10
data/README.md CHANGED
@@ -30,29 +30,20 @@ $ gem install walkthrough_awanllm
30
30
  After installing the gem, you need to configure it by running the setup script. This will prompt you for your AwanLLM API key and the model name you wish to use.
31
31
 
32
32
  ```sh
33
- $ ruby ./vendor/bundle/ruby/YOUR_VERSION/gems/walkthrough_awanllm-0.1.16/bin/setup_awanllm.rb
33
+ $ ruby ./vendor/bundle/ruby/YOUR_VERSION/gems/walkthrough_awanllm-0.1.18/bin/setup_awanllm.rb
34
34
  ```
35
35
 
36
36
  ## Usage
37
37
 
38
- ### Generating Content
39
-
40
- To generate content using the AwanLLM API, you can create an instance of the `AwanLLM` class and call its methods:
41
-
42
- ```ruby
43
- require 'walkthrough_awanllm'
44
-
45
- llm = AwanLLM.new
46
- response = llm.generate_content(prompt: "Generate some content based on this prompt.")
47
- puts response
48
- ```
49
38
 
50
39
  ### Generating a Walkthrough
51
40
 
52
41
  To generate a detailed walkthrough of your project's activities:
53
42
 
54
43
  ```ruby
55
- llm.generate_walkthrough
44
+ rails console
45
+ > awanllm = WalkthroughAwanllm::AwanLLM.new
46
+ > awanllm.generate_walkthrough
56
47
  ```
57
48
 
58
49
  This will read the activity log and generate a `walkthrough.md` file in the project's root directory.
data/Rakefile CHANGED
@@ -1,4 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+
5
+ # Load tasks defined in the lib/tasks directory
6
+ Dir.glob('lib/tasks/*.rake').each { |r| import r }
7
+
4
8
  task default: %i[]
@@ -0,0 +1,15 @@
1
+ # lib/walkthrough_awanllm/cli.rb
2
+
3
+ require 'thor'
4
+
5
+ module WalkthroughAwanllm
6
+ class CLI < Thor
7
+ desc "generate_walkthrough", "Generate the walkthrough.md file"
8
+ def generate_walkthrough
9
+ awanllm = AwanLLM.new
10
+ awanllm.generate_walkthrough
11
+ puts "Walkthrough generated successfully!"
12
+ end
13
+ end
14
+ end
15
+
@@ -1,34 +1,58 @@
1
-
2
1
  require 'rails/railtie'
3
2
  require 'fileutils'
3
+ require 'bundler'
4
+ require 'git'
5
+ require 'listen'
4
6
 
5
- module AwanLLM
7
+ module WalkthroughAwanllm
6
8
  class Railtie < Rails::Railtie
7
9
  initializer "awanllm.track_activity" do |app|
8
10
  app.config.middleware.use AwanLLM::Tracker
9
- end
10
- end
11
- end
12
-
13
- # Middleware to track activities
14
- module AwanLLM
15
- class Tracker
16
- def initialize(app)
17
- @app = app
18
- end
11
+ Bundler::Plugin.add_hook('after-install-all') do |specs|
12
+ log_gem_event('install', specs)
13
+ end
14
+ Bundler::Plugin.add_hook('before-uninstall-all') do |specs|
15
+ log_gem_event('uninstall', specs)
16
+ end
17
+ Bundler::Plugin.add_hook('before-update-all') do |specs|
18
+ log_gem_event('update', specs)
19
+ end
20
+ Bundler::Plugin.add_hook('after-exec-all') do |specs|
21
+ log_gem_event('execute', specs)
22
+ end
23
+ Bundler::Plugin.add_hook('after-update-all') do |specs|
24
+ log_gem_event('update', specs)
25
+ end
26
+ Bundler::Plugin.add_hook('after-clean-all') do |specs|
27
+ log_gem_event('clean', specs)
28
+ end
29
+ Bundler::Plugin.add_hook('after-list-all') do |specs|
30
+ log_gem_event('list', specs)
31
+ end
19
32
 
20
- def call(env)
21
- status, headers, response = @app.call(env)
22
- log_activity(env)
23
- [status, headers, response]
33
+ # Start Git repository monitoring
34
+ git = Git.open('.')
35
+ listener = Listen.to('.', only: /\.rb$/, ignore: /vendor|log/) do |modified, added, removed|
36
+ log_file_changes(modified, added, removed, git)
37
+ end
38
+ listener.start
24
39
  end
25
40
 
26
41
  private
27
42
 
28
- def log_activity(env)
43
+ def log_gem_event(action, specs)
44
+ FileUtils.mkdir_p("log")
45
+ File.open("log/awanllm_activity.log", "a") do |file|
46
+ file.puts("[#{Time.now}] Gem #{action}: #{specs.map(&:name).join(', ')}")
47
+ end
48
+ end
49
+
50
+ def log_file_changes(modified, added, removed, git)
29
51
  FileUtils.mkdir_p("log")
30
52
  File.open("log/awanllm_activity.log", "a") do |file|
31
- file.puts("[#{Time.now}] #{env['REQUEST_METHOD']} #{env['PATH_INFO']}")
53
+ modified.each { |file| file.puts("[#{Time.now}] Modified: #{file} (#{git.diff.stats[:changed]} lines changed)") }
54
+ added.each { |file| file.puts("[#{Time.now}] Added: #{file}") }
55
+ removed.each { |file| file.puts("[#{Time.now}] Removed: #{file}") }
32
56
  end
33
57
  end
34
58
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WalkthroughAwanllm
4
- VERSION = "0.1.16"
4
+ VERSION = "0.1.18"
5
5
  end
@@ -1,85 +1,89 @@
1
1
  require 'httparty'
2
2
  require 'json'
3
- require 'walkthorugh_awanllm/railtie' if defined?(Rails)
3
+ require_relative "walkthrough_awanllm/cli"
4
+ require_relative "walkthrough_awanllm/version"
5
+ require_relative "walkthrough_awanllm/railtie" if defined?(Rails)
4
6
 
5
- class AwanLLM
6
- include HTTParty
7
- base_uri 'https://api.awanllm.com/v1'
7
+ module WalkthroughAwanllm
8
+ class AwanLLM
9
+ include HTTParty
10
+ base_uri 'https://api.awanllm.com/v1'
8
11
 
9
- def initialize(api_key = nil, model_name = nil)
10
- if api_key.nil? || model_name.nil?
11
- config = JSON.parse(File.read("config/awanllm_config.json"))
12
- @api_key = config["api_key"]
13
- @model_name = config["model_name"]
14
- else
15
- @api_key = api_key
16
- @model_name = model_name
17
- end
12
+ def initialize(api_key = nil, model_name = nil)
13
+ if api_key.nil? || model_name.nil?
14
+ config = JSON.parse(File.read("config/awanllm_config.json"))
15
+ @api_key = config["api_key"]
16
+ @model_name = config["model_name"]
17
+ else
18
+ @api_key = api_key
19
+ @model_name = model_name
20
+ end
18
21
 
19
- @headers = {
20
- 'Content-Type' => 'application/json',
21
- 'Authorization' => "Bearer #{@api_key}"
22
- }
23
- end
22
+ @headers = {
23
+ 'Content-Type' => 'application/json',
24
+ 'Authorization' => "Bearer #{@api_key}"
25
+ }
26
+ end
24
27
 
25
- def generate_content(messages = nil, prompt = nil, options = {})
26
- payload = { model: @model_name }
27
- payload[:messages] = messages if messages
28
- payload[:prompt] = prompt if prompt
29
- payload.merge!(options)
28
+ def generate_content(messages = nil, prompt = nil, options = {})
29
+ payload = { model: @model_name }
30
+ payload[:messages] = messages if messages
31
+ payload[:prompt] = prompt if prompt
32
+ payload.merge!(options)
30
33
 
31
- response = self.class.post('/completions', headers: @headers, body: payload.to_json)
32
- handle_response(response)
33
- end
34
+ response = self.class.post('/completions', headers: @headers, body: payload.to_json)
35
+ handle_response(response)
36
+ end
34
37
 
35
- def retrieve_content(content_id)
36
- response = self.class.get("/completions/#{content_id}", headers: @headers)
37
- handle_response(response)
38
- end
38
+ def retrieve_content(content_id)
39
+ response = self.class.get("/completions/#{content_id}", headers: @headers)
40
+ handle_response(response)
41
+ end
39
42
 
40
- def generate_walkthrough
41
- activities = File.read("log/awanllm_activity.log")
42
- prompt = "Here is a log of activities:\n#{activities}\nGenerate a detailed walkthrough based on these activities. It should include the steps taken and the expected outcomes."
43
+ def generate_walkthrough
44
+ activities = File.read("log/awanllm_activity.log")
45
+ prompt = "Here is a log of activities:\n#{activities}\nGenerate a detailed walkthrough based on these activities. It should include the steps taken and the expected outcomes."
43
46
 
44
- options = {
45
- temperature: 0.7,
46
- top_p: 0.9,
47
- max_tokens: 1024
48
- }
47
+ options = {
48
+ temperature: 0.7,
49
+ top_p: 0.9,
50
+ max_tokens: 1024
51
+ }
49
52
 
50
- response = generate_content(nil, prompt, options)
51
- walkthrough = response['choices'][0]['text']
53
+ response = generate_content(nil, prompt, options)
54
+ walkthrough = response['choices'][0]['text']
52
55
 
53
- File.open("walkthrough.md", "w") do |file|
54
- file.write(walkthrough)
56
+ File.open("walkthrough.md", "w") do |file|
57
+ file.write(walkthrough)
58
+ end
55
59
  end
56
- end
57
60
 
58
- def self.activate!
59
- require 'fileutils'
60
- require 'json'
61
+ def self.activate!
62
+ require 'fileutils'
63
+ require 'json'
61
64
 
62
- # Run the installation script
63
- if File.exist?('config/awanllm_config.json')
64
- puts 'Walkthrough_AwanLLM gem is already configured.'
65
- else
66
- ruby_version = RUBY_VERSION.split('.').first(2).join('.')
67
- path_to_script = "./vendor/bundle/ruby/#{ruby_version}/gems/walkthrough_awanllm-0.1.16/bin/setup_awanllm.rb"
68
- system("ruby #{path_to_script}")
65
+ # Run the installation script
66
+ if File.exist?('config/awanllm_config.json')
67
+ puts 'Walkthrough_AwanLLM gem is already configured.'
68
+ else
69
+ ruby_version = RUBY_VERSION.split('.').first(3).join('.')
70
+ path_to_script = "./vendor/bundle/ruby/#{ruby_version}/gems/walkthrough_awanllm-0.1.18/bin/setup_awanllm.rb"
71
+ system("ruby #{path_to_script}")
72
+ end
69
73
  end
70
- end
71
74
 
72
- # Activate the gem automatically after installation
73
- activate!
75
+ # Activate the gem automatically after installation
76
+ activate!
74
77
 
75
- private
78
+ private
76
79
 
77
- def handle_response(response)
78
- if response.success?
79
- JSON.parse(response.body)
80
- else
81
- error_message = JSON.parse(response.body)['error']['message'] rescue response.message
82
- raise "Error: #{response.code} - #{error_message}"
80
+ def handle_response(response)
81
+ if response.success?
82
+ JSON.parse(response.body)
83
+ else
84
+ error_message = JSON.parse(response.body)['error']['message'] rescue response.message
85
+ raise "Error: #{response.code} - #{error_message}"
86
+ end
83
87
  end
84
88
  end
85
89
  end
Binary file
Binary file
Binary file
Binary file
@@ -33,12 +33,13 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = ["setup_awanllm.rb"]
34
34
  spec.require_paths = ["lib"]
35
35
  spec.add_dependency "httparty"
36
+ spec.add_dependency "thor"
36
37
  spec.add_development_dependency "bundler", "~> 2.0"
37
38
  spec.add_development_dependency "rake", "~> 13.0"
38
39
  spec.add_development_dependency "minitest", "~> 5.0"
39
40
  spec.post_install_message = <<-MESSAGE
40
41
  Thank you for installing the Walkthrough_AwanLLM gem!
41
42
  To complete the setup, please run the following command:
42
- ruby ./vendor/bundle/ruby/#{RUBY_VERSION.split('.').first(3).join('.')}/gems/walkthrough_awanllm-0.1.16/bin/setup_awanllm.rb
43
+ ruby ./vendor/bundle/ruby/#{RUBY_VERSION.split('.').first(3).join('.')}/gems/walkthrough_awanllm-0.1.18/bin/setup_awanllm.rb
43
44
  MESSAGE
44
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: walkthrough_awanllm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mrudul John
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,10 +96,15 @@ files:
82
96
  - Rakefile
83
97
  - bin/setup_awanllm.rb
84
98
  - lib/walkthrough_awanllm.rb
99
+ - lib/walkthrough_awanllm/cli.rb
85
100
  - lib/walkthrough_awanllm/railtie.rb
86
101
  - lib/walkthrough_awanllm/version.rb
87
102
  - sig/walkthrough_awanllm.rbs
88
103
  - walkthrough_awanllm-0.1.11.gem
104
+ - walkthrough_awanllm-0.1.13.gem
105
+ - walkthrough_awanllm-0.1.14.gem
106
+ - walkthrough_awanllm-0.1.15.gem
107
+ - walkthrough_awanllm-0.1.16.gem
89
108
  - walkthrough_awanllm.gemspec
90
109
  homepage: https://github.com/mruduljohn/Walkthrough_awanllm_gem
91
110
  licenses:
@@ -95,7 +114,7 @@ metadata:
95
114
  post_install_message: |2
96
115
  Thank you for installing the Walkthrough_AwanLLM gem!
97
116
  To complete the setup, please run the following command:
98
- ruby ./vendor/bundle/ruby/3.3.0/gems/walkthrough_awanllm-0.1.16/bin/setup_awanllm.rb
117
+ ruby ./vendor/bundle/ruby/3.3.0/gems/walkthrough_awanllm-0.1.18/bin/setup_awanllm.rb
99
118
  rdoc_options: []
100
119
  require_paths:
101
120
  - lib