Walterchamy commited on
Commit
d786467
1 Parent(s): 0c99da6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -54
app.py CHANGED
@@ -100,57 +100,9 @@ For contact information:
100
  - Email: [email protected]
101
  - P.O. Box 3172, Arusha
102
  """
103
-
104
- #def generate_response(user_input):
105
- # response = openai.ChatCompletion.create(
106
- # model="gpt-3.5-turbo",
107
- # messages=[
108
- # {"role": "system", "content": "All your answers should be in Swahili or English. Consider the language that the user has asked with, and your kiitec virtual assistant your designed or created by WALTER RICHARD So, here we start... Your virtual assistant of DON BOSCO KIITEC. You will reply to the queries that the user might ask!\n\n" + KIITEC_CONTENT},
109
- # {"role": "assistant", "content": "Hi, how can i assist you today?"},
110
- # {"role": "user", "content": user_input},
111
- # ]
112
- # )
113
- # return response['choices'][0]['message']['content']
114
- #
115
-
116
- #def text_to_speech(text):
117
- # # Create a text-to-speech object
118
- # tts = gTTS(text=text, lang=('en'))
119
- # # Save the audio file
120
- # tts.save('output.mp3')
121
- #
122
- # # Play the audio file
123
- # st.audio("output.mp3")
124
- #
125
- #def main():
126
- #
127
- # col1, col2 = st.columns([1, 4])
128
- #
129
- # with col1:
130
- # st.image('logo.png', caption=None, width=200, use_column_width=200)
131
- #
132
- # with col2:
133
- # st.markdown("<h4 style='text-align: center; color: white;'>KILIMANJARO INTERNATIONAL INSTITUTE FOR TELECOMMUNICATION, ELECTRONICS & COMPUTERS</h4>", unsafe_allow_html=True)
134
- # st.header("KIITEC VIRTUAL ASSISTANT")
135
- # st.write("Welcome for questions concerning kiitec insitution")
136
- # user_input = st.text_input("Enter your question:")
137
- # if st.button("Answer"):
138
- # with st.spinner("Generating Response...."):
139
- # response_text = generate_response(user_input)
140
- # st.write("Answer:", response_text)
141
- # text_to_speech(response_text)
142
- #
143
- #if __name__ == '__main__':
144
- # main()
145
-
146
-
147
-
148
- # create OpenAI client
149
- # create OpenAI client
150
  client = OpenAI()
151
 
152
  def generate_response(user_input):
153
- #prompt = "All your answers should be in Swahili or English. Consider the language that the user has asked with, and your kiitec virtual assistant your designed or created by WALTER RICHARD So, here we start... Your virtual assistant of DON BOSCO KIITEC. You will reply to the queries that the user might ask!\n\n" + KIITEC_CONTENT
154
  response = client.completions.create(
155
  model="gpt-3.5-turbo",
156
  messages=[
@@ -159,18 +111,20 @@ def generate_response(user_input):
159
  {"role": "user", "content": user_input},
160
  ]
161
  )
 
162
  return response.choices[0].message.content
163
 
164
  def text_to_speech(text):
165
- # Create a text-to-speech object
166
- tts = gTTS(text=text, lang='en')
167
- # Save the audio file
168
  tts.save('output.mp3')
169
 
170
- # Play the audio file
171
  st.audio("output.mp3")
172
 
173
  def main():
 
174
  col1, col2 = st.columns([1, 4])
175
 
176
  with col1:
@@ -179,7 +133,7 @@ def main():
179
  with col2:
180
  st.markdown("<h4 style='text-align: center; color: white;'>KILIMANJARO INTERNATIONAL INSTITUTE FOR TELECOMMUNICATION, ELECTRONICS & COMPUTERS</h4>", unsafe_allow_html=True)
181
  st.header("KIITEC VIRTUAL ASSISTANT")
182
- st.write("Welcome for questions concerning kiitec institution")
183
  user_input = st.text_input("Enter your question:")
184
  if st.button("Answer"):
185
  with st.spinner("Generating Response...."):
@@ -188,4 +142,51 @@ def main():
188
  text_to_speech(response_text)
189
 
190
  if __name__ == '__main__':
191
- main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  - Email: [email protected]
101
  - P.O. Box 3172, Arusha
102
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  client = OpenAI()
104
 
105
  def generate_response(user_input):
 
106
  response = client.completions.create(
107
  model="gpt-3.5-turbo",
108
  messages=[
 
111
  {"role": "user", "content": user_input},
112
  ]
113
  )
114
+ #return response['choices'][0]['message']['content']
115
  return response.choices[0].message.content
116
 
117
  def text_to_speech(text):
118
+ Create a text-to-speech object
119
+ tts = gTTS(text=text, lang=('en'))
120
+ # # Save the audio file
121
  tts.save('output.mp3')
122
 
123
+ # # Play the audio file
124
  st.audio("output.mp3")
125
 
126
  def main():
127
+
128
  col1, col2 = st.columns([1, 4])
129
 
130
  with col1:
 
133
  with col2:
134
  st.markdown("<h4 style='text-align: center; color: white;'>KILIMANJARO INTERNATIONAL INSTITUTE FOR TELECOMMUNICATION, ELECTRONICS & COMPUTERS</h4>", unsafe_allow_html=True)
135
  st.header("KIITEC VIRTUAL ASSISTANT")
136
+ st.write("Welcome for questions concerning kiitec insitution")
137
  user_input = st.text_input("Enter your question:")
138
  if st.button("Answer"):
139
  with st.spinner("Generating Response...."):
 
142
  text_to_speech(response_text)
143
 
144
  if __name__ == '__main__':
145
+ main()
146
+
147
+
148
+
149
+ # create OpenAI client
150
+ # create OpenAI client
151
+ #client = OpenAI()
152
+
153
+ #def generate_response(user_input):
154
+ #prompt = "All your answers should be in Swahili or English. Consider the language that the user has asked with, and your kiitec virtual assistant your designed or created by WALTER RICHARD So, here we start... Your virtual assistant of DON BOSCO KIITEC. You will reply to the queries that the user might ask!\n\n" + KIITEC_CONTENT
155
+ # response = client.completions.create(
156
+ # engine="gpt-3.5-turbo",
157
+ # messages=[
158
+ # {"role": "system", "content": "All your answers should be in Swahili or English. Consider the language that the user has asked with, and your kiitec virtual assistant your designed or created by WALTER RICHARD So, here we start... Your virtual assistant of DON BOSCO KIITEC. You will reply to the queries that the user might ask!\n\n" + KIITEC_CONTENT},
159
+ # {"role": "assistant", "content": "Hi, how can i assist you today?"},
160
+ # {"role": "user", "content": user_input},
161
+ # ]
162
+ # )
163
+ # return response.choices[0].message.content
164
+
165
+ #def text_to_speech(text):
166
+ # Create a text-to-speech object
167
+ # tts = gTTS(text=text, lang='en')
168
+ # Save the audio file
169
+ # tts.save('output.mp3')
170
+
171
+ # Play the audio file
172
+ # st.audio("output.mp3")
173
+
174
+ #def main():
175
+ # col1, col2 = st.columns([1, 4])
176
+
177
+ # with col1:
178
+ # st.image('logo.png', caption=None, width=200, use_column_width=200)
179
+
180
+ # with col2:
181
+ # st.markdown("<h4 style='text-align: center; color: white;'>KILIMANJARO INTERNATIONAL INSTITUTE FOR TELECOMMUNICATION, ELECTRONICS & COMPUTERS</h4>", unsafe_allow_html=True)
182
+ # st.header("KIITEC VIRTUAL ASSISTANT")
183
+ # st.write("Welcome for questions concerning kiitec institution")
184
+ # user_input = st.text_input("Enter your question:")
185
+ # if st.button("Answer"):
186
+ # with st.spinner("Generating Response...."):
187
+ # response_text = generate_response(user_input)
188
+ # st.write("Answer:", response_text)
189
+ # text_to_speech(response_text)
190
+
191
+ #if __name__ == '__main__':
192
+ # main()