Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| from functools import partial | |
| from get_answer import get_answer | |
| from logs import save_logs | |
| import gdown | |
| from config import folder_id, json_url_id | |
| download_url = f'https://drive.google.com/uc?id={json_url_id}' | |
| output = 'secret_google_service_account.json' | |
| gdown.download(download_url, output, quiet=False) | |
| sys_prompt = """You are an experimental AI-copilot for doctors. They will check your outputs | |
| You will be given by the doctor patient data input and your role will be to determine the most probable diagnose. | |
| You will include all relevant literature backup and references needed and a whole reasoning path of why you think it is. Reasoning should be based on medical literature, socio environmental factors, sources. | |
| Be very professional and redact as a health practitioner. Your response should reflect a full path to diagnose. | |
| You format our output in the best way possible to make it as it this tool is more than simply chatgpt. | |
| """ | |
| def stream(query): | |
| resp = get_answer(query) | |
| answer = "" | |
| for chunk in resp: | |
| if chunk.choices[0].delta.content is not None: | |
| answer = answer + chunk.choices[0].delta.content | |
| yield answer | |
| # save_logs(query, answer, folder_id=folder_id) | |
| title = "" | |
| with gr.Blocks(title=title,theme='nota-ai/theme',css="footer {visibility: hidden}") as demo: | |
| gr.Markdown(f"## {title}") | |
| with gr.Row(): | |
| with gr.Column(scale=6): | |
| with gr.Row(): | |
| with gr.Column(scale=3): | |
| chat_submit_button = gr.Button(value="Submit ▶") | |
| with gr.Accordion("config", open=False, visible=False): | |
| prompt = gr.Textbox(value=sys_prompt, lines=15, label="prompt", visible=False) | |
| url_input = gr.Textbox(placeholder="Age, medical results", lines=15, label="Input patient data") | |
| with gr.Column(scale=6): | |
| compliance_output = gr.Markdown("Waiting for patient data...") | |
| fn_chat = get_answer | |
| chat_submit_button.click(fn=fn_chat, inputs=[url_input, prompt], outputs=[compliance_output]) | |
| demo.launch(max_threads=40) | |