immosquare-yaml 0.1.20 → 0.1.22

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: 467e395c6883993cd3a7496ca196e0aae40fc5b0b51159e8710b3b852cc8857f
4
- data.tar.gz: b066518248c9f75656bc6fc880f14d82a78aae511272f353df7319ec2ec69bdd
3
+ metadata.gz: 8ffd34ab4fce7d19ca43f4116c404ec6b419d72613752deae7400988cf26b2cb
4
+ data.tar.gz: 781daefa41c64ddbb5498bbcd0819980f1326378947a886e5a2a3d8a0aa775a2
5
5
  SHA512:
6
- metadata.gz: 64b828a55553839f8baa4f3da05ce2f2d7f7b6ef1d9a3340cf413467e27337db80b142ac7ae52742a74107175d7baa169e1fd7eab21d383b94888b2f754fd1ba
7
- data.tar.gz: 7583b3bc085e7c25808cc4a0caec2b03cdd825929d7e79aa365b494a4546afbb0f9c3d393500c346fd640a4728e6f98abd70be21d948ce695e5efc0d82311c0b
6
+ metadata.gz: '080b28c941dca4ff82714c01ad5b3301ab7ae0d6867e10c8d2a4021f1d954a3db9ca40d519a8a241cb19c1fe02183c7bdf98a3f0fb45ee80ed5e897d315fde13'
7
+ data.tar.gz: 88177866769f1672b7a040cccea44139978b00b5dee6b0b3d07af65103a0ac9aa9a8eea04ba9b068ae6b9b8fdacaf5112ad2b101f7858184a124f1a73398691c
@@ -92,8 +92,12 @@ module ImmosquareYaml
92
92
  ##============================================================##
93
93
  ## Then we have to reformat the output yml file
94
94
  ##============================================================##
95
- final_array = translated_array.map {|k, _from, to| [k, to] }
96
- final_hash = translatable_hash(final_array)
95
+ final_array = translated_array.map do |k, _from, to|
96
+ parsed_to = to.start_with?("[") && to.end_with?("]") ? JSON.parse(to) : to
97
+ [k, parsed_to]
98
+ end
99
+ final_hash = translatable_hash(final_array)
100
+
97
101
 
98
102
  ##============================================================##
99
103
  ## We write the output file and clean it
@@ -136,7 +140,7 @@ module ImmosquareYaml
136
140
  end
137
141
  else
138
142
  r2 = options[:format] == "string" ? key.split(":").join(".") : key.split(":")
139
- result << (options[:keys_only] ? r2 : [r2, hash])
143
+ result << (options[:keys_only] ? r2 : [r2, hash.is_a?(Array) ? hash.to_json : hash])
140
144
  end
141
145
  result
142
146
  end
@@ -181,7 +185,7 @@ module ImmosquareYaml
181
185
  {:name => "gpt-4-1106-preview", :tokens => 128_000, :input => 0.0100, :output => 0.030, :group_size => 2400}
182
186
  ]
183
187
  model = models.find {|m| m[:name] == model_name }
184
- model = models.find {|m| m[:name] == "gpt-3.5-turbo-16k" } if model.nil?
188
+ model = models.find {|m| m[:name] == "gpt-4-1106-preview" } if model.nil?
185
189
 
186
190
  ##============================================================##
187
191
  ## Manage blank values
@@ -229,12 +233,16 @@ module ImmosquareYaml
229
233
  prompt_system = "You are a translation tool from #{from_iso} to #{to_iso}\n" \
230
234
  "The input is an array of pairs, where each pair contains an index and a string to translate, formatted as [index, string_to_translate]\n" \
231
235
  "Your task is to create an output ARRAY where each element is a pair consisting of the index and the translated string, formatted as [index, 'string_translated']\n" \
232
- "\nRules to respect:\n" \
236
+ "If a string_to_translate starts with [ and ends with ], it is considered a special string that should be treated as a JSON object. Otherwise, it's a normal string.\n" \
237
+ "\nRules to respect for JSON objects:\n" \
238
+ "- You need to translate ONLY the values of the JSON object, not the keys. Do not change anything in the format, just translate the values.\n" \
239
+ "- Respect all following rules for normal strings to translate the values\n" \
240
+ "\nRules to respect for normal strings:\n" \
233
241
  "- Do not escape apostrophes in translated strings; leave them as they are.\n" \
234
242
  "- Special characters, except apostrophes, that need to be escaped in translated strings should be escaped using a single backslash (\\), not double (\\\\).\n" \
235
243
  "- If a string cannot be translated use the string '#{cant_be_translated}' translated as the translation value witouth quote (simple or double) quote, just the string\n" \
236
244
  "- If you dont know the correct translatation use the #{cant_be_translated} strategy of the preceding point\n" \
237
- "- Use only doubles quotes (\") to enclose translated strings and avoid using single quotes (').\n" \
245
+ "- Use only double quotes (\") to enclose translated strings and avoid using single quotes (').\n" \
238
246
  "- Your output must ONLY be an array with the same number of pairs as the input, without any additional text or explanation. DO NOT COMMENT!\n" \
239
247
  "- You need to check that the globle array is correctly closed at the end of the response. (the response must therefore end with ]] to to be consistent)"
240
248
  prompt_init = "Please proceed with translating the following array:"
@@ -1,3 +1,3 @@
1
1
  module ImmosquareYaml
2
- VERSION = "0.1.20".freeze
2
+ VERSION = "0.1.22".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - IMMO SQUARE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '0'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.1.13
36
+ version: 0.1.14
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.1.13
46
+ version: 0.1.14
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: iso-639
49
49
  requirement: !ruby/object:Gem::Requirement