Khachatur Mirijanyan commited on
Commit
9eb98fa
1 Parent(s): 65e27b3

Qury checking

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -5,11 +5,32 @@ from langchain.chat_models import ChatOpenAI
5
  from langchain.prompts.prompt import PromptTemplate
6
 
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def answer_question(query):
9
- if query.startswith("### Query"):
10
- split = query.split('\n\n')
11
- print(split)
12
- return("DONE: " + query)
 
 
 
 
 
 
 
13
 
14
  if __name__ == "__main__":
15
  import gradio as gr
 
5
  from langchain.prompts.prompt import PromptTemplate
6
 
7
 
8
+ def check_query(query):
9
+ if query.startswith("### Query"):
10
+ split = query.split('\n\n')
11
+ q_text = split[0]
12
+ t_text = split[1]
13
+
14
+ if t_text.startswith("### Tables"):
15
+ tables = t_text.split('\n')
16
+ print(tables[1:])
17
+ return('big')
18
+ else:
19
+ return('error')
20
+ return('small')
21
+
22
  def answer_question(query):
23
+ query_check = check_query(query)
24
+ if query_check == 'big':
25
+ return("BIG TABLE")
26
+ if query_check == 'small':
27
+ return('SMALL TABLE')
28
+ if query_check == 'error':
29
+ return('ERROR: Wrong format for getting the big db schema')
30
+
31
+
32
+
33
+ return("DONE: " + query)
34
 
35
  if __name__ == "__main__":
36
  import gradio as gr