o_collect 0.1.0
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/bin/o_collect +4 -0
- data/lib/collector/o_collect.rb +80 -0
- data/lib/collector/version.rb +3 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 043f3caa318ad8655c31a45a2056ed575debdb7b9b9985e330096f7b299f4fa9
|
4
|
+
data.tar.gz: 3d1896f697d239180030577e44e8c35bd010311af825cac7d365af44c584cf7e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a53fe96f695155d92b32e624b68f7ea8473de85c66e414fdaaf73266d797124af44e1422bfa332979d76ca15e95b14ff0dd0fc387ddd123d9b07c0167ef460c7
|
7
|
+
data.tar.gz: a45b96c49b3b9d65913ec0c7deaba1b27b82e3ea1d21478f7d11187f36b035920764b9f692235fcfc1ecd0b039ad029679ddbd6e04123ed4139defa75669cc38
|
data/bin/o_collect
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'time'
|
3
|
+
require 'groq'
|
4
|
+
include Groq::Helpers
|
5
|
+
|
6
|
+
module Collector
|
7
|
+
class OCollect
|
8
|
+
DEFAULT_CONFIG = {
|
9
|
+
"version" => "0.1",
|
10
|
+
"database" => "local.db",
|
11
|
+
"target_url" => "https://localhost:8080/collect/test",
|
12
|
+
"prompt" => "name a random country",
|
13
|
+
"interval" => 1000
|
14
|
+
}
|
15
|
+
|
16
|
+
CONFIG_FILENAME = ".o_collect"
|
17
|
+
|
18
|
+
API_KEY = "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"
|
19
|
+
MODEL_ID = "mixtral-8x7b-32768"
|
20
|
+
ROLE = "data scientist"
|
21
|
+
|
22
|
+
def self.run
|
23
|
+
new.run
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
ensure_config_file_exists
|
28
|
+
config = load_config
|
29
|
+
|
30
|
+
# Update the config with the current datetime under key "last_run_at"
|
31
|
+
config["last_run_at"] = Time.now.utc.iso8601
|
32
|
+
File.write(CONFIG_FILENAME, config.to_yaml)
|
33
|
+
puts "Configuration updated with last_run_at: #{config['last_run_at']}"
|
34
|
+
|
35
|
+
# Set up Groq Client
|
36
|
+
Groq.configure do |config_obj|
|
37
|
+
config_obj.api_key = API_KEY
|
38
|
+
config_obj.model_id = MODEL_ID
|
39
|
+
end
|
40
|
+
|
41
|
+
client = Groq::Client.new
|
42
|
+
|
43
|
+
# Create a fiber that repeatedly calls the Groq API
|
44
|
+
fiber = Fiber.new do
|
45
|
+
loop do
|
46
|
+
response = client.chat([
|
47
|
+
System(ROLE),
|
48
|
+
U(config["prompt"])
|
49
|
+
])
|
50
|
+
puts response['content']
|
51
|
+
|
52
|
+
# Pause for the configured interval (convert ms to seconds)
|
53
|
+
sleep(config["interval"].to_f / 1000)
|
54
|
+
|
55
|
+
Fiber.yield
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Continuously resume the fiber while it is alive
|
60
|
+
while fiber.alive?
|
61
|
+
fiber.resume
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def ensure_config_file_exists
|
68
|
+
unless File.exist?(CONFIG_FILENAME)
|
69
|
+
File.open(CONFIG_FILENAME, "w") do |file|
|
70
|
+
file.write(DEFAULT_CONFIG.to_yaml)
|
71
|
+
end
|
72
|
+
puts "Created default configuration file #{CONFIG_FILENAME}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def load_config
|
77
|
+
YAML.load_file(CONFIG_FILENAME)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: o_collect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Han
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-02-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.3.2
|
19
|
+
name: groq
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.2
|
27
|
+
description: Provides the o_collect command which periodically calls the Groq API
|
28
|
+
using a configured prompt.
|
29
|
+
email:
|
30
|
+
- han@odore.ai
|
31
|
+
executables:
|
32
|
+
- o_collect
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- bin/o_collect
|
37
|
+
- lib/collector/o_collect.rb
|
38
|
+
- lib/collector/version.rb
|
39
|
+
homepage: https://www.odore.ai
|
40
|
+
licenses:
|
41
|
+
- Nonstandard
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubygems_version: 3.3.26
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Command-line tool for periodic Groq API calls
|
62
|
+
test_files: []
|