Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -203,7 +203,7 @@ def search_internet(question):
|
|
| 203 |
# snippets
|
| 204 |
|
| 205 |
response = openai.Completion.create(
|
| 206 |
-
model="text-davinci-
|
| 207 |
prompt=f'''following are snippets from google search with these as knowledge base only answer questions and print reference link as well followed by answer. \n\n {snippets}\n\n question-{question}\n\nAnswer-''',
|
| 208 |
temperature=0.49,
|
| 209 |
max_tokens=256,
|
|
@@ -324,7 +324,7 @@ drawings, abstract art 🎨, play music 🎵 or videos, create tweets 🐦 and p
|
|
| 324 |
all with the help of HyperBot! 🤖 ✨
|
| 325 |
''')
|
| 326 |
|
| 327 |
-
option_ = ['
|
| 328 |
Usage = st.selectbox('Select an option:', option_)
|
| 329 |
|
| 330 |
if Usage == 'Questions based on custom CSV data':
|
|
@@ -359,23 +359,22 @@ if Usage == 'Questions based on custom CSV data':
|
|
| 359 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 360 |
|
| 361 |
|
| 362 |
-
with st.form(key='
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
try:
|
| 376 |
sqlOutput = gpt3(col_p) #st.text_area('SQL Query', value=gpt3(col_p))
|
| 377 |
warning(sqlOutput)
|
| 378 |
-
cars=pd.read_csv('cars.csv')
|
| 379 |
result_tab2=ps.sqldf(sqlOutput)
|
| 380 |
st.write(result_tab2)
|
| 381 |
with open("fewshot_matplot.txt", "r") as file:
|
|
@@ -410,9 +409,6 @@ if Usage == 'Questions based on custom CSV data':
|
|
| 410 |
else:
|
| 411 |
print('Retry! Graph could not be plotted *_*')
|
| 412 |
|
| 413 |
-
except:
|
| 414 |
-
pass
|
| 415 |
-
|
| 416 |
elif res == "Sample_Cars_csv":
|
| 417 |
df = pd.read_csv('cars.csv')
|
| 418 |
col= df.columns
|
|
@@ -427,63 +423,59 @@ if Usage == 'Questions based on custom CSV data':
|
|
| 427 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 428 |
|
| 429 |
|
| 430 |
-
with st.form(key='
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
try:
|
| 437 |
-
col_p ="Create SQL statement from instruction. "+ext+" " " (" + column +")." +" Request:" + userPrompt + "SQL statement:"
|
| 438 |
-
result = gpt3(col_p)
|
| 439 |
-
except:
|
| 440 |
-
results = gpt3(userPrompt)
|
| 441 |
-
st.success('loaded')
|
| 442 |
-
with col4:
|
| 443 |
try:
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
|
|
|
|
|
|
|
|
|
| 485 |
|
| 486 |
-
elif Usage == '
|
| 487 |
st.text('''You can ask me:
|
| 488 |
1. All the things you ask ChatGPT.
|
| 489 |
2. Generating paintings, drawings, abstract art.
|
|
|
|
| 203 |
# snippets
|
| 204 |
|
| 205 |
response = openai.Completion.create(
|
| 206 |
+
model="text-davinci-003",
|
| 207 |
prompt=f'''following are snippets from google search with these as knowledge base only answer questions and print reference link as well followed by answer. \n\n {snippets}\n\n question-{question}\n\nAnswer-''',
|
| 208 |
temperature=0.49,
|
| 209 |
max_tokens=256,
|
|
|
|
| 324 |
all with the help of HyperBot! 🤖 ✨
|
| 325 |
''')
|
| 326 |
|
| 327 |
+
option_ = ['Ask me anything!😊','Ask me anything (CSV file data)!📊']
|
| 328 |
Usage = st.selectbox('Select an option:', option_)
|
| 329 |
|
| 330 |
if Usage == 'Questions based on custom CSV data':
|
|
|
|
| 359 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 360 |
|
| 361 |
|
| 362 |
+
with st.form(key='columns_in_form'):
|
| 363 |
+
col1, col2 = st.columns(2)
|
| 364 |
+
with col3:
|
| 365 |
+
userPrompt = st.text_area("Input Prompt",'Enter Natural Language Query')
|
| 366 |
+
submitButton = st.form_submit_button(label = 'Submit')
|
| 367 |
+
if submitButton:
|
| 368 |
+
try:
|
| 369 |
+
col_p ="Create SQL statement from instruction. "+ext+" " " (" + column +")." +" Request:" + userPrompt + "SQL statement:"
|
| 370 |
+
result = gpt3(col_p)
|
| 371 |
+
except:
|
| 372 |
+
results = gpt3(userPrompt)
|
| 373 |
+
st.success('loaded')
|
| 374 |
+
with col4:
|
|
|
|
| 375 |
sqlOutput = gpt3(col_p) #st.text_area('SQL Query', value=gpt3(col_p))
|
| 376 |
warning(sqlOutput)
|
| 377 |
+
# cars=pd.read_csv('cars.csv')
|
| 378 |
result_tab2=ps.sqldf(sqlOutput)
|
| 379 |
st.write(result_tab2)
|
| 380 |
with open("fewshot_matplot.txt", "r") as file:
|
|
|
|
| 409 |
else:
|
| 410 |
print('Retry! Graph could not be plotted *_*')
|
| 411 |
|
|
|
|
|
|
|
|
|
|
| 412 |
elif res == "Sample_Cars_csv":
|
| 413 |
df = pd.read_csv('cars.csv')
|
| 414 |
col= df.columns
|
|
|
|
| 423 |
temp = st.slider('Temperature: ', 0.0, 1.0, 0.0)
|
| 424 |
|
| 425 |
|
| 426 |
+
with st.form(key='columns_in_form'):
|
| 427 |
+
col1, col2 = st.columns(2)
|
| 428 |
+
with col1:
|
| 429 |
+
userPrompt = st.text_area("Input Prompt",'Enter Natural Language Query')
|
| 430 |
+
submitButton = st.form_submit_button(label = 'Submit')
|
| 431 |
+
if submitButton:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
try:
|
| 433 |
+
col_p ="Create SQL statement from instruction. "+ext+" " " (" + column +")." +" Request:" + userPrompt + "SQL statement:"
|
| 434 |
+
result = gpt3(col_p)
|
| 435 |
+
except:
|
| 436 |
+
results = gpt3(userPrompt)
|
| 437 |
+
st.success('loaded')
|
| 438 |
+
|
| 439 |
+
with col2:
|
| 440 |
+
sqlOutput = gpt3(col_p) #st.text_area('SQL Query', value=gpt3(col_p))
|
| 441 |
+
warning(sqlOutput)
|
| 442 |
+
cars=pd.read_csv('cars.csv')
|
| 443 |
+
result_tab2=ps.sqldf(sqlOutput)
|
| 444 |
+
st.write(result_tab2)
|
| 445 |
+
|
| 446 |
+
with open("fewshot_matplot.txt", "r") as file:
|
| 447 |
+
text_plot = file.read()
|
| 448 |
+
|
| 449 |
+
result_tab = result_tab2.reset_index(drop=True)
|
| 450 |
+
result_tab_string = result_tab.to_string()
|
| 451 |
+
gr_prompt = text_plot + userPrompt + result_tab_string + "Plot graph for: "
|
| 452 |
+
|
| 453 |
+
if len(gr_prompt) > 4097:
|
| 454 |
+
st.write('OVERWHELMING DATA!!! You have given me more than 4097 tokens! ^_^')
|
| 455 |
+
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 ^_^')
|
| 456 |
+
|
| 457 |
+
elif len(result_tab2.columns) < 2:
|
| 458 |
+
st.write("I need more data to conduct analysis and provide visualizations for you... ^_^")
|
| 459 |
+
|
| 460 |
+
else:
|
| 461 |
+
st.success("Plotting...")
|
| 462 |
+
response_graph = openai.Completion.create(
|
| 463 |
+
engine="text-davinci-003",
|
| 464 |
+
prompt = gr_prompt,
|
| 465 |
+
max_tokens=1024,
|
| 466 |
+
n=1,
|
| 467 |
+
stop=None,
|
| 468 |
+
temperature=0.5,
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
if response_graph['choices'][0]['text'] != "":
|
| 472 |
+
print(response_graph['choices'][0]['text'])
|
| 473 |
+
exec(response_graph['choices'][0]['text'])
|
| 474 |
+
|
| 475 |
+
else:
|
| 476 |
+
print('Retry! Graph could not be plotted *_*')
|
| 477 |
|
| 478 |
+
elif Usage == 'Ask me anything!😊':
|
| 479 |
st.text('''You can ask me:
|
| 480 |
1. All the things you ask ChatGPT.
|
| 481 |
2. Generating paintings, drawings, abstract art.
|