wco_models 3.1.0.85 → 3.1.0.87
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/wco/office_action_templates_controller.rb +0 -3
- data/app/controllers/wco/office_actions_controller.rb +0 -3
- data/app/models/wco/office_action.rb +1 -1
- data/app/models/wco/office_action_template.rb +1 -1
- data/app/models/wco/office_action_template_tie.rb +1 -0
- data/app/models/wco/publisher.rb +16 -4
- data/app/models/wco/report.rb +2 -13
- data/lib/wco/ai_writer.rb +6 -6
- data/lib/wco_models.rb +1 -0
- 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: f087d4035087c7f802c07037989c33caa48b4d6c6cc9e2672339afcae1be46d3
|
4
|
+
data.tar.gz: c88854d0a647ba472eb7585c9526304d3d4020f6bcefd0596430ea0b9379d3ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aa78933c0e1dfce14ce9059a4b3d0bbacefdcfe080308197ff427728ae60d6508b9f61a7b573bc2bf31b790160a8fe74c5e0459f204dc6c2b0c2e4457ee3700
|
7
|
+
data.tar.gz: '0939f3c387a52c1edee06afcd4487cf3bd9be91c9c3c9c1bd406fbc6cdaa9b697e63130cd8d95145174e2f9493c1ddd1015b9a2efebfed40992aeeb44c7197dd'
|
data/app/models/wco/publisher.rb
CHANGED
@@ -28,6 +28,7 @@ class Wco::Publisher
|
|
28
28
|
@headers = {}
|
29
29
|
@ctx = OpenStruct.new
|
30
30
|
|
31
|
+
puts! context_eval, 'context_eval'
|
31
32
|
eval( context_eval )
|
32
33
|
puts! @ctx, '@ctx'
|
33
34
|
|
@@ -38,11 +39,22 @@ class Wco::Publisher
|
|
38
39
|
out = Wco::HTTParty.post( "#{@site.origin}#{post_path}", {
|
39
40
|
body: body.to_json,
|
40
41
|
headers: @headers,
|
41
|
-
basic_auth: { username: site.username, password: site.password },
|
42
|
+
basic_auth: { username: @site.username, password: @site.password },
|
42
43
|
})
|
43
|
-
puts! out.response, '
|
44
|
-
|
45
|
-
|
44
|
+
puts! out.response, 'publisher httparty response'
|
45
|
+
puts! out.body, 'publisher httparty body'
|
46
|
+
if out.code != 201
|
47
|
+
puts! out.body, "publisher#do_run non-201 status"
|
48
|
+
::ExceptionNotifier.notify_exception(
|
49
|
+
Exception.new,
|
50
|
+
data: {
|
51
|
+
httparty_body: out.body,
|
52
|
+
httparty: out,
|
53
|
+
label: "publisher#do_run non-201 status",
|
54
|
+
} )
|
55
|
+
end
|
56
|
+
|
57
|
+
eval( after_eval ) if after_eval.present?
|
46
58
|
end
|
47
59
|
|
48
60
|
|
data/app/models/wco/report.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
|
2
2
|
##
|
3
|
+
## @report.body.split("\n\n").map { |ttt| "<p>#{ttt}</p>" }.join
|
3
4
|
##
|
4
|
-
##
|
5
|
-
# @report.body.split("\n\n").map { |ttt| "<p>#{ttt}</p>" }.join
|
6
|
-
#
|
7
5
|
class Wco::Report
|
8
6
|
include Mongoid::Document
|
9
7
|
include Mongoid::Timestamps
|
@@ -21,19 +19,10 @@ class Wco::Report
|
|
21
19
|
field :slug
|
22
20
|
validates :slug, presence: true, uniqueness: true
|
23
21
|
index({ :slug => 1 }, { :unique => true })
|
24
|
-
before_validation :set_slug, :
|
22
|
+
before_validation :set_slug, on: :create
|
25
23
|
|
26
24
|
field :body
|
27
25
|
|
28
|
-
# field :raw_json, type: :object, default: '{}'
|
29
|
-
|
30
|
-
# field :is_trash, :type => Boolean, :default => false
|
31
|
-
# index({ :is_trash => 1, :is_public => 1 })
|
32
|
-
|
33
|
-
# field :is_public, :type => Boolean, :default => true
|
34
|
-
# index({ :is_public => 1 })
|
35
|
-
# scope :public, ->{ where({ is_public: true }) }
|
36
|
-
|
37
26
|
field :x, :type => Float
|
38
27
|
field :y, :type => Float
|
39
28
|
field :z, :type => Float
|
data/lib/wco/ai_writer.rb
CHANGED
@@ -21,6 +21,7 @@ class Wco::AiWriter
|
|
21
21
|
})
|
22
22
|
out = JSON.parse out.response.body
|
23
23
|
out.deep_symbolize_keys!
|
24
|
+
puts! out, 'chatgpt response'
|
24
25
|
out = out[:choices][0][:message][:content]
|
25
26
|
return out
|
26
27
|
end
|
@@ -28,25 +29,24 @@ class Wco::AiWriter
|
|
28
29
|
|
29
30
|
|
30
31
|
def self.run_headline headline
|
31
|
-
prompt = "Rephrase the following article title using
|
32
|
+
prompt = "Rephrase the following article title using less than 250 characters: #{headline.name}"
|
32
33
|
new_title = self.run_prompt prompt
|
33
|
-
|
34
|
+
new_title = new_title[0..255]
|
35
|
+
# puts! new_title, 'new_title'
|
34
36
|
|
35
37
|
prompt = "Write an article about the following topic: #{headline.name}"
|
36
38
|
new_body = self.run_prompt prompt
|
37
39
|
new_body.gsub!("\r", '')
|
38
40
|
new_body = new_body.split("\n\n").map { |ppp| "<p>#{ppp}</p>" }.join
|
39
41
|
new_body = new_body.gsub("\n", "<br />")
|
40
|
-
puts! new_body[0...200], 'new_body'
|
42
|
+
# puts! new_body[0...200], 'new_body'
|
41
43
|
|
42
44
|
report = Wco::Report.create!({
|
43
45
|
title: new_title,
|
44
|
-
slug:
|
46
|
+
# slug: new_title,
|
45
47
|
body: new_body,
|
46
48
|
})
|
47
49
|
|
48
|
-
# headline.delete
|
49
|
-
|
50
50
|
return report
|
51
51
|
end
|
52
52
|
def run_headline h; self.class.run_headline h; end
|
data/lib/wco_models.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wco_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.87
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Pudeyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|