Update app.py
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ sql_tokenizer = TapexTokenizer.from_pretrained(sql_model_name)
|
|
64 |
sql_model = BartForConditionalGeneration.from_pretrained(sql_model_name)
|
65 |
|
66 |
#sql_response = None
|
67 |
-
|
68 |
|
69 |
def chat(input, history=[]):
|
70 |
|
@@ -99,7 +99,7 @@ def chat(input, history=[]):
|
|
99 |
|
100 |
def sqlquery(input, history=[]):
|
101 |
|
102 |
-
|
103 |
|
104 |
#input_text = " ".join(conversation_history) + " " + input
|
105 |
sql_encoding = sql_tokenizer(table=table, query=input + sql_tokenizer.eos_token, return_tensors="pt")
|
@@ -117,9 +117,9 @@ def sqlquery(input, history=[]):
|
|
117 |
return output
|
118 |
'''
|
119 |
|
120 |
-
history.append((input, sql_response))
|
121 |
-
|
122 |
-
|
123 |
|
124 |
# Build conversation string
|
125 |
#conversation = "\n".join([f"User: {user_msg}\nBot: {resp_msg}" for user_msg, resp_msg in history])
|
@@ -154,10 +154,10 @@ sql_interface = gr.Interface(
|
|
154 |
fn=sqlquery,
|
155 |
theme="default",
|
156 |
css=".footer {display:none !important}",
|
157 |
-
|
158 |
-
|
159 |
-
inputs=["text", "state"],
|
160 |
-
outputs=["chatbot", "state"],
|
161 |
#live=True,
|
162 |
#capture_session=True,
|
163 |
title="ST SQL Chat",
|
|
|
64 |
sql_model = BartForConditionalGeneration.from_pretrained(sql_model_name)
|
65 |
|
66 |
#sql_response = None
|
67 |
+
conversation_history = []
|
68 |
|
69 |
def chat(input, history=[]):
|
70 |
|
|
|
99 |
|
100 |
def sqlquery(input, history=[]):
|
101 |
|
102 |
+
global conversation_history
|
103 |
|
104 |
#input_text = " ".join(conversation_history) + " " + input
|
105 |
sql_encoding = sql_tokenizer(table=table, query=input + sql_tokenizer.eos_token, return_tensors="pt")
|
|
|
117 |
return output
|
118 |
'''
|
119 |
|
120 |
+
#history.append((input, sql_response))
|
121 |
+
conversation_history.append(("User", input))
|
122 |
+
conversation_history.append(("Bot", sql_response))
|
123 |
|
124 |
# Build conversation string
|
125 |
#conversation = "\n".join([f"User: {user_msg}\nBot: {resp_msg}" for user_msg, resp_msg in history])
|
|
|
154 |
fn=sqlquery,
|
155 |
theme="default",
|
156 |
css=".footer {display:none !important}",
|
157 |
+
inputs=gr.Textbox(prompt="You:"),
|
158 |
+
outputs=gr.Textbox(),
|
159 |
+
#inputs=["text", "state"],
|
160 |
+
#outputs=["chatbot", "state"],
|
161 |
#live=True,
|
162 |
#capture_session=True,
|
163 |
title="ST SQL Chat",
|