walkthrough_awanllm 0.1.2 → 0.1.11
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 +4 -4
- data/README.md +12 -53
- data/Rakefile +0 -4
- data/lib/walkthrough_awanllm/railtie.rb +7 -38
- data/lib/walkthrough_awanllm/version.rb +1 -1
- data/lib/walkthrough_awanllm.rb +61 -67
- data/walkthrough_awanllm.gemspec +13 -16
- metadata +3 -19
- data/lib/tasks/generate_walkthrough.rake +0 -8
- data/lib/walkthrough_awanllm/cli.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa569e0418332a73d3c3b176db2eec63facd6ceff4bd37fb8524c09cb71eea69
|
4
|
+
data.tar.gz: 35532ba5da69b42a158601808a328be0defa3b65905e0f4ad300813362d26ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e3a0b59b472762ca4a74746f84ceab7f44da83da09879e510c3b669dc93fcc9741514bfd364e40764c3ffe7b841bcb0f78a578d87d60ad1e42f6b1288e90500
|
7
|
+
data.tar.gz: c8893a61c9c521dfff2aea0d7e97f800cb6c8018c3e74fb6a5bcf13da84a87db11ee0a5b0fa14a061f5b0b941e87af022c74c210ca4fabd7a470a9fdfa1be6e6
|
data/README.md
CHANGED
@@ -1,74 +1,34 @@
|
|
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
|
-
|
3
|
-
```markdown
|
4
1
|
# WalkthroughAwanllm
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
Add this line to your application's Gemfile:
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
11
4
|
|
12
|
-
|
13
|
-
gem 'walkthrough_awanllm'
|
14
|
-
```
|
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.
|
15
6
|
|
16
|
-
|
17
|
-
|
18
|
-
```sh
|
19
|
-
$ bundle install
|
20
|
-
```
|
7
|
+
## Installation
|
21
8
|
|
22
|
-
|
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.
|
23
10
|
|
24
|
-
|
25
|
-
$ gem install walkthrough_awanllm
|
26
|
-
```
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
27
12
|
|
28
|
-
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
29
14
|
|
30
|
-
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
31
16
|
|
32
|
-
|
33
|
-
$ ruby ./vendor/bundle/ruby/YOUR_VERSION/gems/walkthrough_awanllm-0.1.2/bin/setup_awanllm.rb
|
34
|
-
```
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
35
18
|
|
36
19
|
## Usage
|
37
20
|
|
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.
|
21
|
+
TODO: Write usage instructions here
|
50
22
|
|
51
23
|
## Development
|
52
24
|
|
53
25
|
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.
|
54
26
|
|
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).
|
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).
|
68
28
|
|
69
29
|
## Contributing
|
70
30
|
|
71
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
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).
|
72
32
|
|
73
33
|
## License
|
74
34
|
|
@@ -76,5 +36,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
76
36
|
|
77
37
|
## Code of Conduct
|
78
38
|
|
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/
|
80
|
-
```
|
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).
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# lib/awanllm/railtie.rb
|
2
1
|
|
3
2
|
require 'rails/railtie'
|
4
3
|
require 'fileutils'
|
@@ -7,27 +6,6 @@ module AwanLLM
|
|
7
6
|
class Railtie < Rails::Railtie
|
8
7
|
initializer "awanllm.track_activity" do |app|
|
9
8
|
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}"
|
31
9
|
end
|
32
10
|
end
|
33
11
|
end
|
@@ -35,31 +13,22 @@ end
|
|
35
13
|
# Middleware to track activities
|
36
14
|
module AwanLLM
|
37
15
|
class Tracker
|
38
|
-
def initialize(app
|
16
|
+
def initialize(app)
|
39
17
|
@app = app
|
40
18
|
end
|
41
19
|
|
42
20
|
def call(env)
|
43
21
|
status, headers, response = @app.call(env)
|
22
|
+
log_activity(env)
|
44
23
|
[status, headers, response]
|
45
24
|
end
|
46
25
|
|
47
|
-
|
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`
|
26
|
+
private
|
54
27
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
file.puts("
|
59
|
-
file_changes.each_line do |line|
|
60
|
-
file.puts("- #{line.strip}")
|
61
|
-
end
|
62
|
-
file.puts("\n")
|
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']}")
|
63
32
|
end
|
64
33
|
end
|
65
34
|
end
|
data/lib/walkthrough_awanllm.rb
CHANGED
@@ -1,89 +1,83 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'json'
|
3
|
-
|
4
|
-
require_relative "walkthrough_awanllm/version"
|
5
|
-
require_relative "walkthrough_awanllm/railtie" if defined?(Rails)
|
3
|
+
require 'walkthorugh_awanllm/railtie' if defined?(Rails)
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
base_uri 'https://api.awanllm.com/v1'
|
5
|
+
class AwanLLM
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'https://api.awanllm.com/v1'
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
@headers = {
|
23
|
-
'Content-Type' => 'application/json',
|
24
|
-
'Authorization' => "Bearer #{@api_key}"
|
25
|
-
}
|
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
|
26
17
|
end
|
27
18
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
19
|
+
@headers = {
|
20
|
+
'Content-Type' => 'application/json',
|
21
|
+
'Authorization' => "Bearer #{@api_key}"
|
22
|
+
}
|
23
|
+
end
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
|
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)
|
37
30
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
31
|
+
response = self.class.post('/completions', headers: @headers, body: payload.to_json)
|
32
|
+
handle_response(response)
|
33
|
+
end
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
def retrieve_content(content_id)
|
36
|
+
response = self.class.get("/completions/#{content_id}", headers: @headers)
|
37
|
+
handle_response(response)
|
38
|
+
end
|
39
|
+
|
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."
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
options = {
|
45
|
+
temperature: 0.7,
|
46
|
+
top_p: 0.9,
|
47
|
+
max_tokens: 1024
|
48
|
+
}
|
52
49
|
|
53
|
-
|
54
|
-
|
50
|
+
response = generate_content(nil, prompt, options)
|
51
|
+
walkthrough = response['choices'][0]['text']
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
end
|
53
|
+
File.open("walkthrough.md", "w") do |file|
|
54
|
+
file.write(walkthrough)
|
59
55
|
end
|
56
|
+
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
def self.activate!
|
59
|
+
require 'fileutils'
|
60
|
+
require 'json'
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
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')
|
73
67
|
end
|
68
|
+
end
|
74
69
|
|
75
|
-
|
76
|
-
|
70
|
+
# Activate the gem automatically after installation
|
71
|
+
activate!
|
77
72
|
|
78
|
-
|
73
|
+
private
|
79
74
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
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}"
|
87
81
|
end
|
88
82
|
end
|
89
83
|
end
|
data/walkthrough_awanllm.gemspec
CHANGED
@@ -3,45 +3,42 @@
|
|
3
3
|
require_relative "lib/walkthrough_awanllm/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "walkthrough_awanllm"
|
7
|
+
spec.version = WalkthroughAwanllm::VERSION
|
8
|
+
spec.authors = ["Mrudul John"]
|
9
|
+
spec.email = ["mrudulmathews@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
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
15
|
spec.required_ruby_version = ">= 3.0.0"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files =
|
22
|
-
|
23
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
|
24
|
-
f.match(/walkthrough_awanllm-\d+\.\d+\.\d+\.gem/)
|
21
|
+
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
|
22
|
+
ls.readlines("\x0", chomp: true).reject do |f|
|
23
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
|
25
24
|
end
|
26
25
|
end + [
|
27
26
|
"lib/walkthrough_awanllm.rb",
|
28
27
|
"lib/walkthrough_awanllm/railtie.rb",
|
29
28
|
"lib/walkthrough_awanllm/version.rb",
|
30
29
|
"bin/setup_awanllm.rb", # Include setup_awanllm.rb file
|
31
|
-
"lib/tasks/generate_walkthrough.rake", # Include generate_walkthrough.rake file
|
32
30
|
]
|
33
31
|
|
34
32
|
spec.bindir = "bin"
|
35
33
|
spec.executables = ["setup_awanllm.rb"]
|
36
34
|
spec.require_paths = ["lib"]
|
37
35
|
spec.add_dependency "httparty"
|
38
|
-
spec.add_dependency "thor"
|
39
36
|
spec.add_development_dependency "bundler", "~> 2.0"
|
40
37
|
spec.add_development_dependency "rake", "~> 13.0"
|
41
38
|
spec.add_development_dependency "minitest", "~> 5.0"
|
42
39
|
spec.post_install_message = <<-MESSAGE
|
43
|
-
Thank you for installing the
|
40
|
+
Thank you for installing the AwanLLM gem!
|
44
41
|
To complete the setup, please run the following command:
|
45
|
-
|
42
|
+
setup_awanllm
|
46
43
|
MESSAGE
|
47
44
|
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.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mrudul John
|
@@ -24,20 +24,6 @@ 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'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,9 +81,7 @@ files:
|
|
95
81
|
- README.md
|
96
82
|
- Rakefile
|
97
83
|
- bin/setup_awanllm.rb
|
98
|
-
- lib/tasks/generate_walkthrough.rake
|
99
84
|
- lib/walkthrough_awanllm.rb
|
100
|
-
- lib/walkthrough_awanllm/cli.rb
|
101
85
|
- lib/walkthrough_awanllm/railtie.rb
|
102
86
|
- lib/walkthrough_awanllm/version.rb
|
103
87
|
- sig/walkthrough_awanllm.rbs
|
@@ -108,9 +92,9 @@ licenses:
|
|
108
92
|
metadata:
|
109
93
|
homepage_uri: https://github.com/mruduljohn/Walkthrough_awanllm_gem
|
110
94
|
post_install_message: |2
|
111
|
-
Thank you for installing the
|
95
|
+
Thank you for installing the AwanLLM gem!
|
112
96
|
To complete the setup, please run the following command:
|
113
|
-
|
97
|
+
setup_awanllm
|
114
98
|
rdoc_options: []
|
115
99
|
require_paths:
|
116
100
|
- lib
|
@@ -1,15 +0,0 @@
|
|
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
|
-
|