victor7246 commited on
Commit
475edca
·
verified ·
1 Parent(s): 29cf82f

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +9 -12
utils.py CHANGED
@@ -82,24 +82,21 @@ metadata_df = pd.merge(metadata_df, metadata_df2, how='inner')
82
  table_search = EmbeddingsSearch(metadata_df=metadata_df, emb_model=emb_model)
83
 
84
  def extract_question_type(llm, query):
 
 
 
 
 
 
85
  messages = [
86
- (
87
- "system",
88
- """
89
- You are an AI assistant that determines if a question seeks any specific information about any item or any table or a generic information of the database. \
90
- Answer only "specific information" or "generic information".""",
91
- ),
92
  ("human", query),
93
  ]
 
94
  output = llm.invoke(messages)
95
  pred = output.content
96
 
97
- if 'generic' in pred:
98
- return 'generic'
99
- elif 'specific' in pred:
100
- return 'specific'
101
- else:
102
- return 'unknown'
103
 
104
  def extract_table_name(llm, query):
105
  messages = [
 
82
  table_search = EmbeddingsSearch(metadata_df=metadata_df, emb_model=emb_model)
83
 
84
  def extract_question_type(llm, query):
85
+ sys_prompt = """
86
+ You are an AI assistant that determines if a user provided question can be answered from the given tables.
87
+ The metadata of the tables are provided here - {}. \
88
+ If the question can be answered return yes.
89
+ If the question is a generic one and cannot be answered using these tables, return no.""".format(metadata_df[['table','metadata']].to_string())
90
+
91
  messages = [
92
+ ("system", sys_prompt),
 
 
 
 
 
93
  ("human", query),
94
  ]
95
+
96
  output = llm.invoke(messages)
97
  pred = output.content
98
 
99
+ return pred
 
 
 
 
 
100
 
101
  def extract_table_name(llm, query):
102
  messages = [