sublayer 0.2.0 → 0.2.1
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 +4 -4
- data/lib/sublayer/providers/claude.rb +7 -2
- data/lib/sublayer/providers/open_ai.rb +5 -2
- data/lib/sublayer/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9c0626295be488d2a39cfbe94652d3e1238b5885c24c5d4d130e0659939387fd
         | 
| 4 | 
            +
              data.tar.gz: e21ee3e2177caff3a1125de4ba07672db13df661c5888e031d84148f4bfa0a01
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
            -
                     | 
| 36 | 
            -
             | 
| 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"] | 
| 39 | 
            +
                    raise "No function called" unless message["tool_calls"]
         | 
| 40 40 |  | 
| 41 41 | 
             
                    function_body = message.dig("tool_calls", 0, "function", "arguments")
         | 
| 42 | 
            -
             | 
| 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
         | 
    
        data/lib/sublayer/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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. | 
| 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
         |