walkthrough_awanllm 0.1.0 → 0.1.2

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: 3a6b691e6d3f1023d32733347a61c412390434b93331905aad7679335a8686b4
4
- data.tar.gz: 2b765172c9465dfc2179061635f8e39d938386f3ecd40a1705e12015f4e6a874
3
+ metadata.gz: 34fee1262b75077f8e4c1d962798787a9998392d6d8e4adaac320001dabbc533
4
+ data.tar.gz: c05d2adf5e959e52a32ba1e69cd06f1eb581c4cfd02a292ab95d6f546bff9fbf
5
5
  SHA512:
6
- metadata.gz: 04617cdb004d1c65a118f4e66cb222dde75f58da432240885a66f24c2892bf6192cf7dc4031e16833940aea98d6d144c04cbebd394cae933cd1523687577990f
7
- data.tar.gz: 1fe5d80e013fefeba6fdb7cb2fad2ecba7261b5be15d9b8a8487007d96057c7a4696b855c006e601f0f1638f352aecbb2290c695a812419042bfd69eb25a3fb1
6
+ metadata.gz: b1bc27ac8a586b53618e7e8a2a38b70f747bcad9087ce539b38d68a5dc346ea2150620e98e22cd3e84cc9587a262da2cda0e92e13d5bea2f3c4c0d2934cfa791
7
+ data.tar.gz: 124fc7ff76f3b063ccc9d238c2516cb2abe8c2f1a9199cf1ab4181485dc1f925113a65e8a3871d83b277c558ae41656cacd04a9339fe43567f83cf55ea65b727
data/README.md CHANGED
@@ -1,34 +1,74 @@
1
- # WalkthroughAwanllm
1
+ Here's an updated README for your gem `walkthrough_awanllm`, including all necessary installation and usage instructions, as well as development and contributing guidelines.
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ ```markdown
4
+ # WalkthroughAwanllm
4
5
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/walkthrough_awanllm`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+ A Ruby gem to generate a project development walkthrough with the AwanLLM API. This gem helps you log activities and generate detailed walkthroughs of your project's lifecycle.
6
7
 
7
8
  ## Installation
8
9
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'walkthrough_awanllm'
14
+ ```
15
+
16
+ And then execute:
10
17
 
11
- Install the gem and add to the application's Gemfile by executing:
18
+ ```sh
19
+ $ bundle install
20
+ ```
12
21
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
22
+ Or install it yourself as:
14
23
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
24
+ ```sh
25
+ $ gem install walkthrough_awanllm
26
+ ```
16
27
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
28
+ ## Setup
29
+
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
+
32
+ ```sh
33
+ $ ruby ./vendor/bundle/ruby/YOUR_VERSION/gems/walkthrough_awanllm-0.1.2/bin/setup_awanllm.rb
34
+ ```
18
35
 
19
36
  ## Usage
20
37
 
21
- TODO: Write usage instructions here
38
+
39
+ ### Generating a Walkthrough
40
+
41
+ To generate a detailed walkthrough of your project's activities:
42
+
43
+ ```ruby
44
+ rails console
45
+ > awanllm = WalkthroughAwanllm::AwanLLM.new
46
+ > awanllm.generate_walkthrough
47
+ ```
48
+
49
+ This will read the activity log and generate a `walkthrough.md` file in the project's root directory.
22
50
 
23
51
  ## Development
24
52
 
25
53
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
54
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+ To install this gem onto your local machine, run:
56
+
57
+ ```sh
58
+ $ bundle exec rake install
59
+ ```
60
+
61
+ To release a new version, update the version number in `version.rb`, and then run:
62
+
63
+ ```sh
64
+ $ bundle exec rake release
65
+ ```
66
+
67
+ This will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
68
 
29
69
  ## Contributing
30
70
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/walkthrough_awanllm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/walkthrough_awanllm/blob/master/CODE_OF_CONDUCT.md).
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mruduljohn/walkthrough_awanllm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mruduljohn/walkthrough_awanllm/blob/master/CODE_OF_CONDUCT.md).
32
72
 
33
73
  ## License
34
74
 
@@ -36,4 +76,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
76
 
37
77
  ## Code of Conduct
38
78
 
39
- Everyone interacting in the WalkthroughAwanllm project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/walkthrough_awanllm/blob/master/CODE_OF_CONDUCT.md).
79
+ Everyone interacting in the WalkthroughAwanllm project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mruduljohn/walkthrough_awanllm/blob/master/CODE_OF_CONDUCT.md).
80
+ ```
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,8 @@
1
+ # lib/tasks/generate_walkthrough.rake
2
+ namespace :awanllm do
3
+ desc 'Generate walkthrough using AwanLLM'
4
+ task :generate_walkthrough => :environment do
5
+ awanllm = WalkthroughAwanllm::AwanLLM.new
6
+ awanllm.generate_walkthrough
7
+ end
8
+ end
@@ -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,3 +1,4 @@
1
+ # lib/awanllm/railtie.rb
1
2
 
