lammy 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lammy/chat.rb +17 -8
- data/lib/lammy/openai.rb +2 -2
- data/lib/lammy.rb +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dddd7ebf694f48f5d75ff062990bdec4f4e2c1188af7f958fe12a6856928c103
|
4
|
+
data.tar.gz: ea361dc698c42d8c8c37318e0e98300d7fb416e31de53d2b4f3ab05882bf480d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c925d41bfa4a2b66867e43e081187f76f0143775d1e2ac0044b6a243fc3aadcaec13499b9678cbc891b076ae50c9b8612999d183c987b77ae99838658f4f222d
|
7
|
+
data.tar.gz: dcfb1071b3eb78ad66e1151b2d04d4b58581d576ff211f48d2126d9d52af991abbb387bb5cdc36c925efca9ca990a8be1bf1d19767ac5b4dd5aa9d904c997077
|
data/lib/lammy/chat.rb
CHANGED
@@ -17,22 +17,31 @@ module L
|
|
17
17
|
define_method(method_name) do |*args, &block|
|
18
18
|
# Initialize context
|
19
19
|
@system_message = nil
|
20
|
+
@prefilled_message = nil
|
20
21
|
|
21
|
-
#
|
22
|
+
# `context` sets the system message and is available within the instance
|
22
23
|
define_singleton_method(:context) do |message|
|
23
24
|
@system_message = message
|
24
25
|
end
|
25
26
|
|
27
|
+
# `prefill` sets the prefilled message and is available within the instance
|
28
|
+
define_singleton_method(:prefill) do |message|
|
29
|
+
@prefilled_message = message
|
30
|
+
end
|
31
|
+
|
26
32
|
# Call the original method to get the user message
|
27
33
|
user_message = original_method.bind(self).call(*args, &block)
|
28
34
|
|
29
|
-
case settings[:model]
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
client = case settings[:model]
|
36
|
+
when *OpenAI::MODELS
|
37
|
+
OpenAI.new(settings)
|
38
|
+
when *Claude::MODELS
|
39
|
+
Claude.new(settings)
|
40
|
+
else
|
41
|
+
raise "Unsupported model: #{settings[:model]}"
|
42
|
+
end
|
43
|
+
|
44
|
+
client.chat(user_message, @system_message, @prefilled_message)
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
data/lib/lammy/openai.rb
CHANGED
@@ -4,7 +4,7 @@ require 'openai'
|
|
4
4
|
require 'hashie'
|
5
5
|
|
6
6
|
module L
|
7
|
-
# Use the OpenAI API's
|
7
|
+
# Use the OpenAI API's Ruby library
|
8
8
|
class OpenAI
|
9
9
|
MODELS = %w[
|
10
10
|
gpt-4o-mini gpt-4o gpt-4-turbo gpt-4 gpt-3.5-turbo gpt-4o-mini-2024-07-18 gpt-4o-2024-08-06
|
@@ -22,7 +22,7 @@ module L
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Generate a response with support for structured output
|
25
|
-
def chat(user_message, system_message = nil)
|
25
|
+
def chat(user_message, system_message = nil, _ = nil)
|
26
26
|
schema = schema(settings)
|
27
27
|
response = client.chat(
|
28
28
|
parameters: {
|
data/lib/lammy.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lammy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamil Nicieja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: anthropic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
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'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: hashie
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
75
|
requirements:
|
62
76
|
- - ">="
|
63
77
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
78
|
+
version: 2.6.0
|
65
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
80
|
requirements:
|
67
81
|
- - ">="
|