wco_models 3.1.0.85 → 3.1.0.86

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: b766aa1273a9c863ee71e44e96308ac8ff2de76e4a29079bcf58a23cdc50298b
4
+ data.tar.gz: 5c032aa7fac857e68baf760863d0d3de1831de98e1cbf52397c117fa2db41454
5
5
  SHA512:
6
- metadata.gz: 0f55ff4f412e168ba9a2e715afd3e90abd8e44f5d209f544beec59e0d1e9125be0fe1e25763b62e14b131e9c986fb633594d974cedda643ceb8601c74f4b2c18
7
- data.tar.gz: ee4b6abe4d93e40dabd416046b23fce7fea9a2596283fdcce523419eb33941c83855799b8201b32be22c21c554aed0212a50033ee45be56d91da197c8685c8aa
6
+ metadata.gz: 0f539fda62b5de3856bc7fab46585ad1ffe13be1a9f8285e70d11b2bf327d3887a2f5e63815887abb5ea79164ffc733392f6fa69d9931882428f74cacbed2dbc
7
+ data.tar.gz: 98d693ef2b7b0b762b6677e42f1ba2c414f3195b1ea00f009bf55b09e1a03618bf1164e4cef342dca3032baa34294a1c29dacc511c9595ac0b866d510924ba03
@@ -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,14 @@ 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
44
  puts! out.response, 'out'
45
+ if out.code != 201
46
+ raise "#do_run exception: #{out.body}"
47
+ end
44
48
 
45
- eval( after_eval )
49
+ eval( after_eval ) if after_eval.present?
46
50
  end
47
51
 
48
52
 
@@ -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.86
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