appchat 0.0.1 → 0.0.3

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: d5c882774165626a066d323429ff61a588c547ae05d189b966877b8d9e737c00
4
- data.tar.gz: aef14f1e2763f699de19d6a5fc0c5c8e1beecc3df6d592cdffc9b925363142e2
3
+ metadata.gz: f9bb854d39e8d17f65dcc5ff09269f488e63a50fe080e1c7ae104d9326d8d8b9
4
+ data.tar.gz: 50c75e1d61f287bd89d865b9dffbd24bd77c5448cc13c6407788117a0c49140f
5
5
  SHA512:
6
- metadata.gz: 6bb2360a597d89c871d768a1cf1175b691e8b0e48b7f269d0cd21be166dc114c5d8e31cc4d13df854c9f461719fbc0ae7d8e1ffc316b95fb9fe34a4489be243d
7
- data.tar.gz: bcc2fd16587a696f1d973b87954cc96c05fb9a959223852595c5725c724ff0fac2bfd2d6c7ca23431487fb2d9b7d73cc88e3e1d953f9a261cdc39a900724f575
6
+ metadata.gz: ddecc383090bcb31337e1fab220b510fe62afe86d2763cbd95a837b2ae87c52f7aef7d08130411b02e443c76c5392a70d1481cc1556e4928a29aefbe30c1c91a
7
+ data.tar.gz: a04b84d8eab498add64fb2e4111a8fd491e6dec1af3a984957dfc713c26c4f55d90acff6a16ca83a0d9806087efb26db87b06ec4f861e77bc6ff338e4ac227d2
@@ -24,7 +24,8 @@ class AppchatGenerator < Rails::Generators::Base
24
24
  end
25
25
 
26
26
  def generate_scaffolds
27
- generate "model", "Chat"
27
+ generate "model", "Chat context:text"
28
+ route "resources :chats"
28
29
  generate "scaffold", "Message chat:references content:text role:integer"
29
30
  end
30
31
 
@@ -44,6 +45,10 @@ class AppchatGenerator < Rails::Generators::Base
44
45
  copy_file "models/chat.rb", "app/models/chat.rb", force: true
45
46
  end
46
47
 
48
+ def serialize_context
49
+ inject_into_class 'app/models/chat.rb', 'Chat', "serialize :context, coder:JSON, type: Array\n"
50
+ end
51
+
47
52
  def set_associations
48
53
  inject_into_class 'app/models/chat.rb', 'Chat', " has_many :messages, dependent: :destroy\n"
49
54
  end
@@ -75,6 +80,10 @@ class AppchatGenerator < Rails::Generators::Base
75
80
  ART
76
81
  end
77
82
 
83
+ def get_started
84
+ puts "Congratulations on setting up appchat! \n run bin/dev to spin up your app, and visit localhost:3000/chats to start chatting"
85
+ end
86
+
78
87
  private
79
88
 
80
89
  def gem_exists?(gem_name)
@@ -1,5 +1,5 @@
1
1
  <%= link_to chat, data: { turbo_frame: :chat } do %>
2
2
  <div class="w-full text-gray-100 hover:text-green-500">
3
- <%= chat&.messages&.first&.content%>
3
+ <%= chat&.messages&.first&.content || "New AI chat conversation" %>
4
4
  </div>
5
5
  <% end %>
@@ -5,7 +5,7 @@
5
5
  </style>
6
6
  <div class="flex w-full">
7
7
  <%= turbo_stream_from :chats %>
8
- <div class="max-w-sm w-full flex flex-col gap-4 p-2 w-full flex-shrink-0 bg-[#2e2e2e] rounded-lg" id="chats">
8
+ <div class="max-w-sm w-full h-full flex flex-col gap-4 p-2 w-full flex-shrink-0 bg-[#2e2e2e] rounded-lg" id="chats">
9
9
  <%= link_to chats_path, data: { turbo_method: :post, turbo_frame: :chat }, class: "flex gap-2 justify-center items-center bg-gray-500 text-gray-100 rounded-lg p-2 text-center mr-auto" do %>
10
10
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
11
11
  <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
@@ -22,6 +22,7 @@ class GetAiResponseJob < ApplicationJob
22
22
  {
23
23
  model: 'llama3.1',
24
24
  prompt: user_prompt,
25
+ context: chat.context,
25
26
  stream: true,
26
27
  }
27
28
  ) do |event, raw|
@@ -32,5 +33,6 @@ class GetAiResponseJob < ApplicationJob
32
33
  message.update(content: new_content)
33
34
  end
34
35
  end
36
+ chat.update(context: response.last["context"])
35
37
  end
36
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hackliteracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-06 00:00:00.000000000 Z
11
+ date: 2024-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,7 +88,8 @@ files:
88
88
  homepage: https://rubygems.org/gems/appchat
89
89
  licenses:
90
90
  - MIT
91
- metadata: {}
91
+ metadata:
92
+ source_code_uri: https://github.com/ktamulonis/appchat
92
93
  post_install_message:
93
94
  rdoc_options: []
94
95
  require_paths: