immosquare-yaml 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-yaml/translate.rb +5 -5
- data/lib/immosquare-yaml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102b670cbd77856784f8051dfff363ba411293f4217e148eaf4447138e6c2d25
|
4
|
+
data.tar.gz: 43122f8196ceca963ec2ec5c51f3fc93acc197e6e5c6099b76e8837c005197bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30dcf484b803bb10b1ee9971fb5163145d0a89bf33df6dcf2f31ee54d8c76fe32a2adf971828a41fe3a8e7f29956af922647bbfe1f627d5226e18eda332aea8e
|
7
|
+
data.tar.gz: 9e753f4266747162034265ef7b43c727ee297d3ee8fd2bd7414ad935593d2dbe305e773a7ecf05cf4bd5681aa16be1c88402b6052a72958dd44b6509a446610a
|
@@ -229,14 +229,14 @@ module ImmosquareYaml
|
|
229
229
|
ai_resuslts = []
|
230
230
|
prompt_system = "You are a translation tool from #{from_iso} to #{to_iso}\n" \
|
231
231
|
"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" \
|
232
|
-
"Your task is to create an output
|
232
|
+
"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" \
|
233
233
|
"\nRules to respect:\n" \
|
234
234
|
"- Do not escape apostrophes in translated strings; leave them as they are.\n" \
|
235
235
|
"- Special characters, except apostrophes, that need to be escaped in translated strings should be escaped using a single backslash (\\), not double (\\\\).\n" \
|
236
236
|
"- 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" \
|
237
237
|
"- If you dont know the correct translatation use the #{cant_be_translated} strategy of the preceding point\n" \
|
238
238
|
"- Use only doubles quotes (\") to enclose translated strings and avoid using single quotes (').\n" \
|
239
|
-
"- Your output must ONLY be an array with the same number of pairs as the input, without any additional text or explanation
|
239
|
+
"- 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" \
|
240
240
|
"- 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)"
|
241
241
|
prompt_init = "Please proceed with translating the following array:"
|
242
242
|
headers = {
|
@@ -248,13 +248,13 @@ module ImmosquareYaml
|
|
248
248
|
##============================================================##
|
249
249
|
## Loop
|
250
250
|
##============================================================##
|
251
|
-
puts("fields to translate : #{data_open_ai.size}#{" by group of #{group_size}" if data_open_ai.size > group_size}")
|
251
|
+
puts("fields to translate from #{from_iso} (#{from}) to #{to_iso} (#{to}) : #{data_open_ai.size}#{" by group of #{group_size}" if data_open_ai.size > group_size}")
|
252
252
|
while index < data_open_ai.size
|
253
253
|
data_group = data_open_ai[index, group_size]
|
254
254
|
|
255
255
|
|
256
256
|
begin
|
257
|
-
puts("call OPENAI Api (with model #{model[:name]}) #{" for #{data_group.size} fields" if data_open_ai.size > group_size}")
|
257
|
+
puts("call OPENAI Api (with model #{model[:name]}) #{" for #{data_group.size} fields (#{index}-#{index+data_group.size})" if data_open_ai.size > group_size}")
|
258
258
|
prompt = "#{prompt_init}:\n\n#{data_group.inspect}\n\n"
|
259
259
|
body = {
|
260
260
|
:model => model[:name],
|
@@ -265,7 +265,7 @@ module ImmosquareYaml
|
|
265
265
|
:temperature => 0.0
|
266
266
|
}
|
267
267
|
t0 = Time.now
|
268
|
-
call = HTTParty.post("https://api.openai.com/v1/chat/completions", :body => body.to_json, :headers => headers, :timeout =>
|
268
|
+
call = HTTParty.post("https://api.openai.com/v1/chat/completions", :body => body.to_json, :headers => headers, :timeout => 500)
|
269
269
|
|
270
270
|
puts("responded in #{(Time.now - t0).round(2)} seconds")
|
271
271
|
raise(call["error"]["message"]) if call.code != 200
|
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.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iso-639
|