cohere-ruby 0.9.10 → 0.9.11
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/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +37 -22
- data/lib/cohere/client.rb +23 -0
- data/lib/cohere/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: 5f1c3798500d154b882bd6bb2e0e43904fea4bf69db4d982da4abc6265bc461c
         | 
| 4 | 
            +
              data.tar.gz: d91ed933c24f2dacc5f2604639d307fd389f3774aaed8082df07e03ac2961704
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b989c60be670a143848367a7be84f53fc6adf97f31e1f3739113a7a7caec988450e4e889bcbc7f2733783623977dc4f6e1eb7484470259935e30e7dc6d5d1414
         | 
| 7 | 
            +
              data.tar.gz: 00a2e3e1a19bfb1980d06ebc1fd6117262bcdf226bc95bfe0edff8ea8e1397791eaf7ef37b78ad158e0ef5a8363fa809c9215fc325d771e72abf22d7919c54c0
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # Cohere
         | 
| 2 2 |  | 
| 3 3 | 
             
            <p>
         | 
| 4 | 
            -
                <img alt=' | 
| 4 | 
            +
                <img alt='Cohere logo' src='https://static.wikia.nocookie.net/logopedia/images/d/d4/Cohere_2023.svg/revision/latest?cb=20230419182227' height='50' />
         | 
| 5 5 | 
             
                +  
         | 
| 6 6 | 
             
                <img alt='Ruby logo' src='https://user-images.githubusercontent.com/541665/230231593-43861278-4550-421d-a543-fd3553aac4f6.png' height='40' />
         | 
| 7 7 | 
             
            </p>
         | 
