smart_prompt 0.3.5 → 0.3.7
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/CHANGELOG.md +5 -1
- data/README.cn.md +24 -5
- data/README.md +24 -5
- data/lib/smart_prompt/conversation.rb +18 -1
- data/lib/smart_prompt/engine.rb +3 -1
- data/lib/smart_prompt/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73b96899662e077a376cf72e79fe1e65108a2051fcc719587f5a7ab5d5253f63
|
|
4
|
+
data.tar.gz: 6a4236130a8fe4ebf55e1b9ca4c99aa90d118db961042002fb86406f25771623
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 562301cafa00d0b15d808c17f20a19f8eab5bde695117cc025ee79d32d4129c4f5f55b185bb5bf83d3d3e59e72e85f3ac58cd120823a7a42e15c3b98dc592aff
|
|
7
|
+
data.tar.gz: 4dfa53f9b7e30259fb088fa016f54419e087b4e5a0c3f1a26ee8d826479bb8e9d3e27eda712cf2114892e9ccc162846232fd5a56048378adc915026e7be8a0c5
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.6] - 2026-04-08
|
|
9
|
+
### Changed
|
|
10
|
+
- Bumped `ruby-openai` dependency from `8.1.0` to `8.3.0`
|
|
11
|
+
|
|
8
12
|
## [0.3.2] - 2025-05-18
|
|
9
13
|
### Added
|
|
10
14
|
- Initial CHANGELOG.md file
|
|
@@ -34,4 +38,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
34
38
|
- Initial gem release
|
|
35
39
|
- Llama.cpp adapter
|
|
36
40
|
- Basic configuration parameters
|
|
37
|
-
- Environment bug fixes
|
|
41
|
+
- Environment bug fixes
|
data/README.cn.md
CHANGED
|
@@ -68,7 +68,7 @@ llms:
|
|
|
68
68
|
url: https://api.siliconflow.cn/v1/
|
|
69
69
|
api_key: ENV["APIKey"]
|
|
70
70
|
default_model: Qwen/Qwen2.5-7B-Instruct
|
|
71
|
-
|
|
71
|
+
local:
|
|
72
72
|
adapter: openai
|
|
73
73
|
url: http://localhost:8080/
|
|
74
74
|
ollama:
|
|
@@ -81,6 +81,15 @@ llms:
|
|
|
81
81
|
api_key: ENV["DSKEY"]
|
|
82
82
|
default_model: deepseek-reasoner
|
|
83
83
|
|
|
84
|
+
# 模型别名配置
|
|
85
|
+
models:
|
|
86
|
+
local/qwen3.5:
|
|
87
|
+
use: local
|
|
88
|
+
model: qwen3.5
|
|
89
|
+
deepseekv3.2:
|
|
90
|
+
use: SiliconFlow
|
|
91
|
+
model: Pro/deepseek-ai/DeepSeek-V3.2
|
|
92
|
+
|
|
84
93
|
# 默认设置
|
|
85
94
|
default_llm: SiliconFlow
|
|
86
95
|
template_path: "./templates"
|
|
@@ -108,9 +117,8 @@ logger_file: "./logs/smart_prompt.log"
|
|
|
108
117
|
**workers/chat_worker.rb**:
|
|
109
118
|
```ruby
|
|
110
119
|
SmartPrompt.define_worker :chat_assistant do
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
model "deepseek-ai/DeepSeek-V3"
|
|
120
|
+
# 使用配置好的模型别名
|
|
121
|
+
use_model "deepseekv3.2"
|
|
114
122
|
# 设置系统消息
|
|
115
123
|
sys_msg("你是一个有用的 AI 助手。", params)
|
|
116
124
|
# 使用模板和参数
|
|
@@ -274,6 +282,17 @@ llms:
|
|
|
274
282
|
# 其他提供商特定选项
|
|
275
283
|
```
|
|
276
284
|
|
|
285
|
+
### 模型别名配置
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
models:
|
|
289
|
+
model_alias:
|
|
290
|
+
use: "llm_name"
|
|
291
|
+
model: "model_identifier"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
在 worker 中,`use_model "model_alias"` 等价于调用 `use "llm_name"` 和 `model "model_identifier"`。
|
|
295
|
+
|
|
277
296
|
### 路径配置
|
|
278
297
|
|
|
279
298
|
```yaml
|
|
@@ -391,4 +410,4 @@ end
|
|
|
391
410
|
|
|
392
411
|
---
|
|
393
412
|
|
|
394
|
-
**SmartPrompt** - 让 Ruby 应用中的 LLM 集成变得简单、强大且优雅。
|
|
413
|
+
**SmartPrompt** - 让 Ruby 应用中的 LLM 集成变得简单、强大且优雅。
|
data/README.md
CHANGED
|
@@ -68,7 +68,7 @@ llms:
|
|
|
68
68
|
url: https://api.siliconflow.cn/v1/
|
|
69
69
|
api_key: ENV["APIKey"]
|
|
70
70
|
default_model: Qwen/Qwen2.5-7B-Instruct
|
|
71
|
-
|
|
71
|
+
local:
|
|
72
72
|
adapter: openai
|
|
73
73
|
url: http://localhost:8080/
|
|
74
74
|
ollama:
|
|
@@ -81,6 +81,15 @@ llms:
|
|
|
81
81
|
api_key: ENV["DSKEY"]
|
|
82
82
|
default_model: deepseek-reasoner
|
|
83
83
|
|
|
84
|
+
# Model aliases
|
|
85
|
+
models:
|
|
86
|
+
local/qwen3.5:
|
|
87
|
+
use: local
|
|
88
|
+
model: qwen3.5
|
|
89
|
+
deepseekv3.2:
|
|
90
|
+
use: SiliconFlow
|
|
91
|
+
model: Pro/deepseek-ai/DeepSeek-V3.2
|
|
92
|
+
|
|
84
93
|
# Default settings
|
|
85
94
|
default_llm: SiliconFlow
|
|
86
95
|
template_path: "./templates"
|
|
@@ -108,9 +117,8 @@ Create worker files in your `workers/` directory:
|
|
|
108
117
|
**workers/chat_worker.rb**:
|
|
109
118
|
```ruby
|
|
110
119
|
SmartPrompt.define_worker :chat_assistant do
|
|
111
|
-
# Use a
|
|
112
|
-
|
|
113
|
-
model "deepseek-ai/DeepSeek-V3"
|
|
120
|
+
# Use a configured model alias
|
|
121
|
+
use_model "deepseekv3.2"
|
|
114
122
|
# Set system message
|
|
115
123
|
sys_msg("You are a helpful AI assistant.", params)
|
|
116
124
|
# Use template with parameters
|
|
@@ -274,6 +282,17 @@ llms:
|
|
|
274
282
|
# Additional provider-specific options
|
|
275
283
|
```
|
|
276
284
|
|
|
285
|
+
### Model Alias Configuration
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
models:
|
|
289
|
+
model_alias:
|
|
290
|
+
use: "llm_name"
|
|
291
|
+
model: "model_identifier"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
In a worker, `use_model "model_alias"` is equivalent to calling `use "llm_name"` and `model "model_identifier"`.
|
|
295
|
+
|
|
277
296
|
### Path Configuration
|
|
278
297
|
|
|
279
298
|
```yaml
|
|
@@ -391,4 +410,4 @@ This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.t
|
|
|
391
410
|
|
|
392
411
|
---
|
|
393
412
|
|
|
394
|
-
**SmartPrompt** - Making LLM integration in Ruby applications simple, powerful, and elegant.
|
|
413
|
+
**SmartPrompt** - Making LLM integration in Ruby applications simple, powerful, and elegant.
|
|
@@ -14,6 +14,7 @@ module SmartPrompt
|
|
|
14
14
|
@engine = engine
|
|
15
15
|
@adapters = engine.adapters
|
|
16
16
|
@llms = engine.llms
|
|
17
|
+
@models = engine.models
|
|
17
18
|
@current_llm_name = nil
|
|
18
19
|
@templates = engine.templates
|
|
19
20
|
@temperature = 0.7
|
|
@@ -23,12 +24,28 @@ module SmartPrompt
|
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def use(llm_name)
|
|
26
|
-
|
|
27
|
+
llm_name = llm_name.to_s
|
|
28
|
+
raise ConfigurationError, "LLM #{llm_name} not configured" unless @llms.key?(llm_name)
|
|
27
29
|
@current_llm = @llms[llm_name]
|
|
28
30
|
@current_llm_name = llm_name
|
|
29
31
|
self
|
|
30
32
|
end
|
|
31
33
|
|
|
34
|
+
def use_model(model_name)
|
|
35
|
+
model_name = model_name.to_s
|
|
36
|
+
model_config = @models[model_name] || @models[model_name.to_sym]
|
|
37
|
+
raise ConfigurationError, "Model #{model_name} not configured" unless model_config
|
|
38
|
+
|
|
39
|
+
llm_name = model_config["use"] || model_config[:use]
|
|
40
|
+
configured_model_name = model_config["model"] || model_config[:model]
|
|
41
|
+
raise ConfigurationError, "Model #{model_name} must define use" if llm_name.nil? || llm_name.empty?
|
|
42
|
+
raise ConfigurationError, "Model #{model_name} must define model" if configured_model_name.nil? || configured_model_name.empty?
|
|
43
|
+
|
|
44
|
+
use(llm_name)
|
|
45
|
+
model(configured_model_name)
|
|
46
|
+
self
|
|
47
|
+
end
|
|
48
|
+
|
|
32
49
|
def model(model_name)
|
|
33
50
|
@model_name = model_name
|
|
34
51
|
end
|
data/lib/smart_prompt/engine.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module SmartPrompt
|
|
2
2
|
class Engine
|
|
3
|
-
attr_reader :config_file, :config, :adapters, :current_adapter, :llms, :templates
|
|
3
|
+
attr_reader :config_file, :config, :adapters, :current_adapter, :llms, :models, :templates
|
|
4
4
|
attr_reader :stream_response
|
|
5
5
|
|
|
6
6
|
def initialize(config_file)
|
|
7
7
|
@config_file = config_file
|
|
8
8
|
@adapters = {}
|
|
9
9
|
@llms = {}
|
|
10
|
+
@models = {}
|
|
10
11
|
@templates = {}
|
|
11
12
|
@current_workers = {}
|
|
12
13
|
@history_messages = []
|
|
@@ -64,6 +65,7 @@ module SmartPrompt
|
|
|
64
65
|
SmartPrompt.logger = Logger.new(@config["logger_file"])
|
|
65
66
|
end
|
|
66
67
|
SmartPrompt.logger.info "Loading configuration from file: #{config_file}"
|
|
68
|
+
@models = @config["models"] || {}
|
|
67
69
|
@config["adapters"].each do |adapter_name, adapter_class|
|
|
68
70
|
adapter_class = SmartPrompt.const_get(adapter_class)
|
|
69
71
|
@adapters[adapter_name] = adapter_class
|
data/lib/smart_prompt/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smart_prompt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- zhuang biaowei
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 8.
|
|
32
|
+
version: 8.3.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 8.
|
|
39
|
+
version: 8.3.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: json
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: '0'
|
|
139
139
|
requirements: []
|
|
140
|
-
rubygems_version: 4.0.
|
|
140
|
+
rubygems_version: 4.0.10
|
|
141
141
|
specification_version: 4
|
|
142
142
|
summary: A smart prompt management and LLM interaction gem
|
|
143
143
|
test_files: []
|