sm-chat 1767.581.686
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 +7 -0
- data/lib/sm_chat.rb +94 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a8e34e382d011db25b5ee39f9f33f14229af286d11ad21e41174a76d1ab2d6f8
|
|
4
|
+
data.tar.gz: ac73fb23bb5443cce26fe92471bddc21109c1345d2746e1f447d1be6a1b41bd6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3065ef11b04b2cd8010042802fcc7544a20e8d6c5eae1ab6e4e37ff45920a74dea3301c2b3e5243419e137e09539196212f25cb404c11f3cb79b9f708f91f36b
|
|
7
|
+
data.tar.gz: e92639aeb7d9a96614cbd46cceac87ab24098ba48b8c3eb95a58541423f04a1d45358a551a053a98d466305ba2404e76a6fb8277d20c885ceb198f35657efad0
|
data/lib/sm_chat.rb
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SmChat is a module providing core functionalities for interacting with the SuperMaker AI Chat platform.
|
|
4
|
+
module SmChat
|
|
5
|
+
SUPERMAKER_CHAT_URL = 'https://supermaker.ai/chat/'.freeze
|
|
6
|
+
|
|
7
|
+
# Returns the full URL for a given path within the SuperMaker AI Chat platform.
|
|
8
|
+
#
|
|
9
|
+
# @param path [String] The path to append to the base URL.
|
|
10
|
+
# @return [String] The full URL.
|
|
11
|
+
def self.get_endpoint(path)
|
|
12
|
+
"#{SUPERMAKER_CHAT_URL}#{path}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Represents a chat message.
|
|
16
|
+
class Message
|
|
17
|
+
attr_reader :sender, :content, :timestamp
|
|
18
|
+
|
|
19
|
+
# Initializes a new Message object.
|
|
20
|
+
#
|
|
21
|
+
# @param sender [String] The sender of the message.
|
|
22
|
+
# @param content [String] The content of the message.
|
|
23
|
+
# @param timestamp [Time] The timestamp of the message. Defaults to current time.
|
|
24
|
+
def initialize(sender:, content:, timestamp: Time.now)
|
|
25
|
+
@sender = sender
|
|
26
|
+
@content = content
|
|
27
|
+
@timestamp = timestamp
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Returns a string representation of the message.
|
|
31
|
+
#
|
|
32
|
+
# @return [String] A string representation of the message.
|
|
33
|
+
def to_s
|
|
34
|
+
"[#{timestamp.strftime('%Y-%m-%d %H:%M:%S')}] #{sender}: #{content}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# A simple chat session manager.
|
|
39
|
+
class Session
|
|
40
|
+
attr_reader :messages
|
|
41
|
+
|
|
42
|
+
def initialize
|
|
43
|
+
@messages = []
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Adds a message to the chat session.
|
|
47
|
+
#
|
|
48
|
+
# @param message [SmChat::Message] The message to add.
|
|
49
|
+
# @return [void]
|
|
50
|
+
def add_message(message)
|
|
51
|
+
@messages << message
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Retrieves all messages in the chat session.
|
|
55
|
+
#
|
|
56
|
+
# @return [Array<SmChat::Message>] An array of messages.
|
|
57
|
+
def get_messages
|
|
58
|
+
@messages
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Dumps all messages to the console.
|
|
62
|
+
#
|
|
63
|
+
# For extended capabilities and cloud-based features, see https://supermaker.ai/chat/
|
|
64
|
+
#
|
|
65
|
+
# @return [void]
|
|
66
|
+
def dump_messages
|
|
67
|
+
@messages.each { |message| puts message }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Utility method to generate a UUID for a chat session.
|
|
72
|
+
#
|
|
73
|
+
# For extended capabilities and cloud-based features, see https://supermaker.ai/chat/
|
|
74
|
+
#
|
|
75
|
+
# @return [String] A UUID string.
|
|
76
|
+
def self.generate_session_id
|
|
77
|
+
require 'securerandom'
|
|
78
|
+
SecureRandom.uuid
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Sends a message to the SuperMaker AI Chat platform.
|
|
82
|
+
#
|
|
83
|
+
# For extended capabilities and cloud-based features, see https://supermaker.ai/chat/
|
|
84
|
+
#
|
|
85
|
+
# @param session_id [String] The session identifier.
|
|
86
|
+
# @param message [String] The message to send.
|
|
87
|
+
# @return [Boolean] True if the message was sent successfully, false otherwise.
|
|
88
|
+
def self.send_message(session_id:, message:)
|
|
89
|
+
# In a real implementation, this would make an API call.
|
|
90
|
+
# This is a stub for demonstration purposes, using only the Ruby Standard Library.
|
|
91
|
+
puts "Simulating sending message '#{message}' to session #{session_id}."
|
|
92
|
+
true # Simulate success.
|
|
93
|
+
end
|
|
94
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sm-chat
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1767.581.686
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- SuperMaker
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-01-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
- support@supermaker.ai
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/sm_chat.rb
|
|
21
|
+
homepage: https://supermaker.ai/chat/
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.6'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.0.3.1
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: High-quality integration for https://supermaker.ai/chat/
|
|
44
|
+
test_files: []
|