Skip to content

Commit

Permalink
minor updates:
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifiht committed Apr 22, 2024
1 parent b5c494c commit a3875f3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
6 changes: 6 additions & 0 deletions src/lib/shiki_gram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ def open_msg(msg64)
return msg
end
end

#3.1.4 :021 > job = @beanstalk.tubes.reserve
=> #<Beaneater::Job id=297 body="Hello world">
#3.1.4 :022 > job.stats
=> #<Beaneater::StatStruct id=297, tube="test", state="reserved", pri=65536, age=140, delay=0,\
# ttr=120, time_left=115, file=0, reserves=1, timeouts=0, releases=0, buries=0, kicks=0>
60 changes: 29 additions & 31 deletions src/modules/chat/chat.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
#=============<[ Gems ]>=============#
require "http"
require 'json'
require "json"
require "beaneater"
require "require_all"
#==========<[ Local Libs ]>==========#
#require_rel "../../lib/shiki_gram"
require_rel "../../lib/app_settings"
require_rel "../../lib/shiki_stdlib"

prompt = "Hello world."
req_json = {
response = HTTP.post("http://localhost:4242/completion", :json => req_json)
my_hash = JSON.parse(response.body)
puts my_hash["content"]

shiki = Shiki.new("chat")
core_config = AppSettings.new
beanstalk_host = core_config.get("beanstalk_host")
beanstalk_port = core_config.get("beanstalk_port")
core_threads = []

bstalk = Beaneater.new("#{beanstalk_host}\:#{beanstalk_port}")
bstalk.tubes.find("chat") # also creates the tube
bstalk.tubes.watch!("chat")

def log_to_pm2(message)
$stdout.puts message
$stdout.flush
end #def

def format_question(prompt)
request = {
"stream"=> false,
"n_predict"=> 400,
"temperature"=> 0,
Expand All @@ -29,35 +49,13 @@
"grammar"=> "",
"n_probs"=> 0,
"prompt"=> prompt
}
response = HTTP.post("http://localhost:4242/completion", :json => req_json)
my_hash = JSON.parse(response.body)
puts my_hash["content"]


shiki = Shiki.new("chat")
core_config = AppSettings.new
beanstalk_host = core_config.get("beanstalk_host")
beanstalk_port = core_config.get("beanstalk_port")
core_threads = []

bstalk = Beaneater.new("#{beanstalk_host}\:#{beanstalk_port}")
bstalk.tubes.find("chat") # also creates the tube
bstalk.tubes.watch!("chat")
}
return request.to_json
end #def

def log_to_pm2(message)
$stdout.puts message
$stdout.flush
end
def ask_question(str)
question = format_question(str)

def eval_string(str)
begin
eval str
rescue SyntaxError
log_to_pm2("SyntaxError: #{str}")
rescue NameError
log_to_pm2("NameError: #{str}")
end #begin
end #def

core_threads << Thread.new {
Expand All @@ -67,7 +65,7 @@ def eval_string(str)
str = sgram.open_msg(job.body)
log_to_pm2("Received job: #{str}")
begin
eval_string(str)
ask_question(str)
rescue Exception => e
log_to_pm2("Rescued job: #{e}")
end
Expand Down
1 change: 1 addition & 0 deletions src/modules/discord/discord.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#=============<[ Gems ]>=============#
require "discordrb"
require "beaneater"
require "require_all"
#==========<[ Local Libs ]>==========#
#require_rel "../../lib/shiki_gram"
Expand Down

0 comments on commit a3875f3

Please sign in to comment.