DeMaking commited on
Commit
633d2c3
·
verified ·
1 Parent(s): 7a38f6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -29,7 +29,7 @@ def detect_language(user_input):
29
  current_time = time.gmtime().tm_hour+2, ":" , time.gmtime().tm_min , ":" , time.gmtime().tm_sec
30
  # lang = detect(user_input)
31
  lang, _ = langid.classify(user_input) # langid.classify returns a tuple (language, confidence)
32
- print(f"Detected language: {lang}", f"current time: {current_time}")
33
  return "hebrew" if lang == "he" else "english" if lang == "en" else "unsupported"
34
  except Exception as e:
35
  print(f"Language detection error: {e}")
@@ -48,16 +48,17 @@ def detect_language(user_input):
48
 
49
  def generate_response(text):
50
  language = detect_language(text)
51
- print(f"Detected language: {language}", f"current time: {current_time}") # Debugging
 
52
 
53
  if language == "hebrew":
54
  output = hebrew_generator(text, max_length=100, truncation=True)
55
- print(f"Hebrew model output: {output}", f"current time: {current_time}") # Debugging
56
  return output[0]["generated_text"]
57
 
58
  elif language == "english":
59
  output = english_generator(text, max_length=100, truncation=True)
60
- print(f"English model output: {output}", f"current time: {current_time}") # Debugging
61
  return output[0]["generated_text"]
62
 
63
  return "Sorry, I only support Hebrew and English."
 
29
  current_time = time.gmtime().tm_hour+2, ":" , time.gmtime().tm_min , ":" , time.gmtime().tm_sec
30
  # lang = detect(user_input)
31
  lang, _ = langid.classify(user_input) # langid.classify returns a tuple (language, confidence)
32
+ print(f"Detected language: {lang}, ", f"current time: {current_time}")
33
  return "hebrew" if lang == "he" else "english" if lang == "en" else "unsupported"
34
  except Exception as e:
35
  print(f"Language detection error: {e}")
 
48
 
49
  def generate_response(text):
50
  language = detect_language(text)
51
+ current_time = time.gmtime().tm_hour+2, ":" , time.gmtime().tm_min , ":" , time.gmtime().tm_sec
52
+ print(f"Detected language: {language}, ", f"current time: {current_time}") # Debugging
53
 
54
  if language == "hebrew":
55
  output = hebrew_generator(text, max_length=100, truncation=True)
56
+ print(f"Hebrew model output: {output}, ", f"current time: {current_time}") # Debugging
57
  return output[0]["generated_text"]
58
 
59
  elif language == "english":
60
  output = english_generator(text, max_length=100, truncation=True)
61
+ print(f"English model output: {output}, ", f"current time: {current_time}") # Debugging
62
  return output[0]["generated_text"]
63
 
64
  return "Sorry, I only support Hebrew and English."