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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e35d2da6576585f442b86b8ab7589e6338a8c621659f1cb3fbc9f83135c9803e
4
- data.tar.gz: 2640b0995ab53af533155910cd90d607188754e87e6d58898eed2a1a3c98354e
3
+ metadata.gz: f087d4035087c7f802c07037989c33caa48b4d6c6cc9e2672339afcae1be46d3
4
+ data.tar.gz: c88854d0a647ba472eb7585c9526304d3d4020f6bcefd0596430ea0b9379d3ec
5
5
  SHA512:
6
- metadata.gz: 0f55ff4f412e168ba9a2e715afd3e90abd8e44f5d209f544beec59e0d1e9125be0fe1e25763b62e14b131e9c986fb633594d974cedda643ceb8601c74f4b2c18
7
- data.tar.gz: ee4b6abe4d93e40dabd416046b23fce7fea9a2596283fdcce523419eb33941c83855799b8201b32be22c21c554aed0212a50033ee45be56d91da197c8685c8aa
6
+ metadata.gz: 6aa78933c0e1dfce14ce9059a4b3d0bbacefdcfe080308197ff427728ae60d6508b9f61a7b573bc2bf31b790160a8fe74c5e0459f204dc6c2b0c2e4457ee3700
7
+ data.tar.gz: '0939f3c387a52c1edee06afcd4487cf3bd9be91c9c3c9c1bd406fbc6cdaa9b697e63130cd8d95145174e2f9493c1ddd1015b9a2efebfed40992aeeb44c7197dd'
@@ -1,7 +1,4 @@
1
1
 
2
- OAT = Wco::OfficeActionTemplate
3
- OATT = Wco::OfficeActionTemplateTie
4
-
5
2
  class Wco::OfficeActionTemplatesController < Wco::ApplicationController
6
3
 
7
4
  before_action :set_lists
@@ -1,7 +1,4 @@
1
1
 
2
- OAT = Wco::OfficeActionTemplate
3
- OA = Wco::OfficeAction
4
-
5
2
  class Wco::OfficeActionsController < Wco::ApplicationController
6
3
 
7
4
  before_action :set_lists
@@ -44,4 +44,4 @@ class Wco::OfficeAction
44
44
  slug
45
45
  end
46
46
  end
47
-
47
+ OA ||= Wco::OfficeAction
@@ -38,4 +38,4 @@ class Wco::OfficeActionTemplate
38
38
  end
39
39
 
40
40
  end
41
- OAT = Wco::OfficeActionTemplate
41
+ OAT ||= Wco::OfficeActionTemplate
@@ -18,3 +18,4 @@ class Wco::OfficeActionTemplateTie
18
18
  validates :next_at_exe, presence: true
19
19
 
20
20
  end
21
+ OATT ||= Wco::OfficeActionTemplateTie
@@ -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, 'out'
44
-
45
- eval( after_eval )
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
 
@@ -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, :on => :create
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 one sentence: #{headline.name}"
32
+ prompt = "Rephrase the following article title using less than 250 characters: #{headline.name}"
32
33
  new_title = self.run_prompt prompt
33
- puts! new_title, 'new_title'
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: new_title,
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
@@ -24,6 +24,7 @@ require 'sass-rails'
24
24
  require 'stripe'
25
25
 
26
26
  require "wco/engine"
27
+ require 'wco/ai_writer'
27
28
 
28
29
  ACTIVE = 'active'
29
30
  INACTIVE = 'inactive'
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.85
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-16 00:00:00.000000000 Z
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