victor7246 commited on
Commit
20c1eaa
·
verified ·
1 Parent(s): 263d12d

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +20 -0
utils.py CHANGED
@@ -50,6 +50,26 @@ for sheet_name in xls.sheet_names:
50
 
51
  i += 1
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  class EmbeddingsSearch:
54
  def __init__(self, metadata_df, emb_model):
55
 
 
50
 
51
  i += 1
52
 
53
+ def extract_question_type(llm, query):
54
+ messages = [
55
+ (
56
+ "system",
57
+ """
58
+ 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. \
59
+ Answer only "specific information" or "generic information".""",
60
+ ),
61
+ ("human", query),
62
+ ]
63
+ output = llm.invoke(messages)
64
+ pred = output.content
65
+
66
+ if 'generic' in pred:
67
+ return 'generic'
68
+ elif 'specific' in pred:
69
+ return 'specific'
70
+ else:
71
+ return 'unknown'
72
+
73
  class EmbeddingsSearch:
74
  def __init__(self, metadata_df, emb_model):
75