2
3
  require 'rails/railtie'
3
4
  require 'fileutils'
@@ -6,6 +7,27 @@ module AwanLLM
6
7
  class Railtie < Rails::Railtie
7
8
  initializer "awanllm.track_activity" do |app|
8
9
  app.config.middleware.use AwanLLM::Tracker
10
+
11
+ setup_git_hook
12
+ end
13
+
14
+ private
15
+
16
+ def setup_git_hook
17
+ git_hook_script_path = Rails.root.join('.git', 'hooks', 'post-commit')
18
+ git_hook_script_content = <<-SCRIPT
19
+ #!/bin/bash
20
+ RAILS_ROOT="#{Rails.root}"
21
+ cd $RAILS_ROOT
22
+ bundle exec rails runner "AwanLLM::Tracker.new.update_activity_log"
23
+ SCRIPT
24
+
25
+ # Write the Git hook script
26
+ File.open(git_hook_script_path, "w") { |f| f.write(git_hook_script_content) }
27
+ FileUtils.chmod(0755, git_hook_script_path)
28
+
29
+ # Inform the user about the setup
30
+ puts "Git hook for tracking activity log updates has been set up: #{git_hook_script_path}"
9
31
  end
10
32
  end
11
33
  end
@@ -13,22 +35,31 @@ end
13
35
  # Middleware to track activities
14
36
  module AwanLLM
15
37
  class Tracker
16
- def initialize(app)
38
+ def initialize(app = nil)
17
39
  @app = app
18
40
  end
19
41
 
20
42
  def call(env)
21
43
  status, headers, response = @app.call(env)
22
- log_activity(env)
23
44
  [status, headers, response]
24
45
  end
25
46
 
26
- private
47
+ def update_activity_log
48
+ log_file_path = Rails.root.join('log', 'awanllm_activity.log')
49
+ FileUtils.mkdir_p(File.dirname(log_file_path))
50
+
51
+ # Get the latest commit details
52
+ commit_details = `git log -1 --pretty=format:"%H %an %ad %s" --date=iso`
53
+ file_changes = `git diff-tree --no-commit-id --name-status -r HEAD`
27
54
 
28
- def log_activity(env)
29
- FileUtils.mkdir_p("log")
30
- File.open("log/awanllm_activity.log", "a") do |file|
31
- file.puts("[#{Time.now}] #{env['REQUEST_METHOD']} #{env['PATH_INFO']}")
55
+ File.open(log_file_path, "a") do |file|
56
+ file.puts("### [#{Time.now}] Activity Log")
57
+ file.puts("#### Commit Details: #{commit_details.strip}")
58
+ file.puts("#### File Changes:")
59
+ file_changes.each_line do |line|
60
+ file.puts("- #{line.strip}")
61
+ end
62
+ file.puts("\n")
32
63
  end
33
64
  end
34
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WalkthroughAwanllm
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -1,83 +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
- system('ruby setup_awanllm')
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.2/bin/setup_awanllm.rb"
71
+ system("ruby #{path_to_script}")
72
+ end
67
73
  end
68
- end
69
74
 
70
- # Activate the gem automatically after installation
71
- activate!
75
+ # Activate the gem automatically after installation
76
+ activate!
72
77
 
73
- private
78
+ private
74
79
 
75
- def handle_response(response)
76
- if response.success?
77
- JSON.parse(response.body)
78
- else
79
- error_message = JSON.parse(response.body)['error']['message'] rescue response.message
80
- 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
81
87
  end
82
88
  end
