immosquare-yaml 0.1.21 → 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: eb8fa449311d2f5050d1c9b004b591195344348bfdc5c28825df74effed3610a
4
- data.tar.gz: 9327e7cebd1deb38a7c961d321bf1ee9c392aaf61e6bc53851d538c046b99fc5
3
+ metadata.gz: 8ffd34ab4fce7d19ca43f4116c404ec6b419d72613752deae7400988cf26b2cb
4
+ data.tar.gz: 781daefa41c64ddbb5498bbcd0819980f1326378947a886e5a2a3d8a0aa775a2
5
5
  SHA512:
6
- metadata.gz: 4873290094d7da13c38b49f970d566a77746e7f0afc7a5b220f0564cd3ee8f66004d057c261fc26a7cbbf8f19807d7b5fbf18c5b69d81eee7810e8d8b1dde1ba
7
- data.tar.gz: 20c8fa3977965b53f96a8062cba5f3d67906da7ded237fba21a611574fc66b3a9e6d540827832cfd6f026d1b887dba68d9bfdbdde402108ba6e3dca46dc5602a
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.21".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.21
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