sotosbarl commited on
Commit
7cad2e4
·
verified ·
1 Parent(s): 3211a89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import pickle
4
  import streamlit as st
5
  device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
6
 
 
7
 
8
  def init_session_state():
9
  if 'history' not in st.session_state:
@@ -55,10 +56,27 @@ if text:
55
 
56
  answer = dictionary[output][output2]
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  st.session_state.history += "Based on the following information" + answer +"answer this question:" + text # Add new text to history
60
  out = pipe(st.session_state.history) # Generate output based on history
61
- st.text(out[0]['generated_text'])
 
 
 
62
  # st.text("History: " + st.session_state.history)
63
 
64
  # st.text(output)
 
4
  import streamlit as st
5
  device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
6
 
7
+ from translator import translate
8
 
9
  def init_session_state():
10
  if 'history' not in st.session_state:
 
56
 
57
  answer = dictionary[output][output2]
58
 
59
+ # Create a translator object with specified source and target languages
60
+ translator = Translator(from_lang='el', to_lang='en')
61
+ translator2 = Translator(from_lang='en', to_lang='el')
62
+
63
+
64
+
65
+ # Translate the text from Greek to English
66
+ answer = translator.translate(answer)
67
+ text = translator.translate(text)
68
+
69
+ # text_to_translate2 = text[499:999]
70
+ # translated_text2 = translator.translate(text_to_translate2)
71
+
72
+
73
 
74
  st.session_state.history += "Based on the following information" + answer +"answer this question:" + text # Add new text to history
75
  out = pipe(st.session_state.history) # Generate output based on history
76
+
77
+ translated_text2 = translator2.translate(out[0]['generated_text'])
78
+
79
+ st.text(translated_text2)
80
  # st.text("History: " + st.session_state.history)
81
 
82
  # st.text(output)