sublayer 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0266ca3b856c768f521cf65a907ebe9d411f5420f83bfb62455912075253820
4
- data.tar.gz: 1b32e201baa8f26e8caa3a124b4ebe9aeeb652b31745ec0fe6b06ab0cee57da2
3
+ metadata.gz: 9c0626295be488d2a39cfbe94652d3e1238b5885c24c5d4d130e0659939387fd
4
+ data.tar.gz: e21ee3e2177caff3a1125de4ba07672db13df661c5888e031d84148f4bfa0a01
5
5
  SHA512:
6
- metadata.gz: 417a853211fb739887936804948c5758d3880431b2b8252df5e3fc58beb6464f44d6f3e1efb0945b0e72a4f80b7135eec8b9813fbffbe9a6cfbe0c4a1d4bf63a
7
- data.tar.gz: 4ee873c4e5edbe289211320573847cd58273b959e001ad3db8fadf68fdedc0bdc9e957b103573c3d31080acc69886dd58d0146906122192bd75fce1e24724d49
6
+ metadata.gz: 8b2a17ca1598e68b7da6a0caf07d61d53f99c6de561f03bbd4f4a74a4bf05ad30ebb1c9261f34320297a1af88c4b82e35163a7711a3d260d97732d2b34b87f1a
7
+ data.tar.gz: adcb0094652bdd477f5cbbf3346037bbfa1b2b62a7c54a148ddd0d4cb440bef8d7c994487a8ef47aee30c0039d3bad7ddfafee587c3fa6c688c6e51f0e89d26e
@@ -27,13 +27,18 @@ module Sublayer
27
27
  }
28
28
  }
29
29
  ],
30
+ tool_choice: { type: "tool", name: output_adapter.name },
30
31
  messages: [{ "role": "user", "content": prompt }]
31
32
  }.to_json
32
33
  )
34
+
33
35
  raise "Error generating with Claude, error: #{response.body}" unless response.code == 200
34
36
 
35
- function_input = JSON.parse(response.body).dig("content").find {|content| content['type'] == 'tool_use'}.dig("input")
36
- function_input[output_adapter.name]
37
+ tool_use = JSON.parse(response.body).dig("content").find { |content| content['type'] == 'tool_use' && content['name'] == output_adapter.name }
38
+
39
+ raise "Error generating with Claude, error: No function called. If the answer is in the response, try rewording your prompt or output adapter name to be from the perspective of the model. Response: #{response.body}" unless tool_use
40
+
41
+ tool_use.dig("input")[output_adapter.name]
37
42
  end
38
43
  end
39
44
  end
@@ -36,10 +36,13 @@ module Sublayer
36
36
 
37
37
  message = response.dig("choices", 0, "message")
38
38
 
39
- raise "No function called" unless message["tool_calls"].length > 0
39
+ raise "No function called" unless message["tool_calls"]
40
40
 
41
41
  function_body = message.dig("tool_calls", 0, "function", "arguments")
42
- JSON.parse(function_body)[output_adapter.name]
42
+
43
+ raise "Error generating with OpenAI. Empty response. Try rewording your output adapter params to be from the perspective of the model. Full Response: #{response}" if function_body == "{}"
44
+
45
+ results = JSON.parse(function_body)[output_adapter.name]
43
46
  end
44
47
  end
45
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sublayer
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sublayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Werner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-30 00:00:00.000000000 Z
11
+ date: 2024-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  requirements: []
232
- rubygems_version: 3.5.3
232
+ rubygems_version: 3.3.26
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: A model-agnostic Ruby GenerativeAI DSL and Framework