Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -358,57 +358,52 @@ if Usage == 'Ask me anything (CSV file data)!📊':
|
|
| 358 |
|
| 359 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 360 |
|
|
|
|
|
|
|
| 361 |
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
if response_graph['choices'][0]['text'] != "":
|
| 403 |
-
print(response_graph['choices'][0]['text'])
|
| 404 |
-
exec(response_graph['choices'][0]['text'])
|
| 405 |
-
|
| 406 |
-
else:
|
| 407 |
-
print('Retry! Graph could not be plotted *_*')
|
| 408 |
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
|
| 413 |
elif res == "Sample_Cars_csv":
|
| 414 |
df = pd.read_csv('cars.csv')
|
|
@@ -423,58 +418,52 @@ if Usage == 'Ask me anything (CSV file data)!📊':
|
|
| 423 |
|
| 424 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 425 |
|
|
|
|
|
|
|
| 426 |
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
result_tab = result_tab2.reset_index(drop=True)
|
| 448 |
-
result_tab_string = result_tab.to_string()
|
| 449 |
-
gr_prompt = text_plot + userPrompt + result_tab_string + "Plot graph for: "
|
| 450 |
-
|
| 451 |
-
if len(gr_prompt) > 4097:
|
| 452 |
-
st.write('OVERWHELMING DATA!!! You have given me more than 4097 tokens! ^_^')
|
| 453 |
-
st.write('As of today, the NLP model text-davinci-003 that I run on takes in inputs that have less than 4097 tokens. Kindly retry ^_^')
|
| 454 |
-
|
| 455 |
-
elif len(result_tab2.columns) < 2:
|
| 456 |
-
st.write("I need more data to conduct analysis and provide visualizations for you... ^_^")
|
| 457 |
-
|
| 458 |
-
else:
|
| 459 |
-
st.success("Plotting...")
|
| 460 |
-
response_graph = openai.Completion.create(
|
| 461 |
-
engine="text-davinci-003",
|
| 462 |
-
prompt = gr_prompt,
|
| 463 |
-
max_tokens=1024,
|
| 464 |
-
n=1,
|
| 465 |
-
stop=None,
|
| 466 |
-
temperature=0.5,
|
| 467 |
-
)
|
| 468 |
-
|
| 469 |
-
if response_graph['choices'][0]['text'] != "":
|
| 470 |
-
print(response_graph['choices'][0]['text'])
|
| 471 |
-
exec(response_graph['choices'][0]['text'])
|
| 472 |
-
|
| 473 |
-
else:
|
| 474 |
-
print('Retry! Graph could not be plotted *_*')
|
| 475 |
-
except:
|
| 476 |
-
results = gpt3(userPrompt)
|
| 477 |
-
st.success('loaded')
|
| 478 |
|
| 479 |
|
| 480 |
elif Usage == 'Ask me anything!😊':
|
|
|
|
| 358 |
|
| 359 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 360 |
|
| 361 |
+
userPrompt = st.text_area("Input Prompt",'Enter Natural Language Query')
|
| 362 |
+
submitButton = st.form_submit_button(label = 'Submit')
|
| 363 |
|
| 364 |
+
if submitButton:
|
| 365 |
+
try:
|
| 366 |
+
col_p ="Create SQL statement from instruction. "+ext+" " " (" + column +")." +" Request:" + userPrompt + "SQL statement:"
|
| 367 |
+
result = gpt3(col_p)
|
| 368 |
+
sqlOutput = result #st.text_area('SQL Query', value=gpt3(col_p))
|
| 369 |
+
warning(sqlOutput)
|
| 370 |
+
result_tab2=ps.sqldf(sqlOutput)
|
| 371 |
+
st.write(result_tab2)
|
| 372 |
+
with open("fewshot_matplot.txt", "r") as file:
|
| 373 |
+
text_plot = file.read()
|
| 374 |
+
|
| 375 |
+
result_tab = result_tab2.reset_index(drop=True)
|
| 376 |
+
result_tab_string = result_tab.to_string()
|
| 377 |
+
gr_prompt = text_plot + userPrompt + result_tab_string + "Plot graph for: "
|
| 378 |
+
|
| 379 |
+
if len(gr_prompt) > 4097:
|
| 380 |
+
st.write('OVERWHELMING DATA!!! You have given me more than 4097 tokens! ^_^')
|
| 381 |
+
st.write('As of today, the NLP model text-davinci-003/gpt-3.5-turbo that I run on takes in inputs that have less than 4097 tokens. Kindly retry ^_^')
|
| 382 |
+
|
| 383 |
+
elif len(result_tab2.columns) < 2:
|
| 384 |
+
st.write("I need more data to conduct analysis and provide visualizations for you... ^_^")
|
| 385 |
+
|
| 386 |
+
else:
|
| 387 |
+
st.success("Plotting...")
|
| 388 |
+
response_graph = openai.Completion.create(
|
| 389 |
+
engine="text-davinci-003",
|
| 390 |
+
prompt = gr_prompt,
|
| 391 |
+
max_tokens=1024,
|
| 392 |
+
n=1,
|
| 393 |
+
stop=None,
|
| 394 |
+
temperature=0.5,
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
if response_graph['choices'][0]['text'] != "":
|
| 398 |
+
print(response_graph['choices'][0]['text'])
|
| 399 |
+
exec(response_graph['choices'][0]['text'])
|
| 400 |
+
|
| 401 |
+
else:
|
| 402 |
+
print('Retry! Graph could not be plotted *_*')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
|
| 404 |
+
except:
|
| 405 |
+
results = gpt3(userPrompt)
|
| 406 |
+
st.success('loaded')
|
| 407 |
|
| 408 |
elif res == "Sample_Cars_csv":
|
| 409 |
df = pd.read_csv('cars.csv')
|
|
|
|
| 418 |
|
| 419 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 420 |
|
| 421 |
+
userPrompt = st.text_area("Input Prompt",'Enter Natural Language Query')
|
| 422 |
+
submitButton = st.form_submit_button(label = 'Submit')
|
| 423 |
|
| 424 |
+
if submitButton:
|
| 425 |
+
try:
|
| 426 |
+
col_p ="Create SQL statement from instruction. "+ext+" " " (" + column +")." +" Request:" + userPrompt + "SQL statement:"
|
| 427 |
+
result = gpt3(col_p)
|
| 428 |
+
sqlOutput = result #st.text_area('SQL Query', value=gpt3(col_p))
|
| 429 |
+
warning(sqlOutput)
|
| 430 |
+
result_tab2=ps.sqldf(sqlOutput)
|
| 431 |
+
st.write(result_tab2)
|
| 432 |
+
|
| 433 |
+
with open("fewshot_matplot.txt", "r") as file:
|
| 434 |
+
text_plot = file.read()
|
| 435 |
+
|
| 436 |
+
result_tab = result_tab2.reset_index(drop=True)
|
| 437 |
+
result_tab_string = result_tab.to_string()
|
| 438 |
+
gr_prompt = text_plot + userPrompt + result_tab_string + "Plot graph for: "
|
| 439 |
+
|
| 440 |
+
if len(gr_prompt) > 4097:
|
| 441 |
+
st.write('OVERWHELMING DATA!!! You have given me more than 4097 tokens! ^_^')
|
| 442 |
+
st.write('As of today, the NLP model text-davinci-003 that I run on takes in inputs that have less than 4097 tokens. Kindly retry ^_^')
|
| 443 |
+
|
| 444 |
+
elif len(result_tab2.columns) < 2:
|
| 445 |
+
st.write("I need more data to conduct analysis and provide visualizations for you... ^_^")
|
| 446 |
+
|
| 447 |
+
else:
|
| 448 |
+
st.success("Plotting...")
|
| 449 |
+
response_graph = openai.Completion.create(
|
| 450 |
+
engine="text-davinci-003",
|
| 451 |
+
prompt = gr_prompt,
|
| 452 |
+
max_tokens=1024,
|
| 453 |
+
n=1,
|
| 454 |
+
stop=None,
|
| 455 |
+
temperature=0.5,
|
| 456 |
+
)
|
| 457 |
|
| 458 |
+
if response_graph['choices'][0]['text'] != "":
|
| 459 |
+
print(response_graph['choices'][0]['text'])
|
| 460 |
+
exec(response_graph['choices'][0]['text'])
|
| 461 |
+
|
| 462 |
+
else:
|
| 463 |
+
print('Retry! Graph could not be plotted *_*')
|
| 464 |
+
except:
|
| 465 |
+
results = gpt3(userPrompt)
|
| 466 |
+
st.success('loaded')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 467 |
|
| 468 |
|
| 469 |
elif Usage == 'Ask me anything!😊':
|