Update app.py
Browse files
app.py
CHANGED
|
@@ -380,16 +380,16 @@ def gpt_response_to_dataframe(gpt_response):
|
|
| 380 |
def chatbot(user_input, science_objectives="", context="", subdomain="", max_tokens=150, temperature=0.7, top_p=0.9, frequency_penalty=0.5, presence_penalty=0.0):
|
| 381 |
|
| 382 |
|
| 383 |
-
yield "π Connecting with Pinecone...", None, None, None, None
|
| 384 |
|
| 385 |
pc_index_name = "scdd-index"
|
| 386 |
-
yield f"Using Pinecone index: **{index_name}**β
", None, None, None, None
|
| 387 |
|
| 388 |
-
yield "π Retrieving relevant context from Pinecone...", None, None, None, None
|
| 389 |
# Retrieve relevant context using Pinecone
|
| 390 |
relevant_context = retrieve_relevant_context(user_input, context, science_objectives)
|
| 391 |
|
| 392 |
-
yield "Context Retrieved successfully β
", None, None, None, None
|
| 393 |
|
| 394 |
keywords = extract_keywords_with_gpt(context)
|
| 395 |
|
|
@@ -398,7 +398,7 @@ def chatbot(user_input, science_objectives="", context="", subdomain="", max_tok
|
|
| 398 |
# Fetch NASA ADS references using the user context
|
| 399 |
references = fetch_nasa_ads_references(ads_query)
|
| 400 |
|
| 401 |
-
yield "π Generating structured response using GPT-4o...", None, None, None, None
|
| 402 |
|
| 403 |
# Generate response from GPT-4
|
| 404 |
full_response, response_only = generate_response(
|
|
@@ -413,7 +413,7 @@ def chatbot(user_input, science_objectives="", context="", subdomain="", max_tok
|
|
| 413 |
presence_penalty=presence_penalty
|
| 414 |
)
|
| 415 |
|
| 416 |
-
yield "Response generated successfully β
", None, None, None, None
|
| 417 |
|
| 418 |
# Append user-defined science objectives if provided
|
| 419 |
if science_objectives.strip():
|
|
@@ -425,7 +425,7 @@ def chatbot(user_input, science_objectives="", context="", subdomain="", max_tok
|
|
| 425 |
max_tokens, temperature, top_p, frequency_penalty, presence_penalty
|
| 426 |
)
|
| 427 |
|
| 428 |
-
yield "Writing SCDD...", None, None, None, None
|
| 429 |
|
| 430 |
# Fetch exoplanet data and generate insights
|
| 431 |
exoplanet_data = fetch_exoplanet_data()
|
|
@@ -437,7 +437,7 @@ def chatbot(user_input, science_objectives="", context="", subdomain="", max_tok
|
|
| 437 |
# Combine response and insights
|
| 438 |
full_response = f"{full_response}\n\nEnd of Response"
|
| 439 |
|
| 440 |
-
yield "SCDD produced successfully β
", None, None, None, None
|
| 441 |
|
| 442 |
iframe_html = """<iframe width=\"768\" height=\"432\" src=\"https://miro.com/app/live-embed/uXjVKuVTcF8=/?moveToViewport=-331,-462,5434,3063&embedId=710273023721\" frameborder=\"0\" scrolling=\"no\" allow=\"fullscreen; clipboard-read; clipboard-write\" allowfullscreen></iframe>"""
|
| 443 |
mapify_button_html = """<a href=\"https://mapify.so/app/new\" target=\"_blank\"><button>Create Mind Map on Mapify</button></a>"""
|
|
@@ -478,7 +478,7 @@ with gr.Blocks() as demo:
|
|
| 478 |
|
| 479 |
submit_button.click(chatbot, inputs=[user_input, science_objectives_input, context, subdomain, max_tokens, temperature, top_p, frequency_penalty, presence_penalty], outputs=[full_response, relevant_context, extracted_table_df, word_doc_path, iframe_html, mapify_button_html],queue=True)
|
| 480 |
|
| 481 |
-
clear_button.click(lambda: ("", "", "", "", 150, 0.7, 0.9, 0.5, 0.0, "", None, None, None, None), outputs=[user_input, science_objectives_input, context, subdomain, max_tokens, temperature, top_p, frequency_penalty, presence_penalty, full_response, relevant_context, extracted_table_df, word_doc_path, iframe_html, mapify_button_html])
|
| 482 |
|
| 483 |
demo.launch(share=True)
|
| 484 |
|
|
|
|
| 380 |
def chatbot(user_input, science_objectives="", context="", subdomain="", max_tokens=150, temperature=0.7, top_p=0.9, frequency_penalty=0.5, presence_penalty=0.0):
|
| 381 |
|
| 382 |
|
| 383 |
+
yield "π Connecting with Pinecone...", None, None, None, None, None
|
| 384 |
|
| 385 |
pc_index_name = "scdd-index"
|
| 386 |
+
yield f"Using Pinecone index: **{index_name}**β
", None, None, None, None, None
|
| 387 |
|
| 388 |
+
yield "π Retrieving relevant context from Pinecone...", None, None, None, None, None
|
| 389 |
# Retrieve relevant context using Pinecone
|
| 390 |
relevant_context = retrieve_relevant_context(user_input, context, science_objectives)
|
| 391 |
|
| 392 |
+
yield "Context Retrieved successfully β
", None, None, None, None, None
|
| 393 |
|
| 394 |
keywords = extract_keywords_with_gpt(context)
|
| 395 |
|
|
|
|
| 398 |
# Fetch NASA ADS references using the user context
|
| 399 |
references = fetch_nasa_ads_references(ads_query)
|
| 400 |
|
| 401 |
+
yield "π Generating structured response using GPT-4o...", None, None, None, None, None
|
| 402 |
|
| 403 |
# Generate response from GPT-4
|
| 404 |
full_response, response_only = generate_response(
|
|
|
|
| 413 |
presence_penalty=presence_penalty
|
| 414 |
)
|
| 415 |
|
| 416 |
+
yield "Response generated successfully β
", None, None, None, None, None
|
| 417 |
|
| 418 |
# Append user-defined science objectives if provided
|
| 419 |
if science_objectives.strip():
|
|
|
|
| 425 |
max_tokens, temperature, top_p, frequency_penalty, presence_penalty
|
| 426 |
)
|
| 427 |
|
| 428 |
+
yield "Writing SCDD...", None, None, None, None, None
|
| 429 |
|
| 430 |
# Fetch exoplanet data and generate insights
|
| 431 |
exoplanet_data = fetch_exoplanet_data()
|
|
|
|
| 437 |
# Combine response and insights
|
| 438 |
full_response = f"{full_response}\n\nEnd of Response"
|
| 439 |
|
| 440 |
+
yield "SCDD produced successfully β
", None, None, None, None, None
|
| 441 |
|
| 442 |
iframe_html = """<iframe width=\"768\" height=\"432\" src=\"https://miro.com/app/live-embed/uXjVKuVTcF8=/?moveToViewport=-331,-462,5434,3063&embedId=710273023721\" frameborder=\"0\" scrolling=\"no\" allow=\"fullscreen; clipboard-read; clipboard-write\" allowfullscreen></iframe>"""
|
| 443 |
mapify_button_html = """<a href=\"https://mapify.so/app/new\" target=\"_blank\"><button>Create Mind Map on Mapify</button></a>"""
|
|
|
|
| 478 |
|
| 479 |
submit_button.click(chatbot, inputs=[user_input, science_objectives_input, context, subdomain, max_tokens, temperature, top_p, frequency_penalty, presence_penalty], outputs=[full_response, relevant_context, extracted_table_df, word_doc_path, iframe_html, mapify_button_html],queue=True)
|
| 480 |
|
| 481 |
+
clear_button.click(lambda: ("", "", "", "", 150, 0.7, 0.9, 0.5, 0.0, "", "", None, None, None, None), outputs=[user_input, science_objectives_input, context, subdomain, max_tokens, temperature, top_p, frequency_penalty, presence_penalty, full_response, relevant_context, extracted_table_df, word_doc_path, iframe_html, mapify_button_html])
|
| 482 |
|
| 483 |
demo.launch(share=True)
|
| 484 |
|