intelli_agent 0.2.10 → 0.2.12
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/intelli_agent/openai.rb +9 -20
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 37f7cac456bcc0441d34d9f0e9901dfd49d04b3fde889ab44498bd1a735dcbd0
         | 
| 4 | 
            +
              data.tar.gz: 0e3cb4e3597410c51db19ee141d273839a1ea8945c99029d422ce85c247874c7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 47133255200fa5ee3cac2d91db4293348eadd243c11d0893f65280c7ecc378a39db2196cfd81b52343273e1cdc36e738bfa469b5c670e4bb5840c494e5f1cde1
         | 
| 7 | 
            +
              data.tar.gz: cfc9cbf181b2971f51e44cf056bebd5bd0cd344d7561dfea2824249db4cc7c629100dade0fe0013ba29538d11a520e68ded5d811729585b0e7db2dd7f12fef9c
         | 
    
        data/lib/intelli_agent/openai.rb
    CHANGED
    
    | @@ -58,19 +58,9 @@ module IntelliAgent::OpenAI | |
| 58 58 | 
             
                response
         | 
| 59 59 | 
             
              end
         | 
| 60 60 |  | 
| 61 | 
            -
              def self.vision(prompt:, image_url:, model: :gpt_advanced, response_format: nil, max_tokens: MAX_TOKENS)
         | 
| 62 | 
            -
                 | 
| 63 | 
            -
                messages  | 
| 64 | 
            -
                            { type: :image_url, image_url: { url: image_url } }]
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                parameters = { model: model, messages: [{ role: :user, content: messages }], max_tokens: }
         | 
| 67 | 
            -
                parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                response = OpenAI::Client.new.chat(parameters:)
         | 
| 70 | 
            -
                
         | 
| 71 | 
            -
                def response.content = dig('choices', 0, 'message', 'content').strip
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                response
         | 
| 61 | 
            +
              def self.vision(prompt:, image_url:, model: :gpt_advanced, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
         | 
| 62 | 
            +
                message_content = [{ type: :text, text: prompt }, { type: :image_url, image_url: { url: image_url } }]
         | 
| 63 | 
            +
                chat(messages: [{ role: :user, content: message_content }], model:, response_format:, max_tokens:, store:, tools:, auto_run_functions:, function_context:)    
         | 
| 74 64 | 
             
              end  
         | 
| 75 65 |  | 
| 76 66 | 
             
              def self.single_prompt(prompt:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
         | 
| @@ -83,18 +73,17 @@ module IntelliAgent::OpenAI | |
| 83 73 |  | 
| 84 74 | 
             
              def self.chat(messages:, model: :gpt_basic, response_format: nil, max_tokens: MAX_TOKENS, store: true, metadata: nil, tools: nil, auto_run_functions: false, function_context: nil)
         | 
| 85 75 | 
             
                model = select_model(model)
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                # o1 models doesn't support max_tokens, instead max_completion_tokens
         | 
| 88 76 | 
             
                is_o1_model = model.start_with?('o1')
         | 
| 89 | 
            -
                max_completion_tokens = max_tokens if is_o1_model
         | 
| 90 77 |  | 
| 91 78 | 
             
                messages = parse_messages(messages)
         | 
| 92 79 |  | 
| 93 80 | 
             
                parameters = { model:, messages:, store: }
         | 
| 94 81 | 
             
                parameters[:metadata] = metadata if metadata
         | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
                 | 
| 82 | 
            +
             | 
| 83 | 
            +
             | 
| 84 | 
            +
                # o1 family models doesn't support max_tokens params. Instead, use max_completion_tokens
         | 
| 85 | 
            +
                parameters[:max_completion_tokens] = max_tokens if is_o1_model
         | 
| 86 | 
            +
                parameters[:max_tokens] = max_tokens unless is_o1_model
         | 
| 98 87 |  | 
| 99 88 | 
             
                parameters[:response_format] = { type: 'json_object' } if response_format.eql?(:json)
         | 
| 100 89 | 
             
                parameters[:tools] = tools if tools
         | 
| @@ -134,7 +123,7 @@ module IntelliAgent::OpenAI | |
| 134 123 |  | 
| 135 124 | 
             
              def self.parse_messages(messages)
         | 
| 136 125 | 
             
                case messages
         | 
| 137 | 
            -
                in [{ role: String, content: String }, *]
         | 
| 126 | 
            +
                in [{ role: String | Symbol, content: String | Array }, *]
         | 
| 138 127 | 
             
                  messages
         | 
| 139 128 | 
             
                else
         | 
| 140 129 | 
             
                  messages.map do |msg|
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: intelli_agent
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.12
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Gedean Dias
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2024-10-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: ruby-openai
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: '7. | 
| 19 | 
            +
                    version: '7.2'
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: '7. | 
| 26 | 
            +
                    version: '7.2'
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: anthropic
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 84 84 | 
             
                - !ruby/object:Gem::Version
         | 
| 85 85 | 
             
                  version: '0'
         | 
| 86 86 | 
             
            requirements: []
         | 
| 87 | 
            -
            rubygems_version: 3.5. | 
| 87 | 
            +
            rubygems_version: 3.5.21
         | 
| 88 88 | 
             
            signing_key: 
         | 
| 89 89 | 
             
            specification_version: 4
         | 
| 90 90 | 
             
            summary: A helper layer over Anthropic and OpenAI API
         |