walkthrough_awanllm 0.1.20 → 0.2.1

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: ec195b8ba320b5775eca40fe298a17296c4d0d606d9d7033d39b264b6623d4f5
4
- data.tar.gz: b6868fe445362fd7b32aebc703fe6cde3c114347949403c5346bb1a218721ab0
3
+ metadata.gz: 68d5a72fd33467b8273115af0ae452b318116cc161904be735c7ee8f8b34ece1
4
+ data.tar.gz: bfd7e8948893c4bd5b7f7b346a5bd5c15748ca9aaf10abcff461531d53508ae8
5
5
  SHA512:
6
- metadata.gz: d77f4ac5afe4d1739275124108ef41e7a0c2ab8b643c7d5a3b05cbd47fb45c879a2a52f877e3cf1abb318528ef45632944e824b2dc5781f456bc1fe2e1dea976
7
- data.tar.gz: 7e36f89303d7db1a751cf38705362ef8398135d7815eb6a9f81e6f9ade05885218dbf3abaffdd9ee20c16a9695cdd7f593a0800febdf2a090fad153fe3077cc3
6
+ metadata.gz: '087e951d1058073fc1c0560bd4e9b34c304385cf648d576fe6499ad138467ac4a48f34c4ff31463ab194ae3e835f613e48f3a3072dc2c3f094b68c23d642ba86'
7
+ data.tar.gz: 00555f3514d2acb4da15e95b69de5268d2dbc6ecc53ed147cb82717a4ba79747fa43747563f54c798dd359ebc2a2c0db6502a98b1e47c99471dff530f1b2d065
data/README.md CHANGED
@@ -30,7 +30,7 @@ $ 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.20/bin/setup_awanllm.rb
33
+ $ ruby ./vendor/bundle/ruby/YOUR_VERSION/gems/walkthrough_awanllm-0.2.1/bin/setup_awanllm.rb
34
34
  ```
35
35
 
36
36
  ## Usage
@@ -45,7 +45,7 @@ rails console
45
45
  > awanllm = WalkthroughAwanllm::AwanLLM.new
46
46
  > awanllm.generate_walkthrough
47
47
  ```
48
- Or by running :
48
+ (IF ABOVE IS NOT WORKING) by running :
49
49
  ```ruby
50
50
  rails awanllm:generate_walkthrough
51
51
  ```
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WalkthroughAwanllm
4
- VERSION = "0.1.20"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require 'httparty'
2
2
  require 'json'
3
+ require 'fileutils'
3
4
  require_relative "walkthrough_awanllm/cli"
4
5
  require_relative "walkthrough_awanllm/version"
5
6
  require_relative "walkthrough_awanllm/railtie" if defined?(Rails)
@@ -42,20 +43,83 @@ module WalkthroughAwanllm
42
43
 
43
44
  def generate_walkthrough
44
45
  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."
46
+ commits = split_by_commits(activities)
46
47
 
47
- options = {
48
- temperature: 0.7,
49
- top_p: 0.9,
50
- max_tokens: 1024
51
- }
48
+ # Read the last processed commit hash from file
49
+ last_commit_file = "last_processed_commit.txt"
50
+ last_processed_commit = read_last_processed_commit(last_commit_file)
51
+
52
+ # Find the index of the last processed commit
53
+ start_index = commits.index { |commit| commit.include?(last_processed_commit) }
54
+ start_index = start_index.nil? ? 0 : start_index + 1 # Start from the next commit
55
+
56
+ # Extract new commits
57
+ new_commits = commits[start_index..-1] || []
58
+ return if new_commits.empty?
59
+
60
+ prompt_template = <<~PROMPT
61
+ Here is a log of activities for a specific git commit: {{commit}}.
62
+ Using this log, generate a detailed walkthrough for this commit. This walkthrough should be narrated from the first-person perspective of the developer, resembling a personal diary or story. It must include the following:
63
+ - Personal Insights: Capture the developer's thoughts, decisions, and reflections during this commit.
64
+ - Challenges: Describe any difficulties or obstacles faced and how they were resolved or worked around.
65
+ - Technical Details: Provide detailed explanations of the technical aspects and steps involved, including relevant code snippets.
66
+ - Reasoning: Explain the reasoning behind major decisions during this commit, such as choosing specific tools, technologies, or methods.
67
+ - Step-by-Step Process: Offer a structured guide through the entire commit process.
68
+ - Lessons Learned: Conclude with insights or lessons learned from this commit, including what could be done differently in future commits.
69
+ Ensure the walkthrough is thorough, engaging, and informative, offering a deep dive into the developer's journey during this commit.
70
+ PROMPT
71
+
72
+ walkthrough = ""
52
73
 
53
- response = generate_content(nil, prompt, options)
54
- walkthrough = response['choices'][0]['text']
74
+ new_commits.each do |commit|
75
+ prompt = prompt_template.gsub("{{commit}}", commit)
76
+ options = {
77
+ temperature: 0.7,
78
+ top_p: 0.9,
79
+ max_tokens: 2048 # Adjust if your model supports more tokens
80
+ }
55
81
 
56
- File.open("walkthrough.md", "w") do |file|
57
- file.write(walkthrough)
82
+ response = generate_content(nil, prompt, options)
83
+ commit_walkthrough = response['choices'][0]['text']
84
+
85
+ walkthrough += commit_walkthrough + "\n\n"
58
86
  end
87
+
88
+ # Append to the file only if it exists
89
+ if File.exist?("walkthrough.md")
90
+ File.open("walkthrough.md", "a") do |file|
91
+ file.puts("\n")
92
+ file.puts(walkthrough)
93
+ end
94
+ else
95
+ File.write("walkthrough.md", walkthrough)
96
+ end
97
+
98
+ # Update the last processed commit hash
99
+ update_last_processed_commit(last_commit_file, extract_commit_hash(new_commits.last))
100
+ end
101
+
102
+
103
+ # Method to split the log by git commits
104
+ def split_by_commits(log_content)
105
+ log_content.scan(/#### Commit Details:.*?(?=(### \[|\z))/m).map(&:strip)
106
+ end
107
+
108
+ # Read the last processed commit from file
109
+ def read_last_processed_commit(file)
110
+ return nil unless File.exist?(file)
111
+ File.read(file).strip
112
+ end
113
+
114
+ # Update the last processed commit in file
115
+ def update_last_processed_commit(file, commit_hash)
116
+ File.write(file, commit_hash)
117
+ end
118
+
119
+ # Extract the commit hash from a commit section
120
+ def extract_commit_hash(commit_section)
121
+ match = commit_section.match(/#### Commit Details: (\w+)/)
122
+ match[1] if match
59
123
  end
60
124
 
61
125
  def self.activate!
@@ -67,7 +131,7 @@ module WalkthroughAwanllm
67
131
  puts 'Walkthrough_AwanLLM gem is already configured.'
68
132
  else
69
133
  ruby_version = RUBY_VERSION.split('.').first(3).join('.')
70
- path_to_script = "./vendor/bundle/ruby/#{ruby_version}/gems/walkthrough_awanllm-0.1.20/bin/setup_awanllm.rb"
134
+ path_to_script = "./vendor/bundle/ruby/#{ruby_version}/gems/walkthrough_awanllm-0.2.1/bin/setup_awanllm.rb"
71
135
  system("ruby #{path_to_script}")
72
136
  end
73
137
  end
@@ -85,5 +149,6 @@ module WalkthroughAwanllm
85
149
  raise "Error: #{response.code} - #{error_message}"
86
150
  end
87
151
  end
152
+
88
153
  end
89
154
  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.20
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mrudul John
@@ -110,7 +110,7 @@ metadata:
110
110
  post_install_message: |2
111
111
  Thank you for installing the Walkthrough_AwanLLM gem!
112
112
  To complete the setup, please run the following command:
113
- ruby ./vendor/bundle/ruby/3.3.0/gems/walkthrough_awanllm-0.1.20/bin/setup_awanllm.rb
113
+ ruby ./vendor/bundle/ruby/3.3.0/gems/walkthrough_awanllm-0.2.1/bin/setup_awanllm.rb
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib