jonathanjordan21 commited on
Commit
d2d9f68
·
verified ·
1 Parent(s): 0b40540

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -99,7 +99,7 @@ examples = [
99
  ]},
100
  {"code": "003", "examples": [
101
  "Alih kepemilikan kendaraan dengan plat F 3344 PQR",
102
- "Proses balik nama untuk kendaraan plat W 5566 STU",
103
  "Perubahan pemilik pada kendaraan plat AD 7788 VWX"
104
  ]},
105
  {"code": "004", "examples": [
@@ -228,7 +228,7 @@ model_id = model_ids[-1]
228
  model = SentenceTransformer(model_id, trust_remote_code=True)
229
 
230
  # codes_emb = model.encode([x[6:] for x in codes])
231
- codes_emb = model.encode([x["examples"] for x in examples])#.mean(axis=0)
232
 
233
 
234
  def censor_middle(number, num_to_hide=4):
@@ -302,16 +302,17 @@ def build_outputs(results, descriptions, result_details, plate_number):
302
 
303
  for i, (res,desc,detail) in enumerate(zip(results, descriptions, result_details)):
304
  harga_jual = vehicle["harga_jual"]
305
- out += f"{i+1}. {detail}\nRumus: {desc}\nDetail perhitungan: {desc.replace('harga_jual', harga_jual)} = {res}\n"
 
306
 
307
  # out += "----------------------------\nEstimasi biaya: "
308
  out += "\n\n\nEstimasi Biaya: "
309
 
310
  if len(results) > 1:
311
  out += " + ".join(["Rp{:,}".format(x) for x in results])
312
- out += " = {:,}".format(sum(results))
313
  else:
314
- out += "{:,}".format(results[0])
315
 
316
  out += "\n\n----------------------------"
317
  # out += "\n----------------------------\n\n--------------------------------"
@@ -501,7 +502,7 @@ def reload(chosen_model_id):
501
  model = SentenceTransformer(chosen_model_id, trust_remote_code=True)
502
  model_id = chosen_model_id
503
  # codes_emb = model.encode([x[6:] for x in codes])
504
- codes_emb = model.encode([x["examples"] for x in examples])#.mean(axis=0)
505
  return f"Model {chosen_model_id} has been succesfully loaded!"
506
  return f"Model {chosen_model_id} is ready!"
507
 
 
99
  ]},
100
  {"code": "003", "examples": [
101
  "Alih kepemilikan kendaraan dengan plat F 3344 PQR",
102
+ "Balik nama untuk kendaraan plat W 5566 STU",
103
  "Perubahan pemilik pada kendaraan plat AD 7788 VWX"
104
  ]},
105
  {"code": "004", "examples": [
 
228
  model = SentenceTransformer(model_id, trust_remote_code=True)
229
 
230
  # codes_emb = model.encode([x[6:] for x in codes])
231
+ codes_emb = model.encode([x["examples"] for x in examples]).mean(axis=1)
232
 
233
 
234
  def censor_middle(number, num_to_hide=4):
 
302
 
303
  for i, (res,desc,detail) in enumerate(zip(results, descriptions, result_details)):
304
  harga_jual = vehicle["harga_jual"]
305
+ res_str = "{:,}".format(res)
306
+ out += f"{i+1}. {detail}\nRumus: {desc}\nDetail perhitungan: {desc.replace('harga_jual', harga_jual)} = Rp{res_str}\n"
307
 
308
  # out += "----------------------------\nEstimasi biaya: "
309
  out += "\n\n\nEstimasi Biaya: "
310
 
311
  if len(results) > 1:
312
  out += " + ".join(["Rp{:,}".format(x) for x in results])
313
+ out += " = Rp{:,}".format(sum(results))
314
  else:
315
+ out += "Rp{:,}".format(results[0])
316
 
317
  out += "\n\n----------------------------"
318
  # out += "\n----------------------------\n\n--------------------------------"
 
502
  model = SentenceTransformer(chosen_model_id, trust_remote_code=True)
503
  model_id = chosen_model_id
504
  # codes_emb = model.encode([x[6:] for x in codes])
505
+ codes_emb = model.encode([x["examples"] for x in examples]).mean(axis=1)
506
  return f"Model {chosen_model_id} has been succesfully loaded!"
507
  return f"Model {chosen_model_id} is ready!"
508