Spaces:
Running
Running
import gradio as gr | |
import worker | |
import requests | |
from pathlib import Path | |
import torchvision | |
torchvision.disable_beta_transforms_warning() | |
# Get data from url | |
url = 'https://camels.readthedocs.io/_/downloads/en/latest/pdf/' | |
r = requests.get(url, stream=True) | |
document_path = Path('metadata.pdf') | |
document_path.write_bytes(r.content) | |
# document_path="2022GS.pdf" | |
worker.process_document(document_path) | |
def handle_prompt(message, history): | |
bot_response = worker.process_prompt(message, history) | |
return bot_response | |
greetingsmessage = "Hi, I'm the CAMELS DocBot, I'm here to assist you with any question related to the CAMELS simulations documentation" | |
example_questions = [ | |
"How can i read a halo file?", | |
"Which simulation suites are included in CAMELS?", | |
"Which are the largest volumes in CAMELS simulations?", | |
"How can I get the power spectrum of a simulation?" | |
] | |
# chatbot = gr.Chatbot(value=[{"role": "assistant", "content": greetingsmessage}]) | |
# chatbot = gr.Chatbot(value=[[None, greetingsmessage]]) | |
# chatbot = gr.Chatbot(value=gr.ChatMessage(role="assistant",content="How can I help you?")) | |
# chatbot = gr.Chatbot(placeholder=greetingsmessage) | |
demo = gr.ChatInterface(handle_prompt, type="messages", title="CAMELS DocBot",examples=example_questions, theme=gr.themes.Soft(), description=greetingsmessage)#, chatbot=chatbot) | |
demo.launch() |