Spaces:
Running
Running
File size: 1,420 Bytes
114ce4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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)
worker.process_document(document_path)
def handle_prompt(message, history):
bot_response = worker.process_prompt(message)
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() |