| @@ -42,7 +42,7 @@ client = Cohere::Client.new( | |
| 42 42 |  | 
| 43 43 | 
             
            ```ruby
         | 
| 44 44 | 
             
            client.generate(
         | 
| 45 | 
            -
             | 
| 45 | 
            +
              prompt: "Once upon a time in a magical land called"
         | 
| 46 46 | 
             
            )
         | 
| 47 47 | 
             
            ```
         | 
| 48 48 |  | 
| @@ -50,7 +50,7 @@ client.generate( | |
| 50 50 |  | 
| 51 51 | 
             
            ```ruby
         | 
| 52 52 | 
             
            client.chat(
         | 
| 53 | 
            -
             | 
| 53 | 
            +
              message: "Hey! How are you?"
         | 
| 54 54 | 
             
            )
         | 
| 55 55 | 
             
            ```
         | 
| 56 56 |  | 
| @@ -90,30 +90,45 @@ client.chat( | |
| 90 90 | 
             
            )
         | 
| 91 91 | 
             
            ```
         | 
| 92 92 |  | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 93 | 
             
            ### Embed
         | 
| 96 94 |  | 
| 97 95 | 
             
            ```ruby
         | 
| 98 96 | 
             
            client.embed(
         | 
| 99 | 
            -
             | 
| 97 | 
            +
              texts: ["hello!"]
         | 
| 98 | 
            +
            )
         | 
| 99 | 
            +
            ```
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            ### Rerank
         | 
| 102 | 
            +
             | 
| 103 | 
            +
            ```ruby
         | 
| 104 | 
            +
            docs = [
         | 
| 105 | 
            +
              "Carson City is the capital city of the American state of Nevada.",
         | 
| 106 | 
            +
              "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
         | 
| 107 | 
            +
              "Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
         | 
| 108 | 
            +
              "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
         | 
| 109 | 
            +
              "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.",
         | 
| 110 | 
            +
            ]
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            client.rerank(
         | 
| 113 | 
            +
              texts: ["hello!"]
         | 
| 100 114 | 
             
            )
         | 
| 101 115 | 
             
            ```
         | 
| 102 116 |  | 
| 117 | 
            +
             | 
| 103 118 | 
             
            ### Classify
         | 
| 104 119 |  | 
| 105 120 | 
             
            ```ruby
         | 
| 106 121 | 
             
            examples = [
         | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 122 | 
            +
              { text: "Dermatologists don't like her!", label: "Spam" },
         | 
| 123 | 
            +
              { text: "Hello, open to this?", label: "Spam" },
         | 
| 124 | 
            +
              { text: "I need help please wire me $1000 right now", label: "Spam" },
         | 
| 125 | 
            +
              { text: "Nice to know you ;)", label: "Spam" },
         | 
| 126 | 
            +
              { text: "Please help me?", label: "Spam" },
         | 
| 127 | 
            +
              { text: "Your parcel will be delivered today", label: "Not spam" },
         | 
| 128 | 
            +
              { text: "Review changes to our Terms and Conditions", label: "Not spam" },
         | 
| 129 | 
            +
              { text: "Weekly sync notes", label: "Not spam" },
         | 
| 130 | 
            +
              { text: "Re: Follow up from today's meeting", label: "Not spam" },
         | 
| 131 | 
            +
              { text: "Pre-read for tomorrow", label: "Not spam" }
         | 
| 117 132 | 
             
            ]
         | 
| 118 133 |  | 
| 119 134 | 
             
            inputs = [
         | 
| @@ -122,8 +137,8 @@ inputs = [ | |
| 122 137 | 
             
            ]
         | 
| 123 138 |  | 
| 124 139 | 
             
            client.classify(
         | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 140 | 
            +
              examples: examples,
         | 
| 141 | 
            +
              inputs: inputs
         | 
| 127 142 | 
             
            )
         | 
| 128 143 | 
             
            ```
         | 
| 129 144 |  | 
| @@ -131,7 +146,7 @@ client.classify( | |
| 131 146 |  | 
| 132 147 | 
             
            ```ruby
         | 
| 133 148 | 
             
            client.tokenize(
         | 
| 134 | 
            -
             | 
| 149 | 
            +
              text: "hello world!"
         | 
| 135 150 | 
             
            )
         | 
| 136 151 | 
             
            ```
         | 
| 137 152 |  | 
| @@ -139,7 +154,7 @@ client.tokenize( | |
| 139 154 |  | 
| 140 155 | 
             
            ```ruby
         | 
| 141 156 | 
             
            client.detokenize(
         | 
| 142 | 
            -
             | 
| 157 | 
            +
              tokens: [33555, 1114 , 34]
         | 
| 143 158 | 
             
            )
         | 
| 144 159 | 
             
            ```
         | 
| 145 160 |  | 
| @@ -147,7 +162,7 @@ client.detokenize( | |
| 147 162 |  | 
| 148 163 | 
             
            ```ruby
         | 
| 149 164 | 
             
            client.detect_language(
         | 
| 150 | 
            -
             | 
| 165 | 
            +
              texts: ["Здравствуй, Мир"]
         | 
| 151 166 | 
             
            )
         | 
| 152 167 | 
             
            ```
         | 
| 153 168 |  | 
| @@ -155,7 +170,7 @@ client.detect_language( | |
| 155 170 |  | 
| 156 171 | 
             
            ```ruby
         | 
| 157 172 | 
             
            client.summarize(
         | 
| 158 | 
            -
             | 
| 173 | 
            +
              text: "..."
         | 
| 159 174 | 
             
            )
         | 
| 160 175 | 
             
            ```
         | 
| 161 176 |  | 
    
        data/lib/cohere/client.rb
    CHANGED
    
    | @@ -119,6 +119,29 @@ module Cohere | |
| 119 119 | 
             
                  response.body
         | 
| 120 120 | 
             
                end
         | 
| 121 121 |  | 
| 122 | 
            +
                def rerank(
         | 
| 123 | 
            +
                  query:,
         | 
| 124 | 
            +
                  documents:,
         | 
| 125 | 
            +
                  model: nil,
         | 
| 126 | 
            +
                  top_n: nil,
         | 
| 127 | 
            +
                  rank_fields: nil,
         | 
| 128 | 
            +
                  return_documents: nil,
         | 
| 129 | 
            +
                  max_chunks_per_doc: nil
         | 
| 130 | 
            +
                )
         | 
| 131 | 
            +
                  response = connection.post("rerank") do |req|
         | 
| 132 | 
            +
                    req.body = {
         | 
| 133 | 
            +
                      query: query,
         | 
| 134 | 
            +
                      documents: documents
         | 
| 135 | 
            +
                    }
         | 
| 136 | 
            +
                    req.body[:model] = model if model
         | 
| 137 | 
            +
                    req.body[:top_n] = top_n if top_n
         | 
| 138 | 
            +
                    req.body[:rank_fields] = rank_fields if rank_fields
         | 
| 139 | 
            +
                    req.body[:return_documents] = return_documents if return_documents
         | 
| 140 | 
            +
                    req.body[:max_chunks_per_doc] = max_chunks_per_doc if max_chunks_per_doc
         | 
| 141 | 
            +
                  end
         | 
| 142 | 
            +
                  response.body
         | 
| 143 | 
            +
                end
         | 
| 144 | 
            +
             | 
| 122 145 | 
             
                def classify(
         | 
| 123 146 | 
             
                  inputs:,
         | 
| 124 147 | 
             
                  examples:,
         | 
    
        data/lib/cohere/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cohere-ruby
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.9. | 
| 4 | 
            +
              version: 0.9.11
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Andrei Bondarev
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-08-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 70 70 | 
             
                - !ruby/object:Gem::Version
         | 
| 71 71 | 
             
                  version: '0'
         | 
| 72 72 | 
             
            requirements: []
         | 
| 73 | 
            -
            rubygems_version: 3. | 
| 73 | 
            +
            rubygems_version: 3.5.11
         | 
| 74 74 | 
             
            signing_key:
         | 
| 75 75 | 
             
            specification_version: 4
         | 
| 76 76 | 
             
            summary: Cohere API client for Ruby.
         |