Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove server-side infrastructure so developers can bring their own #24

Merged
merged 14 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,96 +2,22 @@ PATH
remote: .
specs:
phlex-chatbot (0.3.3)
actioncable (~> 7.1)
concurrent-ruby (~> 1.3)
concurrent-ruby-edge (~> 0.7.1)
phlex (~> 1.10)
rack (~> 3.1)

GEM
remote: https://rubygems.org/
specs:
actioncable (7.2.0)
actionpack (= 7.2.0)
activesupport (= 7.2.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionpack (7.2.0)
actionview (= 7.2.0)
activesupport (= 7.2.0)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4, < 3.2)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actionview (7.2.0)
activesupport (= 7.2.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
builder (3.3.0)
concurrent-ruby (1.3.4)
concurrent-ruby-edge (0.7.1)
concurrent-ruby (~> 1.3)
connection_pool (2.4.1)
crass (1.0.6)
diff-lcs (1.5.1)
drb (2.2.1)
erubi (1.13.0)
foreman (0.88.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.0)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
minitest (5.25.1)
nio4r (2.7.3)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
phlex (1.11.0)
racc (1.8.1)
rack (3.1.7)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
Expand Down Expand Up @@ -126,16 +52,8 @@ GEM
rubocop-rspec (3.0.4)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
securerandom (0.3.1)
strscan (3.1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
useragent (0.16.10)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.17)

PLATFORMS
arm64-darwin-22
Expand Down
50 changes: 0 additions & 50 deletions lib/phlex/chatbot.rb
Original file line number Diff line number Diff line change
@@ -1,61 +1,11 @@
# frozen_string_literal: true

require "concurrent"
require "phlex"
require "rack"

require_relative "chatbot/channel"
require_relative "chatbot/chat"
require_relative "chatbot/conversator"
require_relative "chatbot/null_logger"
require_relative "chatbot/status_component"
require_relative "chatbot/switchboard/base"
require_relative "chatbot/version"
require_relative "chatbot/web"

module Phlex
module Chatbot
class Error < StandardError; end
ROOT_DIR = Pathname.new(__dir__).join("../..").expand_path

def self.allow_error_messages?
@allow_error_messages
end

def self.allow_error_messages!
@allow_error_messages = true
end

def self.conversator(channel_id:)
@conversator.create(channel_id)
end

def self.conversator=(conversator)
@conversator = conversator
end
self.conversator = Phlex::Chatbot::Conversator

def self.disallow_error_messages!
@allow_error_messages = false
end

def self.logger
@logger ||= NullLogger.new(nil)
end

def self.logger=(logger)
@logger = logger
end

def self.switchboard
@switchboard ||= "in_memory"
require_relative "chatbot/switchboard/#{@switchboard}"
cls_name = @switchboard.to_s.split("_").map(&:capitalize).join
Switchboard.const_get(cls_name).instance
end

def self.switchboard=(name)
@switchboard = name
end
end
end
108 changes: 0 additions & 108 deletions lib/phlex/chatbot/channel.rb

This file was deleted.

6 changes: 0 additions & 6 deletions lib/phlex/chatbot/chat/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ def initialize(conversation_token:, driver:, endpoint:, messages:, full_page: fa
def view_template
div(
**classes("pcb pcb__chat-container", full_page?: "full_page"),
data: {
controller: "pcb-chat-form pcb-chat-messages",
pcb_chat_form_conversation_token_value: @conversation_token,
pcb_chat_form_driver_value: @driver,
pcb_chat_form_endpoint_value: @endpoint,
},
) { chat_content! }

templates!
Expand Down
21 changes: 7 additions & 14 deletions lib/phlex/chatbot/chat/input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@ module Chat
class Input < Phlex::HTML
def view_template
div(class: "pcb__chat-input") do
form(data: { action: "submit->pcb-chat-form#submit" }) do
textarea(
placeholder: "Type your message...",
rows: "1",
data: {
pcb_chat_form_target: "input",
action: <<~ACTIONS.squish,
keydown.ctrl+enter->pcb-chat-form#handleKeyboardSubmit:prevent
keydown.meta+enter->pcb-chat-form#handleKeyboardSubmit:prevent
input->pcb-chat-form#resetTextareaHeight
ACTIONS
},
)
button(type: "submit") { "Send" }
form do
textarea(placeholder: "Type your message...")
submit(
class: "px-4 py-2 rounded bg-blue-500 text-white focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-blue-600 dark:hover:bg-blue-700",
) do
"Send"
end
end
end
end
Expand Down
Loading
Loading