smart_prompt 0.2.5 → 0.2.6

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: 86a2bebbb6e978a1303026f2a04984efe52c7dc875a5adb3beb6c622e1bfa88f
4
- data.tar.gz: 60d974ea4c782d2f8e885bd08f357e82fef1771774cc968819df46ac67886db5
3
+ metadata.gz: 56515cf9de791bf1f22a118499288e5c33b9a196db07b8bdd07c5ab7a6478bd4
4
+ data.tar.gz: 8b7f0c41cdd7e0d64773c9359d8c195419bf317f5f1180747a1e0de6fa9b46f4
5
5
  SHA512:
6
- metadata.gz: 68938c2e1570976a910054d9c89447605ee10b393fc9fa030b39127885ba73ca037d7b6253f35e77d5efc2cd325e3ea4689994d98ff23f46b99ad9a4cc3761d4
7
- data.tar.gz: ec5ca8216aab675dacafe426d60cfdaba6171dfd0922ffc12544e7dc83fdfae0157fb11b47d00a8b791e2cc20e181044604634dac236e6346fda2d5adeb0a2e9
6
+ metadata.gz: aa9dad1da9848cbfbed54f116f5c7290a4e41383ffc546a8e415b8cf6ff2e637ef99b6df72875e81c95d7f23ffff986aa2f9dbf825ca2ca531253014db633087
7
+ data.tar.gz: 96f15a6c1d9ecb13ab8705a2acbea4bbe2661dc9af215046a8c15209a04060f2e57f351365682267419604229ccd49a28a51b1ea0aa3b081deccde9347620288
@@ -37,28 +37,30 @@ module SmartPrompt
37
37
  @engine.history_messages
38
38
  end
39
39
 
40
- def add_message(msg)
41
- history_messages << msg
40
+ def add_message(msg, with_history = false)
41
+ if with_history
42
+ history_messages << msg
43
+ end
42
44
  @messages << msg
43
45
  end
44
46
 
45
- def prompt(template_name, params = {})
47
+ def prompt(template_name, params = {}, with_history = false)
46
48
  if template_name.class == Symbol
47
49
  template_name = template_name.to_s
48
50
  SmartPrompt.logger.info "Use template #{template_name}"
49
51
  raise "Template #{template_name} not found" unless @templates.key?(template_name)
50
52
  content = @templates[template_name].render(params)
51
- add_message({ role: "user", content: content })
53
+ add_message({ role: "user", content: content }, with_history)
52
54
  self
53
55
  else
54
- add_message({ role: "user", content: template_name })
56
+ add_message({ role: "user", content: template_name }, with_history)
55
57
  self
56
58
  end
57
59
  end
58
60
 
59
- def sys_msg(message)
61
+ def sys_msg(message, params)
60
62
  @sys_msg = message
61
- add_message({ role: "system", content: message })
63
+ add_message({ role: "system", content: message }, params[:with_history])
62
64
  self
63
65
  end
64
66
 
@@ -1,3 +1,3 @@
1
1
  module SmartPrompt
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -49,6 +49,10 @@ module SmartPrompt
49
49
  else
50
50
  @conversation.send_msg_by_stream(params, &@proc)
51
51
  end
52
+ elsif method == :sys_msg
53
+ @conversation.sys_msg(*args, params)
54
+ elsif method == :prompt
55
+ @conversation.prompt(*args, params[:with_history])
52
56
  else
53
57
  @conversation.send(method, *args, &block)
54
58
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_prompt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhuang biaowei
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-06 00:00:00.000000000 Z
10
+ date: 2025-04-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: yaml