83
89
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/walkthrough_awanllm/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "walkthrough_awanllm"
7
+ spec.version = WalkthroughAwanllm::VERSION
8
+ spec.authors = ["Mrudul John"]
9
+ spec.email = ["mrudulmathews@gmail.com"]
10
+
11
+ spec.summary = "A Ruby gem to Generate Project Development Walkthrough with the AwanLLM API."
12
+ spec.description = "{UNDER DEVELOPMENT NOT FOR USE YET}A Ruby gem to generate a walkthrough the project lifecycle with the AwanLLM API for generating and retrieving content."
13
+ spec.homepage = "https://github.com/mruduljohn/Walkthrough_awanllm_gem"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.0.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile]) ||
24
+ f.match(/walkthrough_awanllm-\d+\.\d+\.\d+\.gem/)
25
+ end
26
+ end + [
27
+ "lib/walkthrough_awanllm.rb",
28
+ "lib/walkthrough_awanllm/railtie.rb",
29
+ "lib/walkthrough_awanllm/version.rb",
30
+ "bin/setup_awanllm.rb", # Include setup_awanllm.rb file
31
+ "lib/tasks/generate_walkthrough.rake", # Include generate_walkthrough.rake file
32
+ ]
33
+
34
+ spec.bindir = "bin"
35
+ spec.executables = ["setup_awanllm.rb"]
36
+ spec.require_paths = ["lib"]
37
+ spec.add_dependency "httparty"
38
+ spec.add_dependency "thor"
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 13.0"
41
+ spec.add_development_dependency "minitest", "~> 5.0"
42
+ spec.post_install_message = <<-MESSAGE
43
+ Thank you for installing the Walkthrough_AwanLLM gem!
44
+ To complete the setup, please run the following command:
45
+ ruby ./vendor/bundle/ruby/#{RUBY_VERSION.split('.').first(3).join('.')}/gems/walkthrough_awanllm-#{spec.version}/bin/setup_awanllm.rb
46
+ MESSAGE
47
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: walkthrough_awanllm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mrudul John
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2024-06-06 00:00:00.000000000 Z
12
12
  dependencies:
@@ -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
@@ -66,11 +80,12 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '5.0'
69
- description: A Ruby gem to generate a walkthrough the project lifecycle with the AwanLLM
70
- API for generating and retrieving content.
83
+ description: "{UNDER DEVELOPMENT NOT FOR USE YET}A Ruby gem to generate a walkthrough
84
+ the project lifecycle with the AwanLLM API for generating and retrieving content."
71
85
  email:
72
86
  - mrudulmathews@gmail.com
73
- executables: []
87
+ executables:
88
+ - setup_awanllm.rb
74
89
  extensions: []
75
90
  extra_rdoc_files: []
76
91
  files:
@@ -80,19 +95,22 @@ files:
80
95
  - README.md
81
96
  - Rakefile
82
97
  - bin/setup_awanllm.rb
98
+ - lib/tasks/generate_walkthrough.rake
83
99
  - lib/walkthrough_awanllm.rb
100
+ - lib/walkthrough_awanllm/cli.rb
84
101
  - lib/walkthrough_awanllm/railtie.rb
85
102
  - lib/walkthrough_awanllm/version.rb
86
103
  - sig/walkthrough_awanllm.rbs
104
+ - walkthrough_awanllm.gemspec
87
105
  homepage: https://github.com/mruduljohn/Walkthrough_awanllm_gem
88
106
  licenses:
89
107
  - MIT
90
108
  metadata:
91
109
  homepage_uri: https://github.com/mruduljohn/Walkthrough_awanllm_gem
92
110
  post_install_message: |2
93
- Thank you for installing the AwanLLM gem!
111
+ Thank you for installing the Walkthrough_AwanLLM gem!
94
112
  To complete the setup, please run the following command:
95
- ruby setup_awanllm.rb
113
+ ruby ./vendor/bundle/ruby/3.3.0/gems/walkthrough_awanllm-0.1.2/bin/setup_awanllm.rb
96
114
  rdoc_options: []
97
115
  require_paths:
98
116
  - lib
@@ -110,5 +128,5 @@ requirements: []
110
128
  rubygems_version: 3.5.3
111
129
  signing_key:
112
130
  specification_version: 4
113
- summary: A Ruby gem to Generate Project Development Walthrough with the AwanLLM API.
131
+ summary: A Ruby gem to Generate Project Development Walkthrough with the AwanLLM API.
114
132
  test_files: []