ShawnAI commited on
Commit
3f8dc6c
·
1 Parent(s): 32f8fd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -71,6 +71,7 @@ DOCS_DONE = get_status(DB_DONE, "processingfoundation", "right")
71
  TAB_1 = "Chatbot"
72
  TAB_2 = "Details"
73
  TAB_3 = "Database"
 
74
 
75
 
76
 
@@ -98,7 +99,7 @@ webui_title = """
98
  # OpenAI Chatbot Based on Vector Database
99
  """
100
 
101
- dup_link = f'''<a href="https://huggingface.co/spaces/ShawnAI/3GPP-ChatBot?duplicate=true"
102
  style="display:grid; width: 200px;">
103
  <img src="{get_logo(FORK_BADGE, "addthis")}"></a>'''
104
 
@@ -126,15 +127,6 @@ Question:
126
  Answer:"""
127
  )
128
 
129
- '''
130
- Optinal:
131
- Expand each clause/figure name in the answer with corresponding metadata file name.
132
-
133
- Desired format:
134
- Clause/figure name: <dot_separated_numbers>
135
- File name: *.*
136
- '''
137
-
138
  PROMPT_BASE = PromptTemplate(
139
  input_variables=['question', "chat_history"],
140
  template="""Chat History:
@@ -152,8 +144,17 @@ Answer:"""
152
 
153
  #----------------------------------------------------------------------------------------------------------
154
  #----------------------------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
155
 
156
  def init_model(api_key, emb_name, emb_loader, db_api_key, db_env, db_index):
 
157
  try:
158
  if not (api_key and api_key.startswith("sk-") and len(api_key) > 50):
159
  return None,MODEL_NULL+DOCS_NULL,None,None,None,None
@@ -212,7 +213,6 @@ def doc_similarity(query, db, top_k, score):
212
  k=top_k)
213
  #docsearch = db.as_retriever(search_kwargs={'k':top_k})
214
  #docs = docsearch.get_relevant_documents(query)
215
- print(docs)
216
  udocs = remove_duplicates(docs, score)
217
  return udocs
218
 
@@ -406,6 +406,10 @@ with gr.Blocks(
406
  lines=1,
407
  interactive=True,
408
  type='email')
 
 
 
 
409
 
410
  init_input = [llm_api_textbox, emb_textbox, emb_dropdown, db_api_textbox, db_env_textbox, db_index_textbox]
411
  init_output = [llm_api_textbox, model_statusbox,
 
71
  TAB_1 = "Chatbot"
72
  TAB_2 = "Details"
73
  TAB_3 = "Database"
74
+ TAB_4 = "TODO"
75
 
76
 
77
 
 
99
  # OpenAI Chatbot Based on Vector Database
100
  """
101
 
102
+ dup_link = f'''<a href="https://huggingface.co/spaces/ShawnAI/VectorDB-ChatBot?duplicate=true"
103
  style="display:grid; width: 200px;">
104
  <img src="{get_logo(FORK_BADGE, "addthis")}"></a>'''
105
 
 
127
  Answer:"""
128
  )
129
 
 
 
 
 
 
 
 
 
 
130
  PROMPT_BASE = PromptTemplate(
131
  input_variables=['question', "chat_history"],
132
  template="""Chat History:
 
144
 
145
  #----------------------------------------------------------------------------------------------------------
146
  #----------------------------------------------------------------------------------------------------------
147
+ def init_rwkv():
148
+ try:
149
+ import rwkv
150
+ return True
151
+ except Exception:
152
+ print("RWKV not found, skip local llm")
153
+ return False
154
+
155
 
156
  def init_model(api_key, emb_name, emb_loader, db_api_key, db_env, db_index):
157
+ init_rwkv()
158
  try:
159
  if not (api_key and api_key.startswith("sk-") and len(api_key) > 50):
160
  return None,MODEL_NULL+DOCS_NULL,None,None,None,None
 
213
  k=top_k)
214
  #docsearch = db.as_retriever(search_kwargs={'k':top_k})
215
  #docs = docsearch.get_relevant_documents(query)
 
216
  udocs = remove_duplicates(docs, score)
217
  return udocs
218
 
 
406
  lines=1,
407
  interactive=True,
408
  type='email')
409
+ with gr.Tab(TAB_4):
410
+ "TODO"
411
+
412
+
413
 
414
  init_input = [llm_api_textbox, emb_textbox, emb_dropdown, db_api_textbox, db_env_textbox, db_index_textbox]
415
  init_output = [llm_api_textbox, model_statusbox,