newsman 1.2.1 → 1.2.2

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: 28993b9f11754759d159a42a76b5979bec9c12980098de771abd5442fc124ccd
4
- data.tar.gz: 1e98570b8d3b0cb9b0694472e5fefa7fe780ce6434efa12cd231dfa86a31c885
3
+ metadata.gz: '0166813d55623364efd38ff1f3bc83ff3ae76ee9d793b1b5ac52924477122135'
4
+ data.tar.gz: 48d3c00284b0973851b95c2b144fe50972f801deeb826b400ab31e87102b7cfc
5
5
  SHA512:
6
- metadata.gz: a807c540f352124e1a89d485cccfb2f0cf6ff36300b42d57ebb591b5e3e4b03d12413325f69a75d7f99e309c0813d336b1c3e32bb71012e22dd1093129cee5a6
7
- data.tar.gz: 81a635a5caba68596e9c3acd7a242fbf597da0cb06ce87c2103cdab84c1e2e89ef59ec9812e997ff970a0484a16ace406415a83b8c642f6db8ff0f82e571c111
6
+ metadata.gz: 193cf28ea41b994cab278212cc255dcf0d1f7b78570e631f68e17003d489d505fd0e12a8b3244d576fa1e0826d992ead7af9c1febefd80074dc8260174294dae
7
+ data.tar.gz: 4e3a9c5920d471c3c5a1dcabe16692a6154ea50d44adaf775d263ce04186e814068391555d3e90682b043dbb2b3c4fb0372da2f8fa7e91abf331a594bfefe4e7
data/README.md CHANGED
@@ -98,6 +98,25 @@ newsman --help
98
98
  ```
99
99
  And you should see a welcome message from newsman.
100
100
 
101
+ ## Releases
102
+
103
+ Releases are handled by the [`release.yaml`](.github/workflows/release.yaml) GitHub Actions workflow. It runs whenever a tag matching `v*.*.*` (e.g. `v1.2.1`) is pushed, or manually via `workflow_dispatch`. On trigger it:
104
+
105
+ 1. Runs the test suite (`rake test`) and RuboCop (`rake rubocop`).
106
+ 2. Builds and installs the gem (`rake install`).
107
+ 3. Publishes the gem to [RubyGems.org](https://rubygems.org/gems/newsman) (`rake publish`), using the `RUBYGEMS_API_KEY` secret.
108
+ 4. Creates a GitHub Release for the pushed tag, using the `RELEASE_GITHUB_TOKEN` secret.
109
+
110
+ ### How to cut a release
111
+
112
+ 1. **Bump the version** in `newsman.gemspec` (`spec.version`) and commit it to `main`. RubyGems refuses to publish a version that's already live, so this step is mandatory - the workflow's `gem push` will silently fail otherwise (the publish step is `continue-on-error: true`, so the run can still show green even though nothing was actually published).
113
+ 2. **Tag the commit** with the same version, prefixed with `v`, and push the tag:
114
+ ```shell
115
+ git tag v1.2.1
116
+ git push origin v1.2.1
117
+ ```
118
+ 3. Watch the `Release Ruby Gem` workflow run in the Actions tab, and confirm the new version shows up on [RubyGems.org](https://rubygems.org/gems/newsman) and as a [GitHub Release](https://github.com/volodya-lombrozo/newsman/releases).
119
+
101
120
  ## Examples
102
121
 
103
122
  You can find examples of generated reports [here](https://volodya-lombrozo.github.io/newsman/)
@@ -112,32 +112,32 @@ class Assistant
112
112
  send(prompt)
113
113
  end
114
114
 
115
- # rubocop:disable Metrics/MethodLength
115
+ # OpenAI's reasoning-family models (o1, o3, o4-mini, gpt-5, ...) only accept
116
+ # the default temperature (1) and reject any explicit value with a 400.
117
+ # Their "-chat" flavors (e.g. gpt-5-chat-latest) are non-reasoning and
118
+ # support a custom temperature just like gpt-4o, gpt-3.5-turbo, etc.
119
+ FIXED_TEMPERATURE_MODELS = /\A(o[1-9]|gpt-5)/
120
+
116
121
  def send(request)
122
+ parameters = { model: @model, messages: messages(request) }
123
+ parameters[:temperature] = @temperature unless fixed_temperature?
124
+ @client.chat(parameters: parameters).dig('choices', 0, 'message', 'content')
125
+ end
126
+
127
+ def fixed_temperature?
128
+ @model.match?(FIXED_TEMPERATURE_MODELS) && !@model.include?('chat')
129
+ end
130
+
131
+ SYSTEM_PROMPT = 'You are a developer tasked with composing a concise report detailing'\
132
+ ' your activities and progress for the previous week, intended for submission to your supervisor.'
133
+
134
+ def messages(request)
117
135
  if @model == 'o1-preview'
118
- @client.chat(
119
- parameters: {
120
- model: @model,
121
- messages: [{ role: 'user', content: request.to_s }]
122
- }
123
- ).dig('choices', 0, 'message', 'content')
136
+ [{ role: 'user', content: request.to_s }]
124
137
  else
125
- @client.chat(
126
- parameters: {
127
- model: @model,
128
- messages: [
129
- { role: 'system', content: 'You are a developer tasked'\
130
- ' with composing a concise report detailing your activities'\
131
- ' and progress for the previous week,'\
132
- ' intended for submission to your supervisor.' },
133
- { role: 'user', content: request.to_s }
134
- ],
135
- temperature: @temperature
136
- }
137
- ).dig('choices', 0, 'message', 'content')
138
+ [{ role: 'system', content: SYSTEM_PROMPT }, { role: 'user', content: request.to_s }]
138
139
  end
139
140
  end
140
- # rubocop:enable Metrics/MethodLength
141
141
 
142
142
  def deprecated(method)
143
143
  warn "Warning! '#{method}' is deprecated and will be removed in future versions."
@@ -35,4 +35,31 @@ class TestAssistant < Minitest::Test
35
35
  assert_equal expected,
36
36
  assistant.say_hello
37
37
  end
38
+
39
+ def test_fixed_temperature_for_reasoning_models
40
+ %w[o1 o1-preview o1-mini o3 o3-mini o4-mini gpt-5 gpt-5-mini gpt-5.6].each do |model|
41
+ assistant = Assistant.new('test-token', model: model)
42
+ assert(assistant.fixed_temperature?, "expected #{model} to have a fixed temperature")
43
+ end
44
+ end
45
+
46
+ def test_custom_temperature_for_chat_models
47
+ %w[gpt-3.5-turbo gpt-4o gpt-4.1 gpt-5-chat-latest].each do |model|
48
+ assistant = Assistant.new('test-token', model: model)
49
+ refute(assistant.fixed_temperature?, "expected #{model} to allow a custom temperature")
50
+ end
51
+ end
52
+
53
+ def test_o1_preview_skips_system_message
54
+ assistant = Assistant.new('test-token', model: 'o1-preview')
55
+ messages = assistant.messages('do something')
56
+ assert_equal([{ role: 'user', content: 'do something' }], messages)
57
+ end
58
+
59
+ def test_other_models_keep_system_message
60
+ assistant = Assistant.new('test-token', model: 'gpt-5.6')
61
+ messages = assistant.messages('do something')
62
+ assert_equal(2, messages.size)
63
+ assert_equal('system', messages.first[:role])
64
+ end
38
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newsman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Lombrozo