|
18 | 18 | it "returns a response" do |
19 | 19 | expect(instance.generate( |
20 | 20 | prompt: "Once upon a time in a magical land called" |
21 | | - ).dig('generations').first.dig('text')).to eq(" The Past there was a Game called Warhammer Fantasy Battle.") |
| 21 | + ).dig("generations").first.dig("text")).to eq(" The Past there was a Game called Warhammer Fantasy Battle.") |
22 | 22 | end |
23 | 23 | end |
24 | 24 |
|
|
35 | 35 | it "returns a response" do |
36 | 36 | expect(instance.embed( |
37 | 37 | texts: ["hello!"] |
38 | | - ).dig('embeddings')).to eq([[ 1.2177734, 0.67529297, 2.0742188 ]]) |
| 38 | + ).dig("embeddings")).to eq([[1.2177734, 0.67529297, 2.0742188]]) |
39 | 39 | end |
40 | 40 | end |
41 | 41 |
|
42 | 42 | describe "#classify" do |
43 | 43 | let(:classify_result) { JSON.parse(File.read("spec/fixtures/classify_result.json")) } |
44 | 44 | let(:response) { OpenStruct.new(body: classify_result) } |
45 | 45 |
|
46 | | - let(:inputs) {[ |
47 | | - { text: "Dermatologists don't like her!", label: "Spam" }, |
48 | | - { text: "Hello, open to this?", label: "Spam" } |
49 | | - ]} |
50 | | - |
51 | | - let(:examples) {[ |
52 | | - "Confirm your email address", |
53 | | - "hey i need u to send some $" |
54 | | - ]} |
| 46 | + let(:inputs) { |
| 47 | + [ |
| 48 | + {text: "Dermatologists don't like her!", label: "Spam"}, |
| 49 | + {text: "Hello, open to this?", label: "Spam"} |
| 50 | + ] |
| 51 | + } |
| 52 | + |
| 53 | + let(:examples) { |
| 54 | + [ |
| 55 | + "Confirm your email address", |
| 56 | + "hey i need u to send some $" |
| 57 | + ] |
| 58 | + } |
55 | 59 |
|
56 | 60 | before do |
57 | 61 | allow_any_instance_of(Faraday::Connection).to receive(:post) |
|
63 | 67 | res = instance.classify( |
64 | 68 | inputs: inputs, |
65 | 69 | examples: examples |
66 | | - ).dig('classifications') |
| 70 | + ).dig("classifications") |
67 | 71 |
|
68 | | - expect(res.first.dig('prediction')).to eq("Not spam") |
69 | | - expect(res.last.dig('prediction')).to eq("Spam") |
| 72 | + expect(res.first.dig("prediction")).to eq("Not spam") |
| 73 | + expect(res.last.dig("prediction")).to eq("Spam") |
70 | 74 | end |
71 | 75 | end |
72 | 76 |
|
|
83 | 87 | it "returns a response" do |
84 | 88 | expect(instance.tokenize( |
85 | 89 | text: "Hello, world!" |
86 | | - ).dig('tokens')).to eq([33555, 1114 , 34]) |
| 90 | + ).dig("tokens")).to eq([33555, 1114, 34]) |
87 | 91 | end |
88 | 92 | end |
89 | 93 |
|
|
99 | 103 |
|
100 | 104 | it "returns a response" do |
101 | 105 | expect(instance.detokenize( |
102 | | - tokens: [33555, 1114 , 34] |
103 | | - ).dig('text')).to eq("hello world!") |
| 106 | + tokens: [33555, 1114, 34] |
| 107 | + ).dig("text")).to eq("hello world!") |
104 | 108 | end |
105 | 109 | end |
106 | 110 |
|
|
117 | 121 | it "returns a response" do |
118 | 122 | expect(instance.detect_language( |
119 | 123 | texts: ["Здравствуй, Мир"] |
120 | | - ).dig('results').first.dig('language_code')).to eq("ru") |
| 124 | + ).dig("results").first.dig("language_code")).to eq("ru") |
121 | 125 | end |
122 | 126 | end |
123 | 127 |
|
|
133 | 137 |
|
134 | 138 | it "returns a response" do |
135 | 139 | expect(instance.summarize( |
136 | | - text: "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. " + |
137 | | - "It may be made from milk or cream and is flavoured with a sweetener, " + |
138 | | - "either sugar or an alternative, and a spice, such as cocoa or vanilla, " + |
139 | | - "or with fruit such as strawberries or peaches. " + |
140 | | - "It can also be made by whisking a flavored cream base and liquid nitrogen together. " + |
141 | | - "Food coloring is sometimes added, in addition to stabilizers. " + |
142 | | - "The mixture is cooled below the freezing point of water and stirred to incorporate air spaces " + |
143 | | - "and to prevent detectable ice crystals from forming. The result is a smooth, " + |
144 | | - "semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). " + |
145 | | - "It becomes more malleable as its temperature increases.\n\n" + |
146 | | - "The meaning of the name \"ice cream\" varies from one country to another. " + |
147 | | - "In some countries, such as the United States, \"ice cream\" applies only to a specific variety, " + |
148 | | - "and most governments regulate the commercial use of the various terms according to the " + |
149 | | - "relative quantities of the main ingredients, notably the amount of cream. " + |
150 | | - "Products that do not meet the criteria to be called ice cream are sometimes labelled " + |
151 | | - "\"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, " + |
152 | | - "one word is used fo\r all variants. Analogues made from dairy alternatives, " + |
153 | | - "such as goat's or sheep's milk, or milk substitutes " + |
154 | | - "(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are " + |
| 140 | + text: "Ice cream is a sweetened frozen food typically eaten as a snack or dessert. " \ |
| 141 | + "It may be made from milk or cream and is flavoured with a sweetener, " \ |
| 142 | + "either sugar or an alternative, and a spice, such as cocoa or vanilla, " \ |
| 143 | + "or with fruit such as strawberries or peaches. " \ |
| 144 | + "It can also be made by whisking a flavored cream base and liquid nitrogen together. " \ |
| 145 | + "Food coloring is sometimes added, in addition to stabilizers. " \ |
| 146 | + "The mixture is cooled below the freezing point of water and stirred to incorporate air spaces " \ |
| 147 | + "and to prevent detectable ice crystals from forming. The result is a smooth, " \ |
| 148 | + "semi-solid foam that is solid at very low temperatures (below 2 °C or 35 °F). " \ |
| 149 | + "It becomes more malleable as its temperature increases.\n\n" \ |
| 150 | + "The meaning of the name \"ice cream\" varies from one country to another. " \ |
| 151 | + "In some countries, such as the United States, \"ice cream\" applies only to a specific variety, " \ |
| 152 | + "and most governments regulate the commercial use of the various terms according to the " \ |
| 153 | + "relative quantities of the main ingredients, notably the amount of cream. " \ |
| 154 | + "Products that do not meet the criteria to be called ice cream are sometimes labelled " \ |
| 155 | + "\"frozen dairy dessert\" instead. In other countries, such as Italy and Argentina, " \ |
| 156 | + "one word is used fo\r all variants. Analogues made from dairy alternatives, " \ |
| 157 | + "such as goat's or sheep's milk, or milk substitutes " \ |
| 158 | + "(e.g., soy, cashew, coconut, almond milk or tofu), are available for those who are " \ |
155 | 159 | "lactose intolerant, allergic to dairy protein or vegan." |
156 | | - ).dig('summary')).to eq("Ice cream is a frozen dessert made from dairy products or non-dairy substitutes. It is flavoured with a sweetener and a spice or with fruit. It is smooth and semi-solid at low temperatures.") |
| 160 | + ).dig("summary")).to eq("Ice cream is a frozen dessert made from dairy products or non-dairy substitutes. It is flavoured with a sweetener and a spice or with fruit. It is smooth and semi-solid at low temperatures.") |
157 | 161 | end |
158 | 162 | end |
159 | 163 | end |
0 commit comments