quoc-khanh commited on
Commit
5ffcb10
·
verified ·
1 Parent(s): b729426

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -35,19 +35,19 @@ def augment_prompt(query: str, k: int = 10):
35
 
36
  if results:
37
  source_knowledge = "\n\n".join([doc.page_content for doc in results])
38
- return f"""Using the contexts below, answer the query.
39
- Contexts:
40
  {source_knowledge}
41
  """
42
  else:
43
- return f"No relevant context found.\n."
44
 
45
  def get_answer(query, queries_list=None):
46
  if queries_list is None:
47
  queries_list = []
48
-
49
  messages = [
50
- {"role": "user", "parts": [{"text": "IMPORTANT: You are a super energetic, helpful, polite, Vietnamese-speaking assistant. If you can not see the answer in contexts, try to search it up online by yourself but remember to give the source."}]},
51
  {"role": "user", "parts": [{"text": augment_prompt(query=query,k=100)}]}
52
  ]
53
  # bonus = '''
@@ -87,13 +87,15 @@ def get_answer(query, queries_list=None):
87
 
88
  log_message(messages)
89
 
90
- institutions = ['Tất cả'] + ['Trường Công Nghệ']
91
- categories = ['Tất cả'] + ['Đề án', 'Chương trình đào tạo']
 
 
92
 
93
  with gr.Blocks() as demo:
94
  with gr.Row():
95
- category1 = gr.Dropdown(choices = institutions, label="Trường", value = 'Tất cả')
96
- category2 = gr.Dropdown(choices = categories, label="Bạn quan tâm tới", value = 'Tất cả')
97
 
98
  chat_interface = gr.ChatInterface(get_answer,
99
  textbox=gr.Textbox(placeholder="Đặt câu hỏi tại đây",
 
35
 
36
  if results:
37
  source_knowledge = "\n\n".join([doc.page_content for doc in results])
38
+ return f"""Dữ liệu dưới đây liên quan đến Trường Công Nghệ (NCT) thuộc Đại học Kinh tế Quốc dân (NEU), dựa vào đó trả lời câu hỏi.
39
+ Dữ liệu:
40
  {source_knowledge}
41
  """
42
  else:
43
+ return f"Không thông tin liên quan. \n."
44
 
45
  def get_answer(query, queries_list=None):
46
  if queries_list is None:
47
  queries_list = []
48
+
49
  messages = [
50
+ {"role": "user", "parts": [{"text": "IMPORTANT: You are a super helpful, polite, Vietnamese-speaking asistant to give infomation of an university. If you can not see the answer in contexts, try to search it up online by yourself OR tell user to make a more detailed question."}]},
51
  {"role": "user", "parts": [{"text": augment_prompt(query=query,k=100)}]}
52
  ]
53
  # bonus = '''
 
87
 
88
  log_message(messages)
89
 
90
+ institutions = ['Tất cả', 'Trường Công Nghệ']
91
+ categories = ['Tất cả', 'Đề án', 'Chương trình đào tạo']
92
+
93
+ print("Launching on space... This may take some time...")
94
 
95
  with gr.Blocks() as demo:
96
  with gr.Row():
97
+ category1 = gr.Dropdown(choices = institutions, label="Trường", value = None)
98
+ category2 = gr.Dropdown(choices = categories, label="Bạn quan tâm tới", value = None)
99
 
100
  chat_interface = gr.ChatInterface(get_answer,
101
  textbox=gr.Textbox(placeholder="Đặt câu hỏi tại đây",