Spaces:
Paused
Paused
| import logging | |
| import os | |
| import gradio as gr | |
| from generate_response import set_llm, generate_chat_response | |
| from vectorize import load_write_index_nodes | |
| logger = logging.getLogger("agent_logger") | |
| # idk who is passing two arguments to chat when I am not using the history anywhere and i don't care to find out so | |
| # don't remove this argument please | |
| def chat(message, history): | |
| index, nodes = load_write_index_nodes(path='./storage_mx') | |
| for response_text in generate_chat_response(index, message): | |
| yield response_text | |
| if __name__ == '__main__': | |
| api_key = os.getenv('mx_api_key') | |
| set_llm(key=api_key, model="mistral-large-latest", temperature=0) | |
| logger.info("Launching Gradio ChatInterface...") | |
| examples = ["How do I put my newborn in a cot?", "Hoe kan ik slapen in een onrustige buurt?", | |
| "Yatmadan önce yememiz gereken yiyecekler var mı?"] | |
| description = (''' | |
| <div style="text-align:center;"> | |
| <span style="white-space: nowrap; display: inline-block;"> | |
| <img src="./img/logo.png" alt="TU Delft Logo" width="200" style="display: inline; vertical-align: middle;"/> | |
| <img src="./img/logo-em.jpg" alt="Erasmus MC Logo" width="200" style="display: inline; vertical-align: middle;"/> | |
| </span><br/> | |
| Welcome to Our Smart Family Buddy. This is <span style="font-weight: bold;">SleepBot</span>. SleepBot can answer your questions about you, | |
| and your family's, sleep health. For more family support see: <a href="https://cjgrijnmond.nl/">cjgrijnmond.nl</a>. For medical | |
| questions see: <a href="https://www.thuisarts.nl/">thuisarts.nl</a?. | |
| </div> | |
| ''') | |
| demo = gr.ChatInterface(fn=chat, type="messages", title="SleepBot", description=description, examples=examples, | |
| show_progress="full", theme="soft") | |
| demo.launch() | |
| # demo.queue().launch(auth=('sleepbot', 'testing24')) | |