spectre_ai 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/lib/spectre/prompt.rb +29 -2
- data/lib/spectre/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07e44eac15c5b58b13b2dbbb784f1ca4d5364d6aed7f2fe5a5d797c0ee5fd43d
|
4
|
+
data.tar.gz: 3d33fb9b5c228eb4577f678d5e2f310d401671cd242b0ca02bcf9a80df55fad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17c0de5cfb63e7d072e1c85d221abbdadabd2eb131276b22ceff834c7eaea05ce3a2a1a02c826887d39b54619c8841d651a7aaa3823a5eabf4f0f3faaf5c263e
|
7
|
+
data.tar.gz: 14ffff5c963ea79c2360e9517c9906f36b3bc27494732c3f3bd640c0f492aacdd0bdaf190be2effd5bbb9bc875315afe441c8583c07f3ff2faf6f7a8cdcdcceb
|
data/CHANGELOG.md
CHANGED
@@ -70,7 +70,7 @@ This version enhances the flexibility and robustness of the Completions class, e
|
|
70
70
|
|
71
71
|
# Changelog for Version 1.1.1
|
72
72
|
|
73
|
-
**Release Date:** [
|
73
|
+
**Release Date:** [10th Oct 2024]
|
74
74
|
|
75
75
|
**New Features:**
|
76
76
|
|
@@ -81,3 +81,16 @@ This version enhances the flexibility and robustness of the Completions class, e
|
|
81
81
|
Spectre::Prompt.render(template: 'classification/intent/user', locals: { query: 'What is AI?' })
|
82
82
|
```
|
83
83
|
* This feature allows for better organization and scalability when dealing with multiple prompt categories and complex scenarios.
|
84
|
+
|
85
|
+
|
86
|
+
# Changelog for Version 1.1.2
|
87
|
+
|
88
|
+
**Release Date:** [11th Oct 2024]
|
89
|
+
|
90
|
+
**New Features:**
|
91
|
+
|
92
|
+
* **Dynamic Project Root Detection for Prompts**
|
93
|
+
* The `Spectre::Prompt.render` method now dynamically detects the project root based on the presence of project-specific markers, such as `Gemfile`, `.git`, or `config/application.rb`.
|
94
|
+
* This change allows for greater flexibility when using spectre in different environments and projects, ensuring the prompt templates are found regardless of where spectre is used.
|
95
|
+
* **Example**: If you're using `spectre` inside a gem, the `detect_prompts_path` method will now correctly resolve the prompts path within the gem project root.
|
96
|
+
* If no markers are found, the system falls back to the current working directory (`Dir.pwd`).
|
data/lib/spectre/prompt.rb
CHANGED
@@ -9,7 +9,7 @@ module Spectre
|
|
9
9
|
attr_reader :prompts_path
|
10
10
|
|
11
11
|
def prompts_path
|
12
|
-
@prompts_path
|
12
|
+
@prompts_path = detect_prompts_path
|
13
13
|
end
|
14
14
|
|
15
15
|
# Render a prompt by reading and rendering the YAML template
|
@@ -50,7 +50,34 @@ module Spectre
|
|
50
50
|
|
51
51
|
# Detects the appropriate path for prompt templates
|
52
52
|
def detect_prompts_path
|
53
|
-
|
53
|
+
# Find the first non-spectre, non-ruby core file in the call stack
|
54
|
+
calling_file = caller.find do |path|
|
55
|
+
!path.include?('/spectre/') && !path.include?(RbConfig::CONFIG['rubylibdir'])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Determine the directory from where spectre was invoked
|
59
|
+
start_dir = calling_file ? File.dirname(calling_file) : Dir.pwd
|
60
|
+
|
61
|
+
# Traverse up until we find a Gemfile (or another marker of the project root)
|
62
|
+
project_root = find_project_root(start_dir)
|
63
|
+
|
64
|
+
# Return the prompts path based on the detected project root
|
65
|
+
File.join(project_root, 'app', 'spectre', 'prompts')
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_project_root(dir)
|
69
|
+
while dir != '/' do
|
70
|
+
# Check for Gemfile, .git directory, or config/application.rb (Rails)
|
71
|
+
return dir if File.exist?(File.join(dir, 'Gemfile')) ||
|
72
|
+
File.exist?(File.join(dir, 'config', 'application.rb')) ||
|
73
|
+
File.directory?(File.join(dir, '.git'))
|
74
|
+
|
75
|
+
# Move up one directory
|
76
|
+
dir = File.expand_path('..', dir)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Default fallback if no root markers are found
|
80
|
+
Dir.pwd
|
54
81
|
end
|
55
82
|
|
56
83
|
# Split the template parameter into path and prompt
|
data/lib/spectre/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectre_ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Klapatok
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-10-
|
12